diff --git a/.nant/local.include b/.nant/local.include deleted file mode 100644 index be79d1cfce4..00000000000 --- a/.nant/local.include +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BUILDING.md b/BUILDING.md index 2d91710fad2..4eb287a38a9 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,10 +1,26 @@ +# git clone + +get or update source from git + + `git clone git://opensimulator.org/git/opensim` + + + # Building on Windows ## Requirements For building under Windows, the following is required: * [Microsoft DotNet 6.0](https://dotnet.microsoft.com/en-us/download), version 6.0 or later. - dotnet 6.0 is the LTS version and is recommended. + dotnet 8.0 is the LTS version and is recommended. + To building under Windows, the following is required: + + * [dotnet 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) + +optionally also + + * [Visual Studio .NET](https://visualstudio.microsoft.com/vs/features/net-development/), version 2022 or later + ### Building Prebuild is no longer used. There is a top level Solution (sln) and csproj files for each @@ -18,7 +34,10 @@ Either command will do a NuGet restore (dotnet restore) to restore any required kicking off a build using a current version of msbuild. The Csproj and SLN files are all designed to use the new format for Msbuild which is simplified and really directly replaces what prebuild provided. -Load the generated OpenSim.sln into Visual Studio .NET and build the solution. +run + `compile.bat` + +Or load the generated OpenSim.sln into Visual Studio or Visual Studio Code and build the solution. Configure, see below @@ -28,10 +47,14 @@ The resulting build will be generated to ./build/{Debug|Release}/ ## Requirements - * [Mono > 5.0](https://www.mono-project.com/download/stable/#download-lin) - * On some Linux distributions you may need to install additional packages. - * [Microsoft DotNet 6.0](https://dotnet.microsoft.com/en-us/download), version 6.0 or later. - dotnet 6.0 is the LTS version and is recommended. + * [dotnet 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) + * libgdiplus + + if you have mono 6.x complete, you already have libgdiplus, otherwise you need to install it + using a package manager for your operating system, like apt, brew, macports, etc + for example on debian: + + `apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev` ### Building Prebuild is no longer used. There is a top level Solution (sln) and csproj files for each diff --git a/Directory.Build.props b/Directory.Build.props index bc5ea01bfa8..8675639bab1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,10 @@ false + disable + disable + false + true $(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\ $(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\ $(SolutionDir)\build\$(Configuration)\$(AssemblyName)\ diff --git a/OpenSim.sln b/OpenSim.sln index 153dbe5b516..1264c9ea0f9 100644 --- a/OpenSim.sln +++ b/OpenSim.sln @@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Capabilities", "Ope EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Capabilities.Handlers", "OpenSim\Capabilities\Handlers\OpenSim.Capabilities.Handlers.csproj", "{002BDDF6-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Capabilities.Handlers.Tests", "OpenSim\Capabilities\Handlers\OpenSim.Capabilities.Handlers.Tests.csproj", "{507CDB79-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.ConsoleClient", "OpenSim\ConsoleClient\OpenSim.ConsoleClient.csproj", "{CB348113-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Data", "OpenSim\Data\OpenSim.Data.csproj", "{7E218E2D-0000-0000-0000-000000000000}" @@ -35,8 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Data.PGSQL", "OpenS EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Data.SQLite", "OpenSim\Data\SQLite\OpenSim.Data.SQLite.csproj", "{675096A5-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Data.Tests", "OpenSim\Data\Tests\OpenSim.Data.Tests.csproj", "{37FD59A6-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework", "OpenSim\Framework\OpenSim.Framework.csproj", "{BCCDBB55-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.AssetLoader.Filesystem", "OpenSim\Framework\AssetLoader\Filesystem\OpenSim.Framework.AssetLoader.Filesystem.csproj", "{384A4FAB-0000-0000-0000-000000000000}" @@ -47,46 +43,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Monitorin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Serialization", "OpenSim\Framework\Serialization\OpenSim.Framework.Serialization.csproj", "{BD63E665-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Serialization.Tests", "OpenSim\Framework\Serialization\Tests\OpenSim.Framework.Serialization.Tests.csproj", "{B3B5B07A-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Servers", "OpenSim\Framework\Servers\OpenSim.Framework.Servers.csproj", "{726D540D-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Servers.HttpServer", "OpenSim\Framework\Servers\HttpServer\OpenSim.Framework.Servers.HttpServer.csproj", "{159EC5C2-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Servers.Tests", "OpenSim\Framework\Servers\Tests\OpenSim.Framework.Servers.Tests.csproj", "{743E90C2-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Framework.Tests", "OpenSim\Framework\Tests\OpenSim.Framework.Tests.csproj", "{FA62D900-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ClientStack.LindenCaps", "OpenSim\Region\ClientStack\Linden\Caps\OpenSim.Region.ClientStack.LindenCaps.csproj", "{574BCA63-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ClientStack.LindenCaps.Tests", "OpenSim\Region\ClientStack\Linden\Caps\OpenSim.Region.ClientStack.LindenCaps.Tests.csproj", "{A461C3AC-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ClientStack.LindenUDP", "OpenSim\Region\ClientStack\Linden\UDP\OpenSim.Region.ClientStack.LindenUDP.csproj", "{E7F1E4AB-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ClientStack.LindenUDP.Tests", "OpenSim\Region\ClientStack\Linden\UDP\Tests\OpenSim.Region.ClientStack.LindenUDP.Tests.csproj", "{6E5280E2-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.CoreModules", "OpenSim\Region\CoreModules\OpenSim.Region.CoreModules.csproj", "{B60B8DCD-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.CoreModules.Tests", "OpenSim\Region\CoreModules\OpenSim.Region.CoreModules.Tests.csproj", "{3B99D6D0-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.Framework", "OpenSim\Region\Framework\OpenSim.Region.Framework.csproj", "{C98F6D97-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.Framework.Tests", "OpenSim\Region\Framework\OpenSim.Region.Framework.Tests.csproj", "{BEF3BCBC-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.OptionalModules", "OpenSim\Region\OptionalModules\OpenSim.Region.OptionalModules.csproj", "{BAF8E8F2-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.BasicPhysics", "OpenSim\Region\PhysicsModules\BasicPhysics\OpenSim.Region.PhysicsModule.BasicPhysics.csproj", "{BAC989A5-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.BulletS", "OpenSim\Region\PhysicsModules\BulletS\OpenSim.Region.PhysicsModule.BulletS.csproj", "{223BC46D-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.BulletS.Tests", "OpenSim\Region\PhysicsModules\BulletS\Tests\OpenSim.Region.PhysicsModule.BulletS.Tests.csproj", "{7364753A-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.Meshing", "OpenSim\Region\PhysicsModules\Meshing\OpenSim.Region.PhysicsModule.Meshing.csproj", "{5ECE503F-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.Ode", "OpenSim\Region\PhysicsModules\Ode\OpenSim.Region.PhysicsModule.Ode.csproj", "{BD76F0CA-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.Ode.Tests", "OpenSim\Region\PhysicsModules\Ode\Tests\OpenSim.Region.PhysicsModule.Ode.Tests.csproj", "{968D2EA9-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.POS", "OpenSim\Region\PhysicsModules\POS\OpenSim.Region.PhysicsModule.POS.csproj", "{2400666E-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.PhysicsModule.ubOde", "OpenSim\Region\PhysicsModules\ubOde\OpenSim.Region.PhysicsModule.ubOde.csproj", "{AC52DE31-0000-0000-0000-000000000000}" @@ -107,20 +83,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine.Shared.Instance", "OpenSim\Region\ScriptEngine\Shared\Instance\OpenSim.Region.ScriptEngine.Shared.Instance.csproj", "{B185E548-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine.Tests", "OpenSim\Region\ScriptEngine\OpenSim.Region.ScriptEngine.Tests.csproj", "{CBDD2219-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine.XEngine", "OpenSim\Region\ScriptEngine\XEngine\OpenSim.Region.ScriptEngine.XEngine.csproj", "{798F0488-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine.XEngine.Api.Runtime", "OpenSim\Region\ScriptEngine\XEngine\Api\Runtime\OpenSim.Region.ScriptEngine.XEngine.Api.Runtime.csproj", "{4A4B6F6C-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Region.ScriptEngine.YEngine", "OpenSim\Region\ScriptEngine\YEngine\OpenSim.Region.ScriptEngine.YEngine.csproj", "{798B4867-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Server.Base", "OpenSim\Server\Base\OpenSim.Server.Base.csproj", "{2E0569BB-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Server.Handlers", "OpenSim\Server\Handlers\OpenSim.Server.Handlers.csproj", "{ED041501-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Server.Handlers.Tests", "OpenSim\Server\Handlers\OpenSim.Server.Handlers.Tests.csproj", "{AC0DDB9E-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.AssetService", "OpenSim\Services\AssetService\OpenSim.Services.AssetService.csproj", "{7FDD1B76-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.AuthenticationService", "OpenSim\Services\AuthenticationService\OpenSim.Services.AuthenticationService.csproj", "{76495B84-0000-0000-0000-000000000000}" @@ -149,8 +117,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.Interfaces EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.InventoryService", "OpenSim\Services\InventoryService\OpenSim.Services.InventoryService.csproj", "{0066981A-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.InventoryService.Tests", "OpenSim\Services\InventoryService\Tests\OpenSim.Services.InventoryService.Tests.csproj", "{D4979419-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.LLLoginService", "OpenSim\Services\LLLoginService\OpenSim.Services.LLLoginService.csproj", "{84F83E53-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.MapImageService", "OpenSim\Services\MapImageService\OpenSim.Services.MapImageService.csproj", "{B03715E7-0000-0000-0000-000000000000}" @@ -165,22 +131,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.UserAccoun EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Services.UserProfilesService", "OpenSim\Services\UserProfilesService\OpenSim.Services.UserProfilesService.csproj", "{B4C57E7D-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests", "OpenSim\Tests\OpenSim.Tests.csproj", "{CCCB2DA6-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests.Clients.AssetClient", "OpenSim\Tests\Clients\Assets\OpenSim.Tests.Clients.AssetClient.csproj", "{5BC4E133-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests.Common", "OpenSim\Tests\Common\OpenSim.Tests.Common.csproj", "{CC43930F-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests.Performance", "OpenSim\Tests\Performance\OpenSim.Tests.Performance.csproj", "{24A774FE-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests.Permissions", "OpenSim\Tests\Permissions\OpenSim.Tests.Permissions.csproj", "{E0DDF05C-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tests.Stress", "OpenSim\Tests\Stress\OpenSim.Tests.Stress.csproj", "{660D26BC-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tools.Configger", "OpenSim\Tools\Configger\OpenSim.Tools.Configger.csproj", "{2F0C334A-0000-0000-0000-000000000000}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Tools.lslc", "OpenSim\Tools\Compiler\OpenSim.Tools.lslc.csproj", "{12EC22DE-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSimMutelist.Modules", "addon-modules\OpenSimMutelist\Modules\OpenSimMutelist.Modules.csproj", "{87C4E6E3-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSimSearch.Modules", "addon-modules\OpenSimSearch\Modules\OpenSimSearch.Modules.csproj", "{BE5D1132-0000-0000-0000-000000000000}" @@ -189,8 +139,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "pCampBot", "OpenSim\Tools\p EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Robust", "OpenSim\Server\Robust.csproj", "{6E64F01D-0000-0000-0000-000000000000}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Robust.Tests", "OpenSim\Tests\Robust\Robust.Tests.csproj", "{D2E26E14-0000-0000-0000-000000000000}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SmartThreadPool", "ThirdParty\SmartThreadPool\SmartThreadPool.csproj", "{8C618053-0000-0000-0000-000000000000}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenSim.Data.MySQL.MoneyData", "addon-modules\OpenSim.Data.MySQL.MoneyData\OpenSim.Data.MySQL.MoneyData\OpenSim.Data.MySQL.MoneyData.csproj", "{A9CF27A6-3E23-4A10-82DA-604CA8C577D9}" @@ -241,10 +189,6 @@ Global {002BDDF6-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {002BDDF6-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {002BDDF6-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {507CDB79-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {507CDB79-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {507CDB79-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {507CDB79-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {CB348113-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB348113-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB348113-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -269,10 +213,6 @@ Global {675096A5-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {675096A5-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {675096A5-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {37FD59A6-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {37FD59A6-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {37FD59A6-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {37FD59A6-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {BCCDBB55-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BCCDBB55-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {BCCDBB55-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -293,10 +233,6 @@ Global {BD63E665-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD63E665-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD63E665-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {B3B5B07A-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3B5B07A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3B5B07A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3B5B07A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {726D540D-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {726D540D-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {726D540D-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -305,46 +241,22 @@ Global {159EC5C2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {159EC5C2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {159EC5C2-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {743E90C2-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {743E90C2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {743E90C2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {743E90C2-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {FA62D900-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FA62D900-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FA62D900-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FA62D900-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {574BCA63-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {574BCA63-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {574BCA63-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {574BCA63-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {A461C3AC-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A461C3AC-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A461C3AC-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A461C3AC-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {E7F1E4AB-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E7F1E4AB-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {E7F1E4AB-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {E7F1E4AB-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {6E5280E2-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6E5280E2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6E5280E2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6E5280E2-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {B60B8DCD-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B60B8DCD-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {B60B8DCD-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {B60B8DCD-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {3B99D6D0-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B99D6D0-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B99D6D0-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B99D6D0-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {C98F6D97-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C98F6D97-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {C98F6D97-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {C98F6D97-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {BEF3BCBC-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BEF3BCBC-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BEF3BCBC-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BEF3BCBC-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {BAF8E8F2-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BAF8E8F2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {BAF8E8F2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -357,22 +269,10 @@ Global {223BC46D-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {223BC46D-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {223BC46D-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {7364753A-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7364753A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7364753A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7364753A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {5ECE503F-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5ECE503F-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {5ECE503F-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {5ECE503F-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {BD76F0CA-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD76F0CA-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD76F0CA-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD76F0CA-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {968D2EA9-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {968D2EA9-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {968D2EA9-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {968D2EA9-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {2400666E-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2400666E-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {2400666E-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -413,18 +313,6 @@ Global {B185E548-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {B185E548-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {B185E548-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {CBDD2219-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CBDD2219-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CBDD2219-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CBDD2219-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {798F0488-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {798F0488-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {798F0488-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {798F0488-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {4A4B6F6C-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A4B6F6C-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A4B6F6C-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A4B6F6C-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {798B4867-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {798B4867-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {798B4867-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -437,10 +325,6 @@ Global {ED041501-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED041501-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED041501-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {AC0DDB9E-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC0DDB9E-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC0DDB9E-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC0DDB9E-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {7FDD1B76-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7FDD1B76-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FDD1B76-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -497,10 +381,6 @@ Global {0066981A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {0066981A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {0066981A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {D4979419-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4979419-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4979419-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4979419-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {84F83E53-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {84F83E53-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {84F83E53-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -529,38 +409,6 @@ Global {B4C57E7D-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4C57E7D-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {B4C57E7D-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {CCCB2DA6-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CCCB2DA6-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CCCB2DA6-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CCCB2DA6-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {5BC4E133-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5BC4E133-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5BC4E133-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5BC4E133-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {CC43930F-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC43930F-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC43930F-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC43930F-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {24A774FE-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24A774FE-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24A774FE-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24A774FE-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {E0DDF05C-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0DDF05C-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0DDF05C-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0DDF05C-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {660D26BC-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {660D26BC-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {660D26BC-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {660D26BC-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {2F0C334A-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2F0C334A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2F0C334A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2F0C334A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {12EC22DE-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {12EC22DE-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {12EC22DE-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {12EC22DE-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {87C4E6E3-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {87C4E6E3-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {87C4E6E3-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -577,10 +425,6 @@ Global {6E64F01D-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E64F01D-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E64F01D-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU - {D2E26E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2E26E14-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2E26E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2E26E14-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU {8C618053-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C618053-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C618053-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs index dc52320b32e..e5aa79b8246 100755 --- a/OpenSim/Addons/Groups/GroupsMessagingModule.cs +++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs @@ -325,7 +325,7 @@ public void SendMessageToGroup( im.RegionID = thisClient.Scene.RegionInfo.RegionID.Guid; } - if ((im.binaryBucket == null) || (im.binaryBucket.Length == 0) || ((im.binaryBucket.Length == 1 && im.binaryBucket[0] == 0))) + if (im.binaryBucket is null || im.binaryBucket.Length == 0 || (im.binaryBucket.Length == 1 && im.binaryBucket[0] == 0)) { ExtendedGroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), groupID, null); if (groupInfo != null) diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index 314a6057953..cfca4e6003e 100755 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -1113,7 +1113,7 @@ public GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, { m_log.DebugFormat("[Groups]: Group Notice {0} not found, composing empty message.", groupNoticeID); msg.fromAgentID = UUID.Zero.Guid; - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); ; + msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.fromAgentName = string.Empty; msg.message = string.Empty; msg.binaryBucket = Array.Empty(); ; @@ -1275,7 +1275,7 @@ public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = regionInfo.RegionID.Guid; - msg.binaryBucket = Array.Empty(); ; + msg.binaryBucket = Array.Empty(); OutgoingInstantMessage(msg, ejecteeID); } @@ -1293,7 +1293,7 @@ public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = regionInfo.RegionID.Guid; - msg.binaryBucket = Array.Empty(); ; + msg.binaryBucket = Array.Empty(); OutgoingInstantMessage(msg, agentID); } @@ -1575,17 +1575,12 @@ public void NotifyChange(UUID groupID) private string GetRequestingAgentIDStr(IClientAPI client) { - return GetRequestingAgentID(client).ToString(); + return client is null ? UUID.ZeroString : client.AgentId.ToString(); } private UUID GetRequestingAgentID(IClientAPI client) { - UUID requestingAgentID = UUID.Zero; - if (client != null) - { - requestingAgentID = client.AgentId; - } - return requestingAgentID; + return client is null ? UUID.Zero : client.AgentId; } } diff --git a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnector.cs b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnector.cs index 5bca6540922..98a9d4627d7 100644 --- a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnector.cs +++ b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnector.cs @@ -285,8 +285,7 @@ private Dictionary MakeRequest(string method, Dictionary replyData = ServerUtils.ParseXmlResponse( - reply); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); return replyData; } diff --git a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs index dd06c958262..580221fa639 100644 --- a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs +++ b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs @@ -164,12 +164,11 @@ private void OnNewClient(IClientAPI client) void OnCompleteMovementToRegion(IClientAPI client, bool arg2) { - object sp = null; - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) + if (client.SceneAgent is ScenePresence sp) { - if (sp is ScenePresence && ((ScenePresence)sp).PresenceType != PresenceType.Npc) + if (sp.PresenceType != PresenceType.Npc) { - AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); + AgentCircuitData aCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 && m_OfflineIM != null && m_Messaging != null) { @@ -460,7 +459,7 @@ public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID) { - return m_LocalGroupsConnector.GetAgentToGroupInvite(AgentUUI(RequestingAgentID), inviteID); ; + return m_LocalGroupsConnector.GetAgentToGroupInvite(AgentUUI(RequestingAgentID), inviteID); } public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID) diff --git a/OpenSim/Addons/Groups/Local/GroupsServiceLocalConnectorModule.cs b/OpenSim/Addons/Groups/Local/GroupsServiceLocalConnectorModule.cs index cee1c9c8ff5..312d4adf690 100644 --- a/OpenSim/Addons/Groups/Local/GroupsServiceLocalConnectorModule.cs +++ b/OpenSim/Addons/Groups/Local/GroupsServiceLocalConnectorModule.cs @@ -240,7 +240,7 @@ public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID) { - return m_GroupsService.GetAgentToGroupInvite(RequestingAgentID, inviteID); ; + return m_GroupsService.GetAgentToGroupInvite(RequestingAgentID, inviteID); } public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID) @@ -285,7 +285,7 @@ public void UpdateMembership(string RequestingAgentID, string AgentID, UUID Grou public ExtendedGroupMembershipData GetAgentGroupMembership(string RequestingAgentID, string AgentID, UUID GroupID) { - return m_GroupsService.GetAgentGroupMembership(RequestingAgentID, AgentID, GroupID); ; + return m_GroupsService.GetAgentGroupMembership(RequestingAgentID, AgentID, GroupID); } public List GetAgentGroupMemberships(string RequestingAgentID, string AgentID) diff --git a/OpenSim/Addons/Groups/OpenSim.Addons.Groups.csproj b/OpenSim/Addons/Groups/OpenSim.Addons.Groups.csproj index 520c13a59b1..59ac44cf54e 100644 --- a/OpenSim/Addons/Groups/OpenSim.Addons.Groups.csproj +++ b/OpenSim/Addons/Groups/OpenSim.Addons.Groups.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Addons.Groups http://opensimulator.org OpenSim.Addons.Groups @@ -12,6 +12,7 @@ + diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs index a52a91577e8..1fc3afd1efd 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs @@ -327,7 +327,7 @@ public List GetAgentGroupRoles(string RequestingAgentID, string { return m_CacheWrapper.GetAgentGroupRoles(RequestingAgentID, AgentID, GroupID, delegate { - return m_GroupsService.GetAgentGroupRoles(RequestingAgentID, AgentID, GroupID); + return m_GroupsService.GetAgentGroupRoles(RequestingAgentID, AgentID, GroupID); ; }); } diff --git a/OpenSim/Addons/OfflineIM/OpenSim.Addons.OfflineIM.csproj b/OpenSim/Addons/OfflineIM/OpenSim.Addons.OfflineIM.csproj index 1bb689306ea..37d8c9c8837 100644 --- a/OpenSim/Addons/OfflineIM/OpenSim.Addons.OfflineIM.csproj +++ b/OpenSim/Addons/OfflineIM/OpenSim.Addons.OfflineIM.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Addons.OfflineIM http://opensimulator.org OpenSim.Addons.OfflineIM @@ -9,6 +9,7 @@ + diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs index e0022754f72..b4de67b4cd1 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs @@ -93,29 +93,37 @@ public List GetMessages(UUID principalID) if (ret == null) return ims; - if (!ret.ContainsKey("RESULT")) + if (!ret.TryGetValue("RESULT", out object resultobj)) return ims; - string result = ret["RESULT"].ToString(); - if (result == "NULL" || result.ToLower() == "false") + if(resultobj is string result) { - string reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error"; - m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: GetMessages for {0} failed: {1}", principalID, reason); + if (result == "NULL" || result.Equals("false", StringComparison.InvariantCultureIgnoreCase)) + { + if (ret.TryGetValue("REASON", out object rso)) + m_log.Debug($"[OfflineIM.V2.RemoteConnector]: GetMessages for {principalID} failed: {rso}"); + else + m_log.Debug($"[OfflineIM.V2.RemoteConnector]: GetMessages for {principalID} failed: Unknown error"); return ims; } - - foreach (object v in ((Dictionary)ret["RESULT"]).Values) + } + else if(resultobj is Dictionary resultdic) { - GridInstantMessage m = OfflineIMDataUtils.GridInstantMessage((Dictionary)v); + foreach (object v in resultdic.Values) + { + if (v is Dictionary vdic) + { + GridInstantMessage m = OfflineIMDataUtils.GridInstantMessage(vdic); ims.Add(m); } + } + } return ims; } public bool StoreMessage(GridInstantMessage im, out string reason) { - reason = string.Empty; Dictionary sendData = OfflineIMDataUtils.GridInstantMessage(im); Dictionary ret = MakeRequest("STORE", sendData); @@ -126,16 +134,20 @@ public bool StoreMessage(GridInstantMessage im, out string reason) return false; } - if (ret.ContainsKey("RESULT") == true) + if (ret.TryGetValue("RESULT", out object o)) { - string result = ret["RESULT"].ToString(); - if (result == "NULL" || result.ToLower() == "false") + string result = o.ToString(); + if (result == "NULL" || result.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { - reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error"; + if(ret.TryGetValue("REASON", out object ro)) + reason = ro.ToString(); + else + reason = "Unknown error"; return false; } } + reason = string.Empty; return true; } @@ -163,8 +175,7 @@ private Dictionary MakeRequest(string method, Dictionary replyData = ServerUtils.ParseXmlResponse( - reply); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); return replyData; } diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs index bf578a0b9ed..57c724a171b 100644 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs +++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs @@ -28,10 +28,7 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; -using System.Runtime.Serialization; using System.Text; -using System.Timers; using System.Xml; using System.Xml.Serialization; using log4net; @@ -40,21 +37,59 @@ using OpenMetaverse; using OpenSim.Data; using OpenSim.Framework; +using OpenSim.Services.Base; using OpenSim.Services.Interfaces; namespace OpenSim.OfflineIM { - public class OfflineIMService : OfflineIMServiceBase, IOfflineIMService + public class OfflineIMService : ServiceBase, IOfflineIMService { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private const int MAX_IM = 25; - + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IOfflineIMData m_Database = null; + private int m_MaxOfflineIMs = 25; private XmlSerializer m_serializer; private static bool m_Initialized = false; - public OfflineIMService(IConfigSource config) - : base(config) + public OfflineIMService(IConfigSource config) : base(config) { + string dllName = string.Empty; + string connString = string.Empty; + string realm = "im_offline"; + + // + // Try reading the [DatabaseService] section, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig is not null) + { + if (dllName.Length == 0) + dllName = dbConfig.GetString("StorageProvider", string.Empty); + if (connString.Length == 0) + connString = dbConfig.GetString("ConnectionString", string.Empty); + } + + // + // [Messaging] section overrides [DatabaseService], if it exists + // + IConfig imConfig = config.Configs["Messaging"]; + if (imConfig is not null) + { + dllName = imConfig.GetString("StorageProvider", dllName); + connString = imConfig.GetString("ConnectionString", connString); + realm = imConfig.GetString("Realm", realm); + m_MaxOfflineIMs = imConfig.GetInt("MaxOfflineIMs", m_MaxOfflineIMs); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (string.IsNullOrEmpty(dllName)) + throw new Exception("No StorageProvider configured"); + + m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); + if (m_Database is null) + throw new Exception("Could not find a storage interface in the given module " + dllName); + m_serializer = new XmlSerializer(typeof(GridInstantMessage)); if (!m_Initialized) { @@ -68,8 +103,7 @@ public List GetMessages(UUID principalID) List ims = new List(); OfflineIMData[] messages = m_Database.Get("PrincipalID", principalID.ToString()); - - if (messages == null || (messages != null && messages.Length == 0)) + if (messages is null || messages.Length == 0) return ims; foreach (OfflineIMData m in messages) @@ -94,7 +128,7 @@ public bool StoreMessage(GridInstantMessage im, out string reason) // Check limits UUID principalID = new UUID(im.toAgentID); long count = m_Database.GetCount("PrincipalID", principalID.ToString()); - if (count >= MAX_IM) + if (count >= m_MaxOfflineIMs) { reason = "Number of offline IMs has maxed out"; return false; diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMServiceBase.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMServiceBase.cs deleted file mode 100644 index d68ae3d7c52..00000000000 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMServiceBase.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Data; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Base; - -namespace OpenSim.OfflineIM -{ - public class OfflineIMServiceBase : ServiceBase - { - protected IOfflineIMData m_Database = null; - - public OfflineIMServiceBase(IConfigSource config) - : base(config) - { - string dllName = String.Empty; - string connString = String.Empty; - string realm = "im_offline"; - - // - // Try reading the [DatabaseService] section, if it exists - // - IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) - { - if (dllName.Length == 0) - dllName = dbConfig.GetString("StorageProvider", String.Empty); - if (connString.Length == 0) - connString = dbConfig.GetString("ConnectionString", String.Empty); - } - - // - // [Messaging] section overrides [DatabaseService], if it exists - // - IConfig imConfig = config.Configs["Messaging"]; - if (imConfig != null) - { - dllName = imConfig.GetString("StorageProvider", dllName); - connString = imConfig.GetString("ConnectionString", connString); - realm = imConfig.GetString("Realm", realm); - } - - // - // We tried, but this doesn't exist. We can't proceed. - // - if (string.IsNullOrEmpty(dllName)) - throw new Exception("No StorageProvider configured"); - - m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); - if (m_Database == null) - throw new Exception("Could not find a storage interface in the given module " + dllName); - } - } -} diff --git a/OpenSim/ApplicationPlugins/LoadRegions/OpenSim.ApplicationPlugins.LoadRegions.csproj b/OpenSim/ApplicationPlugins/LoadRegions/OpenSim.ApplicationPlugins.LoadRegions.csproj index 2093ded0dcd..91189d3a665 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/OpenSim.ApplicationPlugins.LoadRegions.csproj +++ b/OpenSim/ApplicationPlugins/LoadRegions/OpenSim.ApplicationPlugins.LoadRegions.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.ApplicationPlugins.LoadRegions http://opensimulator.org OpenSim diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/OpenSim.ApplicationPlugins.RegionModulesController.csproj b/OpenSim/ApplicationPlugins/RegionModulesController/OpenSim.ApplicationPlugins.RegionModulesController.csproj index 8533e15a33f..cdfcf1d0866 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/OpenSim.ApplicationPlugins.RegionModulesController.csproj +++ b/OpenSim/ApplicationPlugins/RegionModulesController/OpenSim.ApplicationPlugins.RegionModulesController.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.ApplicationPlugins.RegionModulesController http://opensimulator.org OpenSim @@ -10,6 +10,7 @@ + {1}\n",i,m_texture.FaceTextures[i].TextureID); + sb.AppendLine($"Texture: {i} --> {m_texture.FaceTextures[i].TextureID}"); foreach (AvatarWearable awear in m_wearables) { for (int i = 0; i < awear.Count; i++) - s += String.Format("Wearable: item={0}, asset={1}\n",awear[i].ItemID,awear[i].AssetID); + sb.AppendLine($"Wearable: item={awear[i].ItemID}, asset={awear[i].AssetID}"); } - s += "Visual Params: "; - // for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) + sb.Append("Visual Params: "); + //for (uint j = 0; j < AvatarAppearance.VISUALPARAM_COUNT; j++) for (uint j = 0; j < m_visualparams.Length; j++) - s += String.Format("{0},",m_visualparams[j]); - s += "\n"; + { + sb.Append(m_visualparams[j]); + sb.Append(','); + } + sb.Append('\n'); - return s; + return sb.ToString(); } // DEBUG OFF @@ -539,16 +542,20 @@ internal void AppendAttachment(AvatarAttachment attach) lock (m_attachments) { - if (!m_attachments.ContainsKey(attach.AttachPoint)) - m_attachments[attach.AttachPoint] = new List(); + ref List atlst = ref CollectionsMarshal.GetValueRefOrAddDefault(m_attachments, attach.AttachPoint, out bool ex); + if(!ex) + { + atlst = new List() { attach }; + return; + } - foreach (AvatarAttachment prev in m_attachments[attach.AttachPoint]) + foreach (AvatarAttachment prev in atlst) { if (prev.ItemID.Equals(attach.ItemID)) return; } - m_attachments[attach.AttachPoint].Add(attach); + atlst.Add(attach); } } @@ -560,8 +567,7 @@ internal void ReplaceAttachment(AvatarAttachment attach) lock (m_attachments) { - m_attachments[attach.AttachPoint] = new List(); - m_attachments[attach.AttachPoint].Add(attach); + m_attachments[attach.AttachPoint] = new List() { attach }; } } @@ -609,10 +615,7 @@ public bool SetAttachment(int attachpoint, UUID item, UUID asset) if (!existingAttachment.AssetID.IsZero() && existingAttachment.AttachPoint == (attachpoint & 0x7F)) { - m_log.DebugFormat( - "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}", - item, attachpoint); - + m_log.Debug($"[AVATAR APPEARANCE]: Ignoring attach of an already attached item {item} at point {attachpoint}"); return false; } else diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs index 6435307b98c..32de787ed7a 100644 --- a/OpenSim/Framework/AvatarWearable.cs +++ b/OpenSim/Framework/AvatarWearable.cs @@ -185,11 +185,8 @@ public void Clear() public void RemoveItem(UUID itemID) { - if (m_items.ContainsKey(itemID)) - { - m_ids.Remove(itemID); - m_items.Remove(itemID); - } + m_ids.Remove(itemID); + m_items.Remove(itemID); } public void RemoveAsset(UUID assetID) @@ -225,9 +222,7 @@ public WearableItem this [int idx] public UUID GetAsset(UUID itemID) { - if (!m_items.ContainsKey(itemID)) - return UUID.Zero; - return m_items[itemID]; + return m_items.TryGetValue(itemID, out UUID id) ? id : UUID.Zero; } public static AvatarWearable[] DefaultWearables diff --git a/OpenSim/Framework/BasicDOSProtector.cs b/OpenSim/Framework/BasicDOSProtector.cs index f1ff18f5cb0..c80bee56220 100644 --- a/OpenSim/Framework/BasicDOSProtector.cs +++ b/OpenSim/Framework/BasicDOSProtector.cs @@ -84,8 +84,7 @@ public BasicDOSProtector(BasicDosProtectorOptions options) } foreach (string str in removes) { - m_log.InfoFormat("[{0}] client: {1} is no longer blocked.", - _options.ReportingName, str); + m_log.Info($"[{_options.ReportingName}] client: {str} is no longer blocked."); } _blockLockSlim.EnterReadLock(); if (_tempBlocked.Count > 0) @@ -104,7 +103,7 @@ public BasicDOSProtector(BasicDosProtectorOptions options) public bool IsBlocked(string key) { bool ret = false; - _blockLockSlim.EnterReadLock(); + _blockLockSlim.EnterReadLock(); ret = _tempBlocked.ContainsKey(key); _blockLockSlim.ExitReadLock(); return ret; @@ -141,11 +140,8 @@ public bool Process(string key, string endpoint) if (_options.MaxConcurrentSessions > 0) { - int sessionscount = 0; - _sessionLockSlim.EnterReadLock(); - if (_sessions.ContainsKey(key)) - sessionscount = _sessions[key]; + _sessions.TryGetValue(key, out int sessionscount); _sessionLockSlim.ExitReadLock(); if (sessionscount > _options.MaxConcurrentSessions) @@ -160,7 +156,7 @@ public bool Process(string key, string endpoint) Util.EnvironmentTickCount() + (int) _options.ForgetTimeSpan.TotalMilliseconds); _forgetTimer.Enabled = true; - m_log.WarnFormat("[{0}]: client: {1} is blocked for {2} milliseconds based on concurrency, X-ForwardedForAllowed status is {3}, endpoint:{4}", _options.ReportingName, clientstring, _options.ForgetTimeSpan.TotalMilliseconds, _options.AllowXForwardedFor, endpoint); + m_log.Warn($"[{_options.ReportingName}]: client: {clientstring} is blocked for {_options.ForgetTimeSpan.TotalMilliseconds}ms based on concurrency, X-ForwardedForAllowed status is {_options.AllowXForwardedFor}, endpoint:{_options.AllowXForwardedFor}"); } else @@ -241,8 +237,7 @@ private bool DeeperInspection(string key, string endpoint) _tempBlocked[clientstring] = Util.EnvironmentTickCount() + (int)_options.ForgetTimeSpan.TotalMilliseconds; _blockLockSlim.ExitWriteLock(); - m_log.WarnFormat("[{0}]: client: {1} is blocked for {2} milliseconds, X-ForwardedForAllowed status is {3}, endpoint:{4}", _options.ReportingName, clientstring, _options.ForgetTimeSpan.TotalMilliseconds, _options.AllowXForwardedFor, endpoint); - + m_log.Warn($"[{_options.ReportingName}]: client: {clientstring} is blocked for {_options.ForgetTimeSpan.TotalMilliseconds}ms, X-ForwardedForAllowed status is {_options.AllowXForwardedFor}, endpoint:{endpoint}"); return false; } //else diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs index 3ca85d7d1a0..a5bf3a6aa05 100644 --- a/OpenSim/Framework/Cache.cs +++ b/OpenSim/Framework/Cache.cs @@ -344,26 +344,20 @@ public TimeSpan DefaultTTL // protected virtual CacheItemBase GetItem(string index) { - CacheItemBase item = null; lock (m_Index) { - if (m_Lookup.ContainsKey(index)) - item = m_Lookup[index]; - - if (item == null) + if(m_Lookup.TryGetValue(index, out CacheItemBase item)) { + item.hits++; + item.lastUsed = DateTime.UtcNow; Expire(true); - return null; + return item; } - item.hits++; - item.lastUsed = DateTime.UtcNow; - Expire(true); + return null; } - - return item; } // Get an item from cache. Do not try to fetch from source if not @@ -566,12 +560,9 @@ public void Invalidate(string uuid) { lock (m_Index) { - if (!m_Lookup.ContainsKey(uuid)) - return; - - CacheItemBase item = m_Lookup[uuid]; + if (m_Lookup.TryGetValue(uuid, out CacheItemBase item)) + m_Index.Remove(item); m_Lookup.Remove(uuid); - m_Index.Remove(item); } } diff --git a/OpenSim/Framework/CapsUtil.cs b/OpenSim/Framework/CapsUtil.cs index 020f6e26bdc..86e07cd26e7 100644 --- a/OpenSim/Framework/CapsUtil.cs +++ b/OpenSim/Framework/CapsUtil.cs @@ -26,6 +26,7 @@ */ using OpenMetaverse; +using System.Runtime.CompilerServices; namespace OpenSim.Framework { @@ -39,24 +40,20 @@ public class CapsUtil /// /// /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string GetCapsSeedPath(string capsObjectPath) { - return "CAPS/" + capsObjectPath + "0000/"; + return $"CAPS/{capsObjectPath}0000/"; } /// /// Get a random CAPS object path component that will be used as the identifying part of all future CAPS requests /// /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string GetRandomCapsObjectPath() { - UUID caps = UUID.Random(); - string capsPath = caps.ToString(); - // I'm commenting this, rather than delete, to keep as historical record. - // The caps seed is now a full UUID string that gets added four more digits - // for producing certain CAPs URLs in OpenSim - //capsPath = capsPath.Remove(capsPath.Length - 4, 4); - return capsPath; + return UUID.Random().ToString(); } } } diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 3d811ce284d..13b52727b4a 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -125,8 +125,8 @@ public OSDMap Pack(EntityTransferContext ctx) OSDMap g = (OSDMap)GodData; // Set legacy value // TODO: remove after 0.9 is superseded - if (g.ContainsKey("ViewerUiIsGod")) - args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0; + if (g.TryGetValue("ViewerUiIsGod", out OSD vuiig)) + args["god_level"] = vuiig.AsBoolean() ? 200 : 0; } if ((Throttles != null) && (Throttles.Length > 0)) @@ -150,72 +150,69 @@ public OSDMap Pack(EntityTransferContext ctx) public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) { - if (args.ContainsKey("region_handle")) - UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); + OSD osdtmp; + if (args.TryGetValue("region_handle", out osdtmp) && osdtmp != null) + _ = UInt64.TryParse(osdtmp.AsString(), out RegionHandle); - if (args["circuit_code"] != null) - UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); + if (args.TryGetValue("circuit_code", out osdtmp) && osdtmp != null) + _ = UInt32.TryParse(osdtmp.AsString(), out CircuitCode); - if (args["agent_uuid"] != null) - AgentID = args["agent_uuid"].AsUUID(); + if (args.TryGetValue("agent_uuid", out osdtmp) && osdtmp != null) + AgentID = osdtmp.AsUUID(); - if (args["session_uuid"] != null) - SessionID = args["session_uuid"].AsUUID(); + if (args.TryGetValue("session_uuid", out osdtmp) && osdtmp != null) + SessionID = osdtmp.AsUUID(); - if (args["position"] != null) - Vector3.TryParse(args["position"].AsString(), out Position); + if (args.TryGetValue("position", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out Position); - if (args["velocity"] != null) - Vector3.TryParse(args["velocity"].AsString(), out Velocity); + if (args.TryGetValue("velocity", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out Velocity); - if (args["center"] != null) - Vector3.TryParse(args["center"].AsString(), out Center); + if (args.TryGetValue("center", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out Center); - if (args["size"] != null) - Vector3.TryParse(args["size"].AsString(), out Size); + if (args.TryGetValue("size", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out Size); - if (args["at_axis"] != null) - Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); + if (args.TryGetValue("at_axis", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out AtAxis); - if (args["left_axis"] != null) - Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis); + if (args.TryGetValue("left_axis", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out LeftAxis); - if (args["up_axis"] != null) - Vector3.TryParse(args["up_axis"].AsString(), out UpAxis); + if (args.TryGetValue("up_axis", out osdtmp) && osdtmp != null) + _ = Vector3.TryParse(osdtmp.AsString(), out UpAxis); - if (args["changed_grid"] != null) - ChangedGrid = args["changed_grid"].AsBoolean(); + if (args.TryGetValue("changed_grid", out osdtmp) && osdtmp != null) + ChangedGrid = osdtmp.AsBoolean(); - //if (args["god_level"] != null) - // Int32.TryParse(args["god_level"].AsString(), out GodLevel); - if (args.ContainsKey("god_data") && args["god_data"] != null) - GodData = args["god_data"]; + if (args.TryGetValue("god_data", out osdtmp)) + GodData = osdtmp; - if (args["far"] != null) - Far = (float)(args["far"].AsReal()); + if (args.TryGetValue("far", out osdtmp) && osdtmp != null) + Far = (float)(osdtmp.AsReal()); - if (args["throttles"] != null) - Throttles = args["throttles"].AsBinary(); + if (args.TryGetValue("throttles", out osdtmp) && osdtmp != null) + Throttles = osdtmp.AsBinary(); - if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) && - (args["children_seeds"].Type == OSDType.Array)) + if (args.TryGetValue("children_seeds", out osdtmp) && osdtmp is OSDArray childrenSeeds) { - OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); ChildrenCapSeeds = new Dictionary(); foreach (OSD o in childrenSeeds) { - if (o.Type == OSDType.Map) + if (o is OSDMap pair) { - ulong handle = 0; - string seed = ""; - OSDMap pair = (OSDMap)o; - if (pair["handle"] != null) - if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) - continue; - if (pair["seed"] != null) - seed = pair["seed"].AsString(); - if (!ChildrenCapSeeds.ContainsKey(handle)) - ChildrenCapSeeds.Add(handle, seed); + if (pair.TryGetValue("handle", out osdtmp) && osdtmp != null) + { + if (UInt64.TryParse(osdtmp.AsString(), out ulong handle)) + { + if (pair.TryGetValue("seed", out osdtmp)) + ChildrenCapSeeds.TryAdd(handle, osdtmp.AsString()); + else + ChildrenCapSeeds.TryAdd(handle, string.Empty); + } + } } } } @@ -274,12 +271,13 @@ public OSDMap PackUpdateMessage() public void UnpackUpdateMessage(OSDMap args) { - if (args["group_id"] != null) - GroupID = args["group_id"].AsUUID(); - if (args["group_powers"] != null) - UInt64.TryParse((string)args["group_powers"].AsString(), out GroupPowers); - if (args["accept_notices"] != null) - AcceptNotices = args["accept_notices"].AsBoolean(); + OSD osdtmp; + if (args.TryGetValue("group_id", out osdtmp) && osdtmp != null) + GroupID = osdtmp.AsUUID(); + if (args.TryGetValue("group_powers", out osdtmp) && osdtmp != null) + UInt64.TryParse(osdtmp.AsString(), out GroupPowers); + if (args.TryGetValue("accept_notices", out osdtmp) && osdtmp != null) + AcceptNotices = osdtmp.AsBoolean(); } } @@ -317,14 +315,15 @@ public OSDMap PackUpdateMessage() public void UnpackUpdateMessage(OSDMap args) { - if (args["object"] != null) - ObjectID = args["object"].AsUUID(); - if (args["item"] != null) - ItemID = args["item"].AsUUID(); - if (args["ignore"] != null) - IgnoreControls = (uint)args["ignore"].AsInteger(); - if (args["event"] != null) - EventControls = (uint)args["event"].AsInteger(); + OSD osdtmp; + if (args.TryGetValue("object", out osdtmp) && osdtmp != null) + ObjectID = osdtmp.AsUUID(); + if (args.TryGetValue("item", out osdtmp) && osdtmp != null) + ItemID = osdtmp.AsUUID(); + if (args.TryGetValue("ignore", out osdtmp) && osdtmp != null) + IgnoreControls = (uint)osdtmp.AsInteger(); + if (args.TryGetValue("event", out osdtmp) && osdtmp != null) + EventControls = (uint)osdtmp.AsInteger(); } } @@ -389,16 +388,10 @@ public UUID AgentID // Appearance public AvatarAppearance Appearance; -// DEBUG ON - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); -// DEBUG OFF - // Scripted public ControllerData[] Controllers; - public string CallbackURI; // to remove + public string CallbackURI; public string NewCallbackURI; // These two must have the same Count @@ -407,6 +400,10 @@ public UUID AgentID public Dictionary MovementAnimationOverRides = new Dictionary(); + public List CachedFriendsOnline; + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public void SetLookAt(Vector3 value) { if (value.X == 0 && value.Y == 0) @@ -424,7 +421,7 @@ public void SetLookAt(Vector3 value) public virtual OSDMap Pack(EntityTransferContext ctx) { -// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); + //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); @@ -463,7 +460,7 @@ public virtual OSDMap Pack(EntityTransferContext ctx) args["god_data"] = GodData; OSDMap g = (OSDMap)GodData; if (g.ContainsKey("ViewerUiIsGod")) - args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; + args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0; } args["always_run"] = OSD.FromBoolean(AlwaysRun); args["prey_agent"] = OSD.FromUUID(PreyAgent); @@ -575,6 +572,14 @@ public virtual OSDMap Pack(EntityTransferContext ctx) args["parent_part"] = OSD.FromUUID(ParentPart); args["sit_offset"] = OSD.FromString(SitOffset.ToString()); + if(CachedFriendsOnline != null && CachedFriendsOnline.Count > 0) + { + OSDArray cfonl = new OSDArray(CachedFriendsOnline.Count); + foreach(UUID id in CachedFriendsOnline) + cfonl.Add(id); + args["cfonline"] = cfonl; + } + return args; } @@ -588,7 +593,7 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); OSD tmp; if (args.TryGetValue("region_id", out tmp) && tmp != null) - UUID.TryParse(tmp.AsString(), out RegionID); + _ = UUID.TryParse(tmp.AsString(), out RegionID); if (args.TryGetValue("circuit_code", out tmp) && tmp != null) UInt32.TryParse(tmp.AsString(), out CircuitCode); @@ -600,22 +605,22 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) SessionID = tmp.AsUUID(); if (args.TryGetValue("position", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out Position); + _ = Vector3.TryParse(tmp.AsString(), out Position); if (args.TryGetValue("velocity", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out Velocity); + _ = Vector3.TryParse(tmp.AsString(), out Velocity); if (args.TryGetValue("center", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out Center); + _ = Vector3.TryParse(tmp.AsString(), out Center); if (args.TryGetValue("size", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out Size); + _ = Vector3.TryParse(tmp.AsString(), out Size); if (args.TryGetValue("at_axis", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out AtAxis); + _ = Vector3.TryParse(tmp.AsString(), out AtAxis); if (args.TryGetValue("left_axis", out tmp) && tmp != null) - Vector3.TryParse(tmp.AsString(), out LeftAxis); + _ = Vector3.TryParse(tmp.AsString(), out LeftAxis); if (args.TryGetValue("up_axis", out tmp) && tmp != null) Vector3.TryParse(tmp.AsString(), out UpAxis); @@ -624,7 +629,7 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) SenderWantsToWaitForRoot = tmp.AsBoolean(); if (args.TryGetValue("far", out tmp) && tmp != null) - Far = (float)(tmp.AsReal()); + Far = (float)tmp.AsReal(); if (args.TryGetValue("aspect", out tmp) && tmp != null) Aspect = (float)tmp.AsReal(); @@ -633,19 +638,19 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) Throttles = tmp.AsBinary(); if (args.TryGetValue("locomotion_state", out tmp) && tmp != null) - UInt32.TryParse(tmp.AsString(), out LocomotionState); + _ = UInt32.TryParse(tmp.AsString(), out LocomotionState); if (args.TryGetValue("head_rotation", out tmp) && tmp != null) - Quaternion.TryParse(tmp.AsString(), out HeadRotation); + _ = Quaternion.TryParse(tmp.AsString(), out HeadRotation); if (args.TryGetValue("body_rotation", out tmp) && tmp != null) - Quaternion.TryParse(tmp.AsString(), out BodyRotation); + _ = Quaternion.TryParse(tmp.AsString(), out BodyRotation); if (args.TryGetValue("control_flags", out tmp) && tmp != null) - UInt32.TryParse(tmp.AsString(), out ControlFlags); + _ = UInt32.TryParse(tmp.AsString(), out ControlFlags); if (args.TryGetValue("energy_level", out tmp) && tmp != null) - EnergyLevel = (float)(tmp.AsReal()); + EnergyLevel = (float)tmp.AsReal(); if (args.TryGetValue("god_data", out tmp) && tmp != null) GodData = tmp; @@ -657,7 +662,7 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) PreyAgent = tmp.AsUUID(); if (args.TryGetValue("agent_access", out tmp) && tmp != null) - Byte.TryParse(tmp.AsString(), out AgentAccess); + _ = Byte.TryParse(tmp.AsString(), out AgentAccess); if (args.TryGetValue("agent_cof", out tmp) && tmp != null) agentCOF = tmp.AsUUID(); @@ -680,43 +685,36 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) if(args.TryGetValue("active_group_title", out tmp) && tmp != null) ActiveGroupTitle = tmp.AsString(); - if (args.TryGetValue("children_seeds", out tmp) && tmp is OSDArray) + if (args.TryGetValue("children_seeds", out tmp) && tmp is OSDArray childrenSeeds) { - OSDArray childrenSeeds = (OSDArray)tmp; ChildrenCapSeeds = new Dictionary(); foreach (OSD o in childrenSeeds) { - if (o is OSDMap) + if (o is OSDMap pair) { - ulong handle = 0; - string seed = ""; - OSDMap pair = (OSDMap)o; - if (pair.TryGetValue("handle", out tmp)) - if (!UInt64.TryParse(tmp.AsString(), out handle)) - continue; - if (pair.TryGetValue("seed", out tmp)) - seed = tmp.AsString(); - if (!ChildrenCapSeeds.ContainsKey(handle)) - ChildrenCapSeeds.Add(handle, seed); + if (pair.TryGetValue("handle", out tmp) && tmp != null && UInt64.TryParse(tmp.AsString(), out ulong handle)) + { + if (pair.TryGetValue("seed", out tmp)) + ChildrenCapSeeds.TryAdd(handle, tmp.AsString()); + else + ChildrenCapSeeds.Add(handle, string.Empty); + } } } } - if (args.TryGetValue("animations", out tmp) && tmp is OSDArray) + if (args.TryGetValue("animations", out tmp) && tmp is OSDArray anims) { - OSDArray anims = (OSDArray)tmp; Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { - if (o is OSDMap) - { - Anims[i++] = new Animation((OSDMap)o); - } + if (o is OSDMap om) + Anims[i++] = new Animation(om); } } - if (args.TryGetValue("default_animation", out tmp) && tmp is OSDMap) + if (args.TryGetValue("default_animation", out tmp) && tmp is OSDMap tmpm) { try { @@ -728,7 +726,7 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) } } - if (args.TryGetValue("animation_state", out tmp) && tmp is OSDMap) + if (args.TryGetValue("animation_state", out tmp) && tmp is OSDMap tmpms) { try { @@ -742,19 +740,19 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) MovementAnimationOverRides.Clear(); - if (args.TryGetValue("movementAO", out tmp) && tmp is OSDArray) + if (args.TryGetValue("movementAO", out tmp) && tmp is OSDArray AOs) { - OSDArray AOs = (OSDArray)tmp; - int count = AOs.Count; - - for (int i = 0; i < count; i++) + for (int i = 0; i < AOs.Count; i++) { - OSDMap ao = (OSDMap)AOs[i]; - if (ao["state"] != null && ao["uuid"] != null) + if(AOs[i] is OSDMap ao) { - string state = ao["state"].AsString(); - UUID id = ao["uuid"].AsUUID(); - MovementAnimationOverRides[state] = id; + if (ao.TryGetValue("state", out OSD st) && st != null && + ao.TryGetValue("uuid", out OSD uid) && uid != null) + { + string state = st.AsString(); + UUID id = uid.AsUUID(); + MovementAnimationOverRides[state] = id; + } } } } @@ -773,10 +771,10 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) // packed_appearence should contain all appearance information - if (args.TryGetValue("packed_appearance", out tmp) && tmp is OSDMap) + if (args.TryGetValue("packed_appearance", out tmp) && tmp is OSDMap pam) { //m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance"); - Appearance = new AvatarAppearance((OSDMap)tmp); + Appearance = new AvatarAppearance(pam); } else { @@ -798,10 +796,8 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) if (args.TryGetValue("visual_params", out tmp) && tmp != null) Appearance.SetVisualParams(tmp.AsBinary()); - if (args.TryGetValue("wearables", out tmp) && tmp is OSDArray) + if (args.TryGetValue("wearables", out tmp) && tmp is OSDArray wears) { - OSDArray wears = (OSDArray)tmp; - for (int i = 0; i < wears.Count / 2; i++) { AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); @@ -809,34 +805,32 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) } } - if (args.TryGetValue("attachments", out tmp) && tmp is OSDArray) + if (args.TryGetValue("attachments", out tmp) && tmp is OSDArray attachs) { - OSDArray attachs = (OSDArray)tmp; foreach (OSD o in attachs) { - if (o is OSDMap) + if (o is OSDMap att) { // We know all of these must end up as attachments so we // append rather than replace to ensure multiple attachments // per point continues to work // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); - Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); + Appearance.AppendAttachment(new AvatarAttachment(att)); } } } // end of code to remove } - if (args.TryGetValue("controllers", out tmp) && tmp is OSDArray) + if (args.TryGetValue("controllers", out tmp) && tmp is OSDArray controls) { - OSDArray controls = (OSDArray)tmp; Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { - if (o is OSDMap) + if (o is OSDMap cntr) { - Controllers[i++] = new ControllerData((OSDMap)o); + Controllers[i++] = new ControllerData(cntr); } } } @@ -848,16 +842,14 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) NewCallbackURI = tmp.AsString(); // Attachment objects - if (args.TryGetValue("attach_objects", out tmp) && tmp is OSDArray) + if (args.TryGetValue("attach_objects", out tmp) && tmp is OSDArray attObjs) { - OSDArray attObjs = (OSDArray)tmp; AttachmentObjects = new List(); AttachmentObjectStates = new List(); foreach (OSD o in attObjs) { - if (o is OSDMap) + if (o is OSDMap info) { - OSDMap info = (OSDMap)o; ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); so.ExtraFromXmlString(info["extra"].AsString()); so.HasGroupChanged = info["modified"].AsBoolean(); @@ -871,6 +863,13 @@ public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx) ParentPart = tmp.AsUUID(); if (args.TryGetValue("sit_offset", out tmp) && tmp != null) Vector3.TryParse(tmp.AsString(), out SitOffset); + + if (args.TryGetValue("cfonline", out tmp) && tmp is OSDArray cfonl) + { + CachedFriendsOnline = new List(cfonl.Count); + foreach(OSD o in cfonl) + CachedFriendsOnline.Add(o.AsUUID()); + } } public AgentData() diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index c444fcffc54..05829b869d8 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs @@ -40,15 +40,15 @@ public class ClientManager { /// A dictionary mapping from /// to references - private readonly Dictionary m_dictbyUUID = new Dictionary(); + private readonly Dictionary m_dictbyUUID = new(); /// A dictionary mapping from /// to references - private readonly Dictionary m_dictbyIPe= new Dictionary(); + private readonly Dictionary m_dictbyIPe= new(); /// snapshot collection of current /// references private IClientAPI[] m_array = null; /// Synchronization object for writing to the collections - private readonly object m_syncRoot = new object(); + private readonly object m_syncRoot = new(); /// Number of clients in the collection public int Count @@ -96,10 +96,8 @@ public bool Remove(UUID key) { lock (m_syncRoot) { - IClientAPI value; - if (m_dictbyUUID.TryGetValue(key, out value)) + if (m_dictbyUUID.Remove(key, out IClientAPI value)) { - m_dictbyUUID.Remove(key); m_dictbyIPe.Remove(value.RemoteEndPoint); m_array = null; return true; @@ -193,7 +191,7 @@ public void ForEach(Action action) IClientAPI[] localArray; lock (m_syncRoot) { - if (m_array == null) + if (m_array is null) { if (m_dictbyUUID.Count == 0) return; diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 3da2e386ceb..80d59931675 100755 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -670,7 +670,7 @@ public static string[] Parse(string text) { if (index % 2 == 0) { - string[] words = unquoted[index].Split(new char[] {' '}); + string[] words = unquoted[index].Split(); bool option = false; foreach (string w in words) diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs index f4d36874501..2bce8b45c37 100755 --- a/OpenSim/Framework/Console/ConsolePluginCommand.cs +++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs @@ -62,7 +62,7 @@ public class ConsolePluginCommand /// the text displayed in "help showme new commands" public ConsolePluginCommand(string command, ConsoleCommand dlg, string help) { - m_cmdText = command.Split(new char[] { ' ' }); + m_cmdText = command.Split(); m_commandDelegate = dlg; m_helpText = help; } diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 58efe84390f..d5c55f1c4c5 100755 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -324,10 +324,8 @@ public override void LockOutput() m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition); int count = m_commandLine.Length + prompt.Length; - char[] spaces = new char[count]; - for(int i = 0; i < spaces.Length; i++) - spaces[i] = ' '; - System.Console.Write(spaces); + if(count > 0) + System.Console.Write(new string(' ', count)); m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition); } @@ -444,11 +442,12 @@ public override void Output(string format, params object[] components) m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition); int count = m_commandLine.Length + prompt.Length - text.Length; - WriteLocalText(text, level); - for (int i = 0; i < count; ++i) - System.Console.Write(" "); - System.Console.WriteLine(); + if(count > 0) + System.Console.WriteLine(new string(' ', count)); + else + System.Console.WriteLine(); + m_cursorYPosition = System.Console.CursorTop; Show(); } @@ -496,8 +495,8 @@ public override string ReadLine(string p, bool isCommand, bool e) { Show(); //Reduce collisions with internal read terminal information like cursor position on linux - //while(System.Console.KeyAvailable == false) - // Thread.Sleep(100); + while(System.Console.KeyAvailable == false) + Thread.Sleep(100); ConsoleKeyInfo key = System.Console.ReadKey(true); diff --git a/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj index 5cfae0bb51d..83329488826 100644 --- a/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj +++ b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Framework.Console http://opensimulator.org ServerConsole diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 276b7fa5df5..b92af1fcdf8 100755 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -322,7 +322,7 @@ public override string ReadLine(string p, bool isCommand, bool e) for (i=0 ; i < cmd.Length ; i++) { - if (cmd[i].Contains(" ")) + if (cmd[i].Contains(' ')) cmd[i] = "\"" + cmd[i] + "\""; } return String.Empty; @@ -721,12 +721,10 @@ protected Hashtable NoEvents(UUID RequestID, UUID id) Hashtable result = new Hashtable(); XmlDocument xmldoc = new XmlDocument(); - XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, - "", ""); + XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); xmldoc.AppendChild(xmlnode); - XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession", - ""); + XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession", ""); xmldoc.AppendChild(rootElement); diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index f97b69acc05..5dbd0bd9ace 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -34,6 +34,9 @@ public class Constants public const int MaxAgentAttachments = 38; public const int MaxAgentGroups = 60; + public const int MaxEstateAccessIds = 500; + public const int MaxEstateManagers = 20; + // 'RegionSize' is the legacy region size. // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not // be the legacy region size. @@ -56,6 +59,8 @@ public class Constants public const float MinWaterHeight = 0; public const float MaxWaterHeight = 8000f; + public const int MaxTextureResolution = 1024; + public static readonly string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; //plywood public static readonly UUID DefaultTextureID = new UUID(DefaultTexture); @@ -68,6 +73,9 @@ public class Constants public static readonly UUID EmptyNotecardID = new UUID(EmptyNotecard); public static readonly byte[] EmptyNotecardData = osUTF8.GetASCIIBytes("Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length 0\n}\n\0"); + public static readonly string DefaultMaterial = "968cbad0-4dad-d64e-71b5-72bf13ad051a"; + public static readonly UUID DefaultMaterialID = new UUID(DefaultMaterial); + public static readonly string m_MrOpenSimIDString = "11111111-1111-0000-0000-000100bba000"; public static readonly UUID m_MrOpenSimID = new UUID(m_MrOpenSimIDString); public static readonly DateTime m_MrOpenSimBorn = new DateTime(2007, 1, 1, 0, 0, 0, DateTimeKind.Utc); @@ -85,10 +93,10 @@ public enum EstateAccessCodex : uint public enum EstateAccessLimits : int { - AllowedAccess = 500, + AllowedAccess = MaxEstateAccessIds, AllowedGroups = 63, EstateBans = 500, - EstateManagers = 10 + EstateManagers = MaxEstateManagers } [Flags]public enum TeleportFlags : uint diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 0e9a46e2f3e..ef73dd059b4 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -27,7 +27,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Reflection; using OpenMetaverse; @@ -249,7 +248,7 @@ public bool AllowEnvironmentOverride // All those lists... // - private List l_EstateManagers = new List(); + private List l_EstateManagers = new(); public UUID[] EstateManagers { @@ -257,7 +256,7 @@ public UUID[] EstateManagers set { l_EstateManagers = new List(value); } } - private List l_EstateBans = new List(); + private List l_EstateBans = new(); public EstateBan[] EstateBans { @@ -265,14 +264,14 @@ public EstateBan[] EstateBans set { l_EstateBans = new List(value); } } - private List l_EstateAccess = new List(); + private List l_EstateAccess = new(); public UUID[] EstateAccess { get { return l_EstateAccess.ToArray(); } set { l_EstateAccess = new List(value); } } - private List l_EstateGroups = new List(); + private List l_EstateGroups = new(); public UUID[] EstateGroups { get { return l_EstateGroups.ToArray(); } @@ -288,8 +287,7 @@ public EstateSettings() public void Save() { - if (OnSave != null) - OnSave(this); + OnSave?.Invoke(this); } public int EstateUsersCount() @@ -301,15 +299,14 @@ public void AddEstateUser(UUID avatarID) { if (avatarID.IsZero()) return; - if (!l_EstateAccess.Contains(avatarID) && - (l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess)) + if ((l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess) && + !l_EstateAccess.Contains(avatarID)) l_EstateAccess.Add(avatarID); } public void RemoveEstateUser(UUID avatarID) { - if (l_EstateAccess.Contains(avatarID)) - l_EstateAccess.Remove(avatarID); + _ = l_EstateAccess.Remove(avatarID); } public int EstateGroupsCount() @@ -321,15 +318,14 @@ public void AddEstateGroup(UUID avatarID) { if (avatarID.IsZero()) return; - if (!l_EstateGroups.Contains(avatarID) && - (l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups)) + if ((l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups) && + !l_EstateGroups.Contains(avatarID)) l_EstateGroups.Add(avatarID); } public void RemoveEstateGroup(UUID avatarID) { - if (l_EstateGroups.Contains(avatarID)) - l_EstateGroups.Remove(avatarID); + _ = l_EstateGroups.Remove(avatarID); } public int EstateManagersCount() @@ -341,31 +337,24 @@ public void AddEstateManager(UUID avatarID) { if (avatarID.IsZero()) return; - if (!l_EstateManagers.Contains(avatarID) && - (l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers)) + if ((l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers) && + !l_EstateManagers.Contains(avatarID)) l_EstateManagers.Add(avatarID); } public void RemoveEstateManager(UUID avatarID) { - if (l_EstateManagers.Contains(avatarID)) - l_EstateManagers.Remove(avatarID); + _ = l_EstateManagers.Remove(avatarID); } public bool IsEstateManagerOrOwner(UUID avatarID) { - if (IsEstateOwner(avatarID)) - return true; - - return l_EstateManagers.Contains(avatarID); + return m_EstateOwner.Equals(avatarID) || l_EstateManagers.Contains(avatarID); } public bool IsEstateOwner(UUID avatarID) { - if (avatarID == m_EstateOwner) - return true; - - return false; + return m_EstateOwner.Equals(avatarID); } public bool IsBanned(UUID avatarID) @@ -373,8 +362,10 @@ public bool IsBanned(UUID avatarID) if (!IsEstateManagerOrOwner(avatarID)) { foreach (EstateBan ban in l_EstateBans) - if (ban.BannedUserID == avatarID) + { + if (ban.BannedUserID.Equals(avatarID)) return true; + } } return false; } @@ -384,8 +375,10 @@ public bool IsBanned(UUID avatarID, int userFlags) if (!IsEstateManagerOrOwner(avatarID)) { foreach (EstateBan ban in l_EstateBans) - if (ban.BannedUserID == avatarID) - return true; + { + if (ban.BannedUserID.Equals(avatarID)) + return true; + } if (!HasAccess(avatarID)) { @@ -415,7 +408,7 @@ public int EstateBansCount() public void AddBan(EstateBan ban) { - if (ban == null) + if (ban is null) return; if (!IsBanned(ban.BannedUserID, 32) && (l_EstateBans.Count < (int)Constants.EstateAccessLimits.EstateBans)) //Ignore age-based bans @@ -444,11 +437,11 @@ public bool HasAccess(UUID user) public void SetFromFlags(ulong regionFlags) { - ResetHomeOnTeleport = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport) == (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport); - BlockDwell = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.BlockDwell) == (ulong)OpenMetaverse.RegionFlags.BlockDwell); - AllowLandmark = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowLandmark) == (ulong)OpenMetaverse.RegionFlags.AllowLandmark); - AllowParcelChanges = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges) == (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges); - AllowSetHome = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowSetHome) == (ulong)OpenMetaverse.RegionFlags.AllowSetHome); + ResetHomeOnTeleport = (regionFlags & (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport) != 0; + BlockDwell = (regionFlags & (ulong)OpenMetaverse.RegionFlags.BlockDwell) != 0; + AllowLandmark = (regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowLandmark) != 0; + AllowParcelChanges = (regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges) != 0; + AllowSetHome = (regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowSetHome) != 0; } public bool GroupAccess(UUID groupID) @@ -458,7 +451,7 @@ public bool GroupAccess(UUID groupID) public Dictionary ToMap() { - Dictionary map = new Dictionary(); + Dictionary map = new(); PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo p in properties) { @@ -467,7 +460,7 @@ public Dictionary ToMap() continue; object value = p.GetValue(this, null); - if (value != null) + if (value is not null) { if (p.PropertyType.IsArray) // of UUIDs { @@ -488,7 +481,7 @@ public Dictionary ToMap() // EstateBans are special if (EstateBans.Length > 0) { - Dictionary bans = new Dictionary(); + Dictionary bans = new(); int i = 0; foreach (EstateBan ban in EstateBans) bans["ban" + i++] = ban.ToMap(); @@ -527,7 +520,7 @@ public EstateSettings(Dictionary map) foreach (KeyValuePair kvp in map) { PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance); - if (p == null) + if (p is null) continue; // EstateBans is a complex type, let's treat it as special @@ -536,7 +529,7 @@ public EstateSettings(Dictionary map) if (p.PropertyType.IsArray) { - string[] elements = ((string)map[p.Name]).Split(new char[] { ',' }); + string[] elements = ((string)map[p.Name]).Split(Util.SplitCommaArray); UUID[] uuids = new UUID[elements.Length]; int i = 0; foreach (string e in elements) @@ -548,31 +541,31 @@ public EstateSettings(Dictionary map) object value = p.GetValue(this, null); if (value is String) p.SetValue(this, map[p.Name], null); - else if (value is UInt32) - p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); - else if (value is Boolean) - p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); + else if (value is uint) + p.SetValue(this, uint.Parse((string)map[p.Name]), null); + else if (value is bool) + p.SetValue(this, bool.Parse((string)map[p.Name]), null); else if (value is UUID) p.SetValue(this, UUID.Parse((string)map[p.Name]), null); } } // EstateBans are special - if (map.ContainsKey("EstateBans")) + if (map.TryGetValue("EstateBans", out object oEstateBans)) { - if(map["EstateBans"] is string) + if(oEstateBans is string bansmap) { // JSON encoded bans map - Dictionary bdata = new Dictionary(); + Dictionary bdata = new(); try { // bypass libovm, we dont need even more useless high level maps // this should only be called once.. but no problem, i hope // (other uses may need more..) LitJson.JsonMapper.RegisterImporter((input) => new UUID(input)); - bdata = LitJson.JsonMapper.ToObject>((string)map["EstateBans"]); + bdata = LitJson.JsonMapper.ToObject>(bansmap); } - // catch(Exception e) + //catch(Exception e) catch { return; diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs index 7f3980bdf1e..5f1246a9768 100644 --- a/OpenSim/Framework/GridInstantMessage.cs +++ b/OpenSim/Framework/GridInstantMessage.cs @@ -50,7 +50,7 @@ public class GridInstantMessage public GridInstantMessage() { - binaryBucket = Array.Empty(); ; + binaryBucket = Array.Empty(); } public GridInstantMessage(GridInstantMessage im, bool addTimestamp) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a3008a53c23..965e68eacc8 100755 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -127,21 +127,21 @@ public delegate void RequestObjectPropertiesFamily( public delegate void ObjectDrop(uint localID, IClientAPI remoteClient); public delegate void UpdatePrimFlags( - uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient); + uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, in ExtraPhysicsData PhysData, IClientAPI remoteClient); public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient); - public delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient); + public delegate void UpdateVector(uint localID, in Vector3 pos, IClientAPI remoteClient); public delegate void ClientChangeObject(uint localID, object data ,IClientAPI remoteClient); - public delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient); + public delegate void UpdatePrimRotation(uint localID, in Quaternion rot, IClientAPI remoteClient); - public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient); + public delegate void UpdatePrimSingleRotation(uint localID, in Quaternion rot, IClientAPI remoteClient); - public delegate void UpdatePrimSingleRotationPosition(uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient); + public delegate void UpdatePrimSingleRotationPosition(uint localID, in Quaternion rot, in Vector3 pos, IClientAPI remoteClient); - public delegate void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient); + public delegate void UpdatePrimGroupRotation(uint localID, in Vector3 pos, in Quaternion rot, IClientAPI remoteClient); public delegate void ObjectDuplicate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, UUID GroupID); @@ -607,7 +607,7 @@ public enum PrimUpdateFlags : uint { None = 0, AttachmentPoint = 1 << 0, - Material = 1 << 1, + MaterialOvr = 1 << 1, ClickAction = 1 << 2, Scale = 1 << 3, ParentID = 1 << 4, @@ -630,11 +630,13 @@ public enum PrimUpdateFlags : uint Sound = 1 << 21, TerseUpdate = Position | Rotation | Velocity | Acceleration | AngularVelocity, - FullUpdate = 0x00ffffff, + FullUpdate = 0x00ffffff & ~MaterialOvr, Animations = 1 << 24, FullUpdatewithAnim = FullUpdate | Animations, + FullUpdatewithMatOvr = FullUpdate | MaterialOvr, + FullUpdatewithAnimMatOvr = FullUpdate | Animations | MaterialOvr, UpdateProbe = 0x10000000, // 1 << 28 SendInTransit = 0x20000000, // 1 << 29 @@ -646,6 +648,9 @@ public interface IClientAPI { Vector3 StartPos { get; set; } float StartFar { get; set; } + float FOV { get; set; } + int viewHeight { get; set; } + int viewWidth { get; set; } UUID AgentId { get; } @@ -757,7 +762,6 @@ public interface IClientAPI event DeRezObject OnDeRezObject; event RezRestoreToWorld OnRezRestoreToWorld; event Action OnRegionHandShakeReply; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly")] event GenericCall1 OnRequestWearables; event Action OnCompleteMovementToRegion; diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs index fb66056fbac..3b262cc1e3f 100644 --- a/OpenSim/Framework/InventoryFolderBase.cs +++ b/OpenSim/Framework/InventoryFolderBase.cs @@ -48,9 +48,7 @@ public class InventoryFolderBase : InventoryNodeBase private short _type; /// - /// This is used to denote the version of the client, needed - /// because of the changes clients have with inventory from - /// time to time (1.19.1 caused us some fits there). + /// This is used to denote the version of folder /// private ushort _version; diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 6e989d71949..cbfa5f771a1 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -46,8 +46,8 @@ public class LandAccessEntry /// public class LandData { - private Vector3 _AABBMax = new Vector3(); - private Vector3 _AABBMin = new Vector3(); + private Vector3 _AABBMax = new(); + private Vector3 _AABBMin = new(); private int _area = 0; private uint _auctionID = 0; //Unemplemented. If set to 0, not being auctioned private UUID _authBuyerID = UUID.Zero; //Unemplemented. Authorized Buyer's UUID @@ -75,15 +75,15 @@ public class LandData private string _mediaURL = String.Empty; private string _musicURL = String.Empty; private UUID _ownerID = UUID.Zero; - private List _parcelAccessList = new List(); + private List _parcelAccessList = new(); private float _passHours = 0; private int _passPrice = 0; private int _salePrice = 0; //Unemeplemented. Parcels price. private int _simwideArea = 0; private int _simwidePrims = 0; private UUID _snapshotID = UUID.Zero; - private Vector3 _userLocation = new Vector3(); - private Vector3 _userLookAt = new Vector3(); + private Vector3 _userLocation = new(); + private Vector3 _userLookAt = new(); private int _otherCleanTime = 0; private string _mediaType = "none/none"; private string _mediaDescription = ""; @@ -763,60 +763,63 @@ public LandData() /// public LandData Copy() { - LandData landData = new LandData(); - - landData._AABBMax = _AABBMax; - landData._AABBMin = _AABBMin; - landData._area = _area; - landData._auctionID = _auctionID; - landData._authBuyerID = _authBuyerID; - landData._category = _category; - landData._claimDate = _claimDate; - landData._claimPrice = _claimPrice; - landData._globalID = _globalID; - landData.m_fakeID = m_fakeID; - landData._groupID = _groupID; - landData._isGroupOwned = _isGroupOwned; - landData._localID = _localID; - landData._landingType = _landingType; - landData._mediaAutoScale = _mediaAutoScale; - landData._mediaID = _mediaID; - landData._mediaURL = _mediaURL; - landData._musicURL = _musicURL; - landData._ownerID = _ownerID; - landData._bitmap = (byte[])_bitmap.Clone(); - landData._description = _description; - landData._flags = _flags; - landData._name = _name; - landData._status = _status; - landData._passHours = _passHours; - landData._passPrice = _passPrice; - landData._salePrice = _salePrice; - landData._snapshotID = _snapshotID; - landData._userLocation = _userLocation; - landData._userLookAt = _userLookAt; - landData._otherCleanTime = _otherCleanTime; - landData._mediaType = _mediaType; - landData._mediaDescription = _mediaDescription; - landData._mediaWidth = _mediaWidth; - landData._mediaHeight = _mediaHeight; - landData._mediaLoop = _mediaLoop; - landData._obscureMusic = _obscureMusic; - landData._obscureMedia = _obscureMedia; - landData._simwideArea = _simwideArea; - landData._simwidePrims = _simwidePrims; - landData.m_dwell = m_dwell; - landData.SeeAVs = SeeAVs; - landData.AnyAVSounds = AnyAVSounds; - landData.GroupAVSounds = GroupAVSounds; + LandData landData = new() + { + _AABBMax = _AABBMax, + _AABBMin = _AABBMin, + _area = _area, + _auctionID = _auctionID, + _authBuyerID = _authBuyerID, + _category = _category, + _claimDate = _claimDate, + _claimPrice = _claimPrice, + _globalID = _globalID, + m_fakeID = m_fakeID, + _groupID = _groupID, + _isGroupOwned = _isGroupOwned, + _localID = _localID, + _landingType = _landingType, + _mediaAutoScale = _mediaAutoScale, + _mediaID = _mediaID, + _mediaURL = _mediaURL, + _musicURL = _musicURL, + _ownerID = _ownerID, + _bitmap = (byte[])_bitmap.Clone(), + _description = _description, + _flags = _flags, + _name = _name, + _status = _status, + _passHours = _passHours, + _passPrice = _passPrice, + _salePrice = _salePrice, + _snapshotID = _snapshotID, + _userLocation = _userLocation, + _userLookAt = _userLookAt, + _otherCleanTime = _otherCleanTime, + _mediaType = _mediaType, + _mediaDescription = _mediaDescription, + _mediaWidth = _mediaWidth, + _mediaHeight = _mediaHeight, + _mediaLoop = _mediaLoop, + _obscureMusic = _obscureMusic, + _obscureMedia = _obscureMedia, + _simwideArea = _simwideArea, + _simwidePrims = _simwidePrims, + m_dwell = m_dwell, + SeeAVs = SeeAVs, + AnyAVSounds = AnyAVSounds, + GroupAVSounds = GroupAVSounds + }; landData._parcelAccessList.Clear(); foreach (LandAccessEntry entry in _parcelAccessList) { - LandAccessEntry newEntry = new LandAccessEntry(); - newEntry.AgentID = entry.AgentID; - newEntry.Flags = entry.Flags; - newEntry.Expires = entry.Expires; + LandAccessEntry newEntry = new() + { + AgentID = entry.AgentID, + Flags = entry.Flags, + Expires = entry.Expires + }; landData._parcelAccessList.Add(newEntry); } diff --git a/OpenSim/Framework/LandUpdateArgs.cs b/OpenSim/Framework/LandUpdateArgs.cs index 6305223f571..7d0acec69ae 100644 --- a/OpenSim/Framework/LandUpdateArgs.cs +++ b/OpenSim/Framework/LandUpdateArgs.cs @@ -54,8 +54,6 @@ public class LandUpdateArgs : EventArgs public int MediaHeight; public int MediaWidth; public bool MediaLoop; - public bool ObscureMusic; - public bool ObscureMedia; public bool SeeAVs; public bool AnyAVSounds; public bool GroupAVSounds; diff --git a/OpenSim/Framework/LogWriter.cs b/OpenSim/Framework/LogWriter.cs index 2e0bf4a354d..5b331c06225 100755 --- a/OpenSim/Framework/LogWriter.cs +++ b/OpenSim/Framework/LogWriter.cs @@ -44,19 +44,19 @@ public class LogWriter : IDisposable { public bool Enabled { get; private set; } - private string m_logDirectory = "."; - private int m_logMaxFileTimeMin = 5; // 5 minutes + private readonly string m_logDirectory = "."; + private readonly int m_logMaxFileTimeMin = 5; // 5 minutes public String LogFileHeader { get; set; } private StreamWriter m_logFile = null; - private TimeSpan m_logFileLife; + private readonly TimeSpan m_logFileLife; private DateTime m_logFileEndTime; - private Object m_logFileWriteLock = new Object(); - private bool m_flushWrite; + private readonly Object m_logFileWriteLock = new Object(); + private readonly bool m_flushWrite; // set externally when debugging. If let 'null', this does not write any error messages. public ILog ErrorLogger = null; - private string LogHeader = "[LOG WRITER]"; + private readonly string LogHeader = "[LOG WRITER]"; /// /// Create a log writer that will not write anything. Good for when not enabled @@ -78,9 +78,8 @@ public LogWriter() /// if one is looking for a crash, this is a good thing to turn on. public LogWriter(string dir, string headr, int maxFileTime, bool flushWrite) { - m_logDirectory = dir == null ? "." : dir; - - LogFileHeader = headr == null ? "log-" : headr; + m_logDirectory = dir ?? "."; + LogFileHeader = headr ?? "log-"; m_logMaxFileTimeMin = maxFileTime; if (m_logMaxFileTimeMin < 1) @@ -100,13 +99,14 @@ public LogWriter(string dir, string headr, int maxFileTime) : this(dir, headr, m public void Dispose() { - this.Close(); + Close(); + GC.SuppressFinalize(this); } public void Close() { Enabled = false; - if (m_logFile != null) + if (m_logFile is not null) { m_logFile.Close(); m_logFile.Dispose(); @@ -116,17 +116,16 @@ public void Close() public void Write(string line, params object[] args) { - if (!Enabled) return; + if (!Enabled) + return; Write(String.Format(line, args)); } public void Flush() { - if (!Enabled) return; - if (m_logFile != null) - { - m_logFile.Flush(); - } + if (!Enabled) + return; + m_logFile?.Flush(); } public void Write(string line) @@ -137,9 +136,9 @@ public void Write(string line) lock (m_logFileWriteLock) { DateTime now = DateTime.UtcNow; - if (m_logFile == null || now > m_logFileEndTime) + if (m_logFile is null || now > m_logFileEndTime) { - if (m_logFile != null) + if (m_logFile is not null) { m_logFile.Close(); m_logFile.Dispose(); @@ -153,12 +152,12 @@ public void Write(string line) + String.Format("{0}{1}.log", LogFileHeader, now.ToString("yyyyMMddHHmmss")); m_logFile = new StreamWriter(File.Open(path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite)); } - if (m_logFile != null) + if (m_logFile is not null) { StringBuilder buff = new StringBuilder(line.Length + 25); buff.Append(now.ToString("yyyyMMddHHmmssfff")); // buff.Append(now.ToString("yyyyMMddHHmmss")); - buff.Append(","); + buff.Append('"'); buff.Append(line); buff.Append("\r\n"); m_logFile.Write(buff.ToString()); @@ -169,10 +168,7 @@ public void Write(string line) } catch (Exception e) { - if (ErrorLogger != null) - { - ErrorLogger.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e); - } + ErrorLogger?.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e); Enabled = false; } return; diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs index e6b2800e643..412c2ae291d 100644 --- a/OpenSim/Framework/MapAndArray.cs +++ b/OpenSim/Framework/MapAndArray.cs @@ -27,6 +27,8 @@ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace OpenSim.Framework { @@ -82,12 +84,10 @@ public bool AddOrReplace(TKey key, TValue value) { lock (m_syncRoot) { - bool containedKey = m_dict.ContainsKey(key); - - m_dict[key] = value; + ref TValue curvalue = ref CollectionsMarshal.GetValueRefOrAddDefault(m_dict, key, out bool existed); + curvalue = value; m_array = null; - - return !containedKey; + return existed; } } @@ -117,9 +117,8 @@ public bool Remove(TKey key) { lock (m_syncRoot) { - bool removed = m_dict.Remove(key); m_array = null; - return removed; + return m_dict.Remove(key); } } @@ -156,7 +155,8 @@ public void Clear() { lock (m_syncRoot) { - m_dict = new Dictionary(); + if(m_dict.Count > 0) + m_dict = new Dictionary(); m_array = null; } } @@ -171,15 +171,21 @@ public TValue[] GetArray() { lock (m_syncRoot) { - if (m_array == null) + if (m_array is null) { if(m_dict.Count == 0) - return new TValue[0]; + return Array.Empty(); m_array = new TValue[m_dict.Count]; m_dict.Values.CopyTo(m_array, 0); } return m_array; } } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Span GetSpan() + { + return new Span(GetArray()); + } } } diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index 0d2c5caf80f..809a705d4ed 100644 --- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs @@ -46,39 +46,36 @@ public virtual string Report(IScene scene = null) public virtual string Report() { StringBuilder sb = new StringBuilder(Environment.NewLine); - sb.Append("MEMORY STATISTICS"); - sb.Append(Environment.NewLine); sb.AppendFormat( - "Heap allocated to OpenSim : {0} MB\n", - Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); - - sb.AppendFormat( - "Heap allocation rate (last/avg): {0}/{1}MB/s\n", + "Heap allocated: {0}MB \t allocation rate (last/avg): {1}/{2}MB/s\n", + Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0), Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3), Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3)); + GCMemoryInfo gcmem = GC.GetGCMemoryInfo(); + sb.AppendFormat( + "GCTotalCommited: {0}MB \t GCTotalAvaiable {1}MB \t GCHMthreshold {2}MB\n", + Math.Round(gcmem.TotalCommittedBytes / 1024.0 / 1024.0), + Math.Round(gcmem.TotalAvailableMemoryBytes / 1024.0 / 1024.0), + Math.Round(gcmem.HighMemoryLoadThresholdBytes / 1024.0 / 1024.0)); + try { using (Process myprocess = Process.GetCurrentProcess()) { sb.AppendFormat( - "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", + "Process memory: Physical {0}MB \t Paged {1}MB\n", Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0), - Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0), - Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0)); + Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0)); sb.AppendFormat( - "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", + "Peak process memory: Physical {0}MB \t Paged {1}MB \t\n", Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0), - Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0), - Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0)); + Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0)); sb.AppendFormat("\nTotal process Threads {0}\n", myprocess.Threads.Count); } } catch { } -// else -// sb.Append("Process reported as Exited \n"); - return sb.ToString(); } diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index 3f71811d36a..f1eb75748e8 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs @@ -257,7 +257,6 @@ private void ProcessRequests(object o) m_log.DebugFormat("[{0}]: Processed job {1}",LoggingName,currentJob.Name); currentJob.Action = null; - currentJob = null; } lock (JobLock) --m_numberThreads; diff --git a/OpenSim/Framework/Monitoring/OpenSim.Framework.Monitoring.csproj b/OpenSim/Framework/Monitoring/OpenSim.Framework.Monitoring.csproj index ce560e9b3a1..c67ba9a67b2 100644 --- a/OpenSim/Framework/Monitoring/OpenSim.Framework.Monitoring.csproj +++ b/OpenSim/Framework/Monitoring/OpenSim.Framework.Monitoring.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Framework.Monitoring http://opensimulator.org OpenSim diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs index a26a6e03660..80a6c9c6af1 100644 --- a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs @@ -35,7 +35,6 @@ using log4net; using Nini.Config; using OpenMetaverse.StructuredData; -using OpenSim.Framework; namespace OpenSim.Framework.Monitoring { @@ -57,9 +56,9 @@ public class ServerStatsCollector public string NetworkInterfaceTypes = "Ethernet"; - readonly int performanceCounterSampleInterval = 500; -// int lastperformanceCounterSampleTime = 0; - + //readonly int performanceCounterSampleInterval = 500; + //int lastperformanceCounterSampleTime = 0; + /* private class PerfCounterControl { public PerformanceCounter perfCounter; @@ -78,6 +77,7 @@ public PerfCounterControl(PerformanceCounter pPc, string pName) } PerfCounterControl processorPercentPerfCounter = null; + */ // IRegionModuleBase.Initialize public void Initialise(IConfigSource source) @@ -138,22 +138,22 @@ private void MakeStat(string pName, string pDesc, string pUnit, string pContaine public void RegisterServerStats() { -// lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); - PerformanceCounter tempPC; - Stat tempStat; - string tempName; + //lastperformanceCounterSampleTime = Util.EnvironmentTickCount(); + //PerformanceCounter tempPC; + //Stat tempStat; + //string tempName; try { - tempName = "CPUPercent"; - tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); - processorPercentPerfCounter = new PerfCounterControl(tempPC); + //tempName = "CPUPercent"; + //tempPC = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + //processorPercentPerfCounter = new PerfCounterControl(tempPC); // A long time bug in mono is that CPU percent is reported as CPU percent idle. Windows reports CPU percent busy. - tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, - StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); }, - StatVerbosity.Info); - StatsManager.RegisterStat(tempStat); - RegisteredStats.Add(tempName, tempStat); + //tempStat = new Stat(tempName, tempName, "", "percent", CategoryServer, ContainerProcessor, + // StatType.Pull, (s) => { GetNextValue(s, processorPercentPerfCounter); }, + // StatVerbosity.Info); + //StatsManager.RegisterStat(tempStat); + //RegisteredStats.Add(tempName, tempStat); MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor, (s) => { s.Value = Math.Round(Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds, 3); }); @@ -300,6 +300,7 @@ public void RegisterServerStats() }); } + /* // Notes on performance counters: // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c @@ -325,6 +326,7 @@ private void GetNextValue(Stat stat, PerfCounterControl perfControl) } } } + */ // Lookup the nic that goes with this stat and set the value by using a fetch action. // Not sure about closure with delegates inside delegates. diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 97c76f922ff..2bc8c4c499c 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -27,10 +27,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; using System.Text; -using log4net; using OpenMetaverse.StructuredData; namespace OpenSim.Framework.Monitoring @@ -315,9 +312,9 @@ public bool ComputeMeasuresOfInterest(out double lastChangeOverTime, out double lock (m_samples) { - // m_log.DebugFormat( - // "[STAT]: Samples for {0} are {1}", - // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); + //m_log.DebugFormat( + // "[STAT]: Samples for {0} are {1}", + // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); foreach (double s in m_samples) { @@ -331,8 +328,7 @@ public bool ComputeMeasuresOfInterest(out double lastChangeOverTime, out double if (lastSample != null && penultimateSample != null) { - lastChangeOverTime - = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); + lastChangeOverTime = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); } int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 0e5626b164e..447303e7dc3 100755 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; @@ -188,6 +189,43 @@ private static void OutputAllStatsToConsole(ICommandConsole con) { foreach (string report in GetAllStatsReports()) con.Output(report); + con.Output(MemoryReport()); + } + + private static string MemoryReport() + { + StringBuilder sb = new StringBuilder(Environment.NewLine); + sb.AppendFormat( + "Heap allocated: {0}MB \t allocation rate (last/avg): {1}/{2}MB/s\n", + Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0), + Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3), + Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3)); + + GCMemoryInfo gcmem = GC.GetGCMemoryInfo(); + sb.AppendFormat( + "GCTotalCommited: {0}MB \t GCTotalAvaiable {1}MB \t GCHMthreshold {2}MB\n", + Math.Round(gcmem.TotalCommittedBytes / 1024.0 / 1024.0), + Math.Round(gcmem.TotalAvailableMemoryBytes / 1024.0 / 1024.0), + Math.Round(gcmem.HighMemoryLoadThresholdBytes / 1024.0 / 1024.0)); + + try + { + using (Process myprocess = Process.GetCurrentProcess()) + { + sb.AppendFormat( + "Process memory: Physical {0}MB \t Paged {1}MB\n", + Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0), + Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0)); + sb.AppendFormat( + "Peak process memory: Physical {0}MB \t Paged {1}MB \t\n", + Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0), + Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0)); + sb.AppendFormat("\nTotal process Threads {0}\n", myprocess.Threads.Count); + } + } + catch + { } + return sb.ToString(); } private static List GetCategoryStatsReports( diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 6ad3cdda892..cb0e5993e54 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -197,8 +197,8 @@ public static void Stop() // m_log.DebugFormat( // "[WATCHDOG]: Stop: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); - if(t.IsAlive) - t.Abort(); + //if(t.IsAlive) + // t.Abort(); } m_threads.Clear(); } @@ -269,18 +269,13 @@ public static bool AbortThread(int threadID) { lock (m_threads) { - if (m_threads.ContainsKey(threadID)) + if(RemoveThread(threadID)) { - ThreadWatchdogInfo twi = m_threads[threadID]; - twi.Thread.Abort(); - RemoveThread(threadID); - + //ThreadWatchdogInfo twi = m_threads[threadID]; + //twi.Thread.Abort(); return true; } - else - { - return false; - } + return false; } } @@ -325,11 +320,8 @@ public static ThreadWatchdogInfo GetCurrentThreadInfo() { lock (m_threads) { - if (m_threads.ContainsKey(Thread.CurrentThread.ManagedThreadId)) - return m_threads[Thread.CurrentThread.ManagedThreadId]; + return m_threads.TryGetValue(Thread.CurrentThread.ManagedThreadId, out ThreadWatchdogInfo twi) ? twi : null; } - - return null; } /// diff --git a/OpenSim/Framework/MultipartForm.cs b/OpenSim/Framework/MultipartForm.cs index 7a13e8b21cb..35cf82adb30 100644 --- a/OpenSim/Framework/MultipartForm.cs +++ b/OpenSim/Framework/MultipartForm.cs @@ -129,11 +129,10 @@ public static HttpWebResponse Post(HttpWebRequest request, List postPar private static string Boundary() { - Random rnd = new Random(); string formDataBoundary = String.Empty; while (formDataBoundary.Length < 15) - formDataBoundary = formDataBoundary + rnd.Next(); + formDataBoundary = formDataBoundary + Random.Shared.Next(); formDataBoundary = formDataBoundary.Substring(0, 15); formDataBoundary = "-----------------------------" + formDataBoundary; diff --git a/OpenSim/Framework/ObjectJobEngine.cs b/OpenSim/Framework/ObjectJobEngine.cs index 11027c9b341..19e59d7147e 100644 --- a/OpenSim/Framework/ObjectJobEngine.cs +++ b/OpenSim/Framework/ObjectJobEngine.cs @@ -124,7 +124,7 @@ public void Cancel() return; try { - while(m_jobQueue.TryTake(out object dummy)); + while(m_jobQueue.TryTake(out _)); m_cancelSource.Cancel(); } catch { } diff --git a/OpenSim/Framework/OpenSim.Framework.csproj b/OpenSim/Framework/OpenSim.Framework.csproj index 89550fb395d..d528fdf09fc 100644 --- a/OpenSim/Framework/OpenSim.Framework.csproj +++ b/OpenSim/Framework/OpenSim.Framework.csproj @@ -1,6 +1,6 @@  - net48 + net8.0 OpenSim.Framework http://opensimulator.org OpenSim.Framework @@ -28,9 +28,6 @@ ..\..\bin\OpenMetaverseTypes.dll False - - False - False @@ -190,6 +187,7 @@ + @@ -208,4 +206,4 @@ VersionInfo.tt - \ No newline at end of file + diff --git a/OpenSim/Framework/OutboundUrlFilter.cs b/OpenSim/Framework/OutboundUrlFilter.cs index 63ae3614485..2e3cc2ca157 100644 --- a/OpenSim/Framework/OutboundUrlFilter.cs +++ b/OpenSim/Framework/OutboundUrlFilter.cs @@ -33,6 +33,8 @@ using log4net; using LukeSkywalker.IPNetwork; using Nini.Config; +using IPNetwork = LukeSkywalker.IPNetwork.IPNetwork; + namespace OpenSim.Framework { diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs index 884f4dd35e0..044b9de3e76 100644 --- a/OpenSim/Framework/PluginLoader.cs +++ b/OpenSim/Framework/PluginLoader.cs @@ -159,17 +159,13 @@ public void Load() { log.Info("[PLUGINS]: Loading extension point " + ext); - if (constraints.ContainsKey(ext)) + if (constraints.TryGetValue(ext , out IPluginConstraint cons)) { - IPluginConstraint cons = constraints[ext]; if (cons.Apply(ext)) log.Error("[PLUGINS]: " + ext + " failed constraint: " + cons.Message); } - IPluginFilter filter = null; - - if (filters.ContainsKey(ext)) - filter = filters[ext]; + filters.TryGetValue(ext, out IPluginFilter filter); List loadedPlugins = new List(); foreach (PluginExtensionNode node in AddinManager.GetExtensionNodes(ext)) diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 4199288315c..fb9c416ec03 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -149,17 +149,41 @@ public class PrimitiveBaseShape [XmlIgnore] private bool _projectionEntry; [XmlIgnore] private bool _meshFlagsEntry; - //extra parameters extramesh/flag [XmlIgnore] public Primitive.ReflectionProbe ReflectionProbe = null; - //extra parameters extramesh/flag [XmlIgnore] public Primitive.RenderMaterials RenderMaterials = null; - public bool MeshFlagEntry { - get { return _meshFlagsEntry;} + get { return _meshFlagsEntry; } + } + + public bool AnimeshEnabled + { + get + { + return(_meshFlagsEntry && + (_meshFlags & 0x01) != 0 && + (_sculptType & 0x07) == (int)OpenMetaverse.SculptType.Mesh); + } + set + { + if((_sculptType & 0x07) != (int)OpenMetaverse.SculptType.Mesh) + { + _meshFlagsEntry = false; + _meshFlags = 0; + return; + } + + if (value) + { + _meshFlagsEntry = true; + _meshFlags |= 1; + } + else + _meshFlags &= 0xfe; + } } public byte ProfileCurve @@ -177,11 +201,11 @@ public byte ProfileCurve "[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.", hollowShapeByte); - this._hollowShape = HollowShape.Same; + _hollowShape = HollowShape.Same; } else { - this._hollowShape = (HollowShape)hollowShapeByte; + _hollowShape = (HollowShape)hollowShapeByte; } // Handle profile shape component @@ -193,11 +217,11 @@ public byte ProfileCurve "[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.", profileShapeByte); - this._profileShape = ProfileShape.Square; + _profileShape = ProfileShape.Square; } else { - this._profileShape = (ProfileShape)profileShapeByte; + _profileShape = (ProfileShape)profileShapeByte; } } } @@ -221,7 +245,7 @@ public PrimitiveBaseShape() /// public PrimitiveBaseShape(Primitive prim) { -// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); + //m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); PCode = (byte)prim.PrimData.PCode; @@ -267,7 +291,7 @@ public Primitive.TextureEntry Textures { get { -// m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); + //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } catch { } @@ -305,55 +329,56 @@ public static PrimitiveBaseShape Default public static PrimitiveBaseShape Create() { - PrimitiveBaseShape shape = new PrimitiveBaseShape(); - return shape; + return new PrimitiveBaseShape(); } public static PrimitiveBaseShape CreateBox() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Straight; - shape._profileShape = ProfileShape.Square; - shape._pathScaleX = 100; - shape._pathScaleY = 100; + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Straight, + _profileShape = ProfileShape.Square, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateSphere() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Curve1; - shape._profileShape = ProfileShape.HalfCircle; - shape._pathScaleX = 100; - shape._pathScaleY = 100; + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Curve1, + _profileShape = ProfileShape.HalfCircle, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateCylinder() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Curve1; - shape._profileShape = ProfileShape.Square; - - shape._pathScaleX = 100; - shape._pathScaleY = 100; - + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Curve1, + _profileShape = ProfileShape.Square, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID) { - PrimitiveBaseShape shape = new PrimitiveBaseShape(); - - shape._pathScaleX = 100; - shape._pathScaleY = 100; + PrimitiveBaseShape shape = new() + { + _pathScaleX = 100, + _pathScaleY = 100 + }; - if(numberOfFaces <= 0) // oops ? + if (numberOfFaces <= 0) // oops ? numberOfFaces = 1; switch(numberOfFaces) @@ -489,329 +514,217 @@ public byte[] ExtraParams } } - public ushort PathBegin { - get { - return _pathBegin; - } - set { - _pathBegin = value; - } + public ushort PathBegin + { + get { return _pathBegin; } + set { _pathBegin = value; } } - public byte PathCurve { - get { - return _pathCurve; - } - set { - _pathCurve = value; - } + public byte PathCurve + { + get { return _pathCurve; } + set { _pathCurve = value; } } - public ushort PathEnd { - get { - return _pathEnd; - } - set { - _pathEnd = value; - } + public ushort PathEnd + { + get { return _pathEnd; } + set { _pathEnd = value; } } - public sbyte PathRadiusOffset { - get { - return _pathRadiusOffset; - } - set { - _pathRadiusOffset = value; - } + public sbyte PathRadiusOffset + { + get { return _pathRadiusOffset; } + set { _pathRadiusOffset = value; } } - public byte PathRevolutions { - get { - return _pathRevolutions; - } - set { - _pathRevolutions = value; - } + public byte PathRevolutions + { + get { return _pathRevolutions; } + set { _pathRevolutions = value; } } - public byte PathScaleX { - get { - return _pathScaleX; - } - set { - _pathScaleX = value; - } + public byte PathScaleX + { + get { return _pathScaleX; } + set { _pathScaleX = value; } } - public byte PathScaleY { - get { - return _pathScaleY; - } - set { - _pathScaleY = value; - } + public byte PathScaleY + { + get { return _pathScaleY; } + set { _pathScaleY = value; } } - public byte PathShearX { - get { - return _pathShearX; - } - set { - _pathShearX = value; - } + public byte PathShearX + { + get { return _pathShearX; } + set { _pathShearX = value; } } - public byte PathShearY { - get { - return _pathShearY; - } - set { - _pathShearY = value; - } + public byte PathShearY + { + get { return _pathShearY; } + set { _pathShearY = value; } } - public sbyte PathSkew { - get { - return _pathSkew; - } - set { - _pathSkew = value; - } + public sbyte PathSkew + { + get { return _pathSkew; } + set { _pathSkew = value; } } - public sbyte PathTaperX { - get { - return _pathTaperX; - } - set { - _pathTaperX = value; - } + public sbyte PathTaperX + { + get { return _pathTaperX; } + set { _pathTaperX = value; } } - public sbyte PathTaperY { - get { - return _pathTaperY; - } - set { - _pathTaperY = value; - } + public sbyte PathTaperY + { + get { return _pathTaperY; } + set { _pathTaperY = value; } } - public sbyte PathTwist { - get { - return _pathTwist; - } - set { - _pathTwist = value; - } + public sbyte PathTwist + { + get { return _pathTwist; } + set { _pathTwist = value; } } - public sbyte PathTwistBegin { - get { - return _pathTwistBegin; - } - set { - _pathTwistBegin = value; - } + public sbyte PathTwistBegin + { + get { return _pathTwistBegin; } + set { _pathTwistBegin = value; } } - public byte PCode { - get { - return _pCode; - } - set { - _pCode = value; - } + public byte PCode + { + get { return _pCode; } + set { _pCode = value; } } - public ushort ProfileBegin { - get { - return _profileBegin; - } - set { - _profileBegin = value; - } + public ushort ProfileBegin + { + get { return _profileBegin; } + set { _profileBegin = value; } } - public ushort ProfileEnd { - get { - return _profileEnd; - } - set { - _profileEnd = value; - } + public ushort ProfileEnd + { + get { return _profileEnd; } + set { _profileEnd = value; } } - public ushort ProfileHollow { - get { - return _profileHollow; - } - set { - _profileHollow = value; - } + public ushort ProfileHollow + { + get { return _profileHollow; } + set { _profileHollow = value; } } - public Vector3 Scale { - get { - return _scale; - } - set { - _scale = value; - } + public Vector3 Scale + { + get { return _scale; } + set { _scale = value; } } - public byte State { - get { - return _state; - } - set { - _state = value; - } + public byte State + { + get { return _state; } + set { _state = value; } } - public byte LastAttachPoint { - get { - return _lastattach; - } - set { - _lastattach = value; - } + public byte LastAttachPoint + { + get { return _lastattach; } + set { _lastattach = value; } } - public ProfileShape ProfileShape { - get { - return _profileShape; - } - set { - _profileShape = value; - } + public ProfileShape ProfileShape + { + get { return _profileShape; } + set { _profileShape = value; } } - public HollowShape HollowShape { - get { - return _hollowShape; - } - set { - _hollowShape = value; - } + public HollowShape HollowShape + { + get { return _hollowShape; } + set { _hollowShape = value; } } - public UUID SculptTexture { - get { - return _sculptTexture; - } - set { - _sculptTexture = value; - } + public UUID SculptTexture + { + get { return _sculptTexture; } + set { _sculptTexture = value; } } public byte SculptType { - get - { - return _sculptType; - } - set - { - _sculptType = value; - } + get { return _sculptType; } + set { _sculptType = value; } } // This is only used at runtime. For sculpties this holds the texture data, and for meshes // the mesh data. public byte[] SculptData { - get - { - return _sculptData; - } - set - { -// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Setting SculptData to data with length {0}", value.Length); - _sculptData = value; - } + get { return _sculptData; } + set { _sculptData = value; } } public int FlexiSoftness { - get - { - return _flexiSoftness; - } - set - { - _flexiSoftness = value; - } + get { return _flexiSoftness; } + set { _flexiSoftness = value; } } - public float FlexiTension { - get { - return _flexiTension; - } - set { - _flexiTension = value; - } + public float FlexiTension + { + get { return _flexiTension; } + set { _flexiTension = value; } } - public float FlexiDrag { - get { - return _flexiDrag; - } - set { - _flexiDrag = value; - } + public float FlexiDrag + { + get { return _flexiDrag; } + set { _flexiDrag = value; } } - public float FlexiGravity { - get { - return _flexiGravity; - } - set { - _flexiGravity = value; - } + public float FlexiGravity + { + get { return _flexiGravity; } + set { _flexiGravity = value; } } - public float FlexiWind { - get { - return _flexiWind; - } - set { - _flexiWind = value; - } + public float FlexiWind + { + get { return _flexiWind; } + set { _flexiWind = value; } } - public float FlexiForceX { - get { - return _flexiForceX; - } - set { - _flexiForceX = value; - } + public float FlexiForceX + { + get { return _flexiForceX; } + set { _flexiForceX = value; } } - public float FlexiForceY { - get { - return _flexiForceY; - } - set { - _flexiForceY = value; - } + public float FlexiForceY + { + get { return _flexiForceY; } + set { _flexiForceY = value; } } - public float FlexiForceZ { - get { - return _flexiForceZ; - } - set { - _flexiForceZ = value; - } + public float FlexiForceZ + { + get { return _flexiForceZ; } + set { _flexiForceZ = value; } } - public float LightColorR { - get { - return _lightColorR; - } - set { + public float LightColorR + { + get { return _lightColorR; } + set + { if (value < 0) _lightColorR = 0; else if (value > 1.0f) @@ -821,11 +734,11 @@ public float LightColorR { } } - public float LightColorG { - get { - return _lightColorG; - } - set { + public float LightColorG + { + get { return _lightColorG; } + set + { if (value < 0) _lightColorG = 0; else if (value > 1.0f) @@ -835,11 +748,11 @@ public float LightColorG { } } - public float LightColorB { - get { - return _lightColorB; - } - set { + public float LightColorB + { + get { return _lightColorB; } + set + { if (value < 0) _lightColorB = 0; else if (value > 1.0f) @@ -849,11 +762,11 @@ public float LightColorB { } } - public float LightColorA { - get { - return _lightColorA; - } - set { + public float LightColorA + { + get { return _lightColorA; } + set + { if (value < 0) _lightColorA = 0; else if (value > 1.0f) @@ -863,113 +776,77 @@ public float LightColorA { } } - public float LightRadius { - get { - return _lightRadius; - } - set { - _lightRadius = value; - } + public float LightRadius + { + get { return _lightRadius; } + set { _lightRadius = value; } } - public float LightCutoff { - get { - return _lightCutoff; - } - set { - _lightCutoff = value; - } + public float LightCutoff + { + get { return _lightCutoff; } + set { _lightCutoff = value; } } - public float LightFalloff { - get { - return _lightFalloff; - } - set { - _lightFalloff = value; - } + public float LightFalloff + { + get { return _lightFalloff; } + set { _lightFalloff = value; } } - public float LightIntensity { - get { - return _lightIntensity; - } - set { - _lightIntensity = value; - } + public float LightIntensity + { + get { return _lightIntensity; } + set { _lightIntensity = value; } } // only means we do have flexi data - public bool FlexiEntry { - get { - return _flexiEntry; - } - set { - _flexiEntry = value; - } + public bool FlexiEntry + { + get { return _flexiEntry; } + set { _flexiEntry = value; } } - public bool LightEntry { - get { - return _lightEntry; - } - set { - _lightEntry = value; - } + public bool LightEntry + { + get { return _lightEntry; } + set { _lightEntry = value; } } - public bool SculptEntry { - get { - return _sculptEntry; - } - set { - _sculptEntry = value; - } + public bool SculptEntry + { + get { return _sculptEntry; } + set { _sculptEntry = value; } } - public bool ProjectionEntry { - get { - return _projectionEntry; - } - set { - _projectionEntry = value; - } + public bool ProjectionEntry + { + get { return _projectionEntry; } + set { _projectionEntry = value; } } - public UUID ProjectionTextureUUID { - get { - return _projectionTextureID; - } - set { - _projectionTextureID = value; - } + public UUID ProjectionTextureUUID + { + get { return _projectionTextureID; } + set { _projectionTextureID = value; } } - public float ProjectionFOV { - get { - return _projectionFOV; - } - set { - _projectionFOV = value; - } + public float ProjectionFOV + { + get { return _projectionFOV; } + set { _projectionFOV = value; } } - public float ProjectionFocus { - get { - return _projectionFocus; - } - set { - _projectionFocus = value; - } + public float ProjectionFocus + { + get { return _projectionFocus; } + set { _projectionFocus = value; } } - public float ProjectionAmbiance { - get { - return _projectionAmb; - } - set { - _projectionAmb = value; - } + public float ProjectionAmbiance + { + get { return _projectionAmb; } + set { _projectionAmb = value; } } public ulong GetMeshKey(Vector3 size, float lod) @@ -981,38 +858,35 @@ public ulong GetMeshKey(Vector3 size, float lod, bool convex) { ulong hash = 5381; - hash = djb2(hash, this.PathCurve); - hash = djb2(hash, (byte)((byte)this.HollowShape | (byte)this.ProfileShape)); - hash = djb2(hash, this.PathBegin); - hash = djb2(hash, this.PathEnd); - hash = djb2(hash, this.PathScaleX); - hash = djb2(hash, this.PathScaleY); - hash = djb2(hash, this.PathShearX); - hash = djb2(hash, this.PathShearY); - hash = djb2(hash, (byte)this.PathTwist); - hash = djb2(hash, (byte)this.PathTwistBegin); - hash = djb2(hash, (byte)this.PathRadiusOffset); - hash = djb2(hash, (byte)this.PathTaperX); - hash = djb2(hash, (byte)this.PathTaperY); - hash = djb2(hash, this.PathRevolutions); - hash = djb2(hash, (byte)this.PathSkew); - hash = djb2(hash, this.ProfileBegin); - hash = djb2(hash, this.ProfileEnd); - hash = djb2(hash, this.ProfileHollow); + hash = djb2(hash, PathCurve); + hash = djb2(hash, (byte)((byte)HollowShape | (byte)ProfileShape)); + hash = djb2(hash, PathBegin); + hash = djb2(hash, PathEnd); + hash = djb2(hash, PathScaleX); + hash = djb2(hash, PathScaleY); + hash = djb2(hash, PathShearX); + hash = djb2(hash, PathShearY); + hash = djb2(hash, (byte)PathTwist); + hash = djb2(hash, (byte)PathTwistBegin); + hash = djb2(hash, (byte)PathRadiusOffset); + hash = djb2(hash, (byte)PathTaperX); + hash = djb2(hash, (byte)PathTaperY); + hash = djb2(hash, PathRevolutions); + hash = djb2(hash, (byte)PathSkew); + hash = djb2(hash, ProfileBegin); + hash = djb2(hash, ProfileEnd); + hash = djb2(hash, ProfileHollow); // TODO: Separate scale out from the primitive shape data (after // scaling is supported at the physics engine level) hash = djb2(hash, size.X); hash = djb2(hash, size.Y); hash = djb2(hash, size.Z); - - // Include LOD in hash, accounting for endianness + hash = djb2(hash, lod); - byte[] lodBytes = new byte[4]; - // include sculpt UUID - if (this.SculptEntry) + if (SculptEntry) { byte[] scaleBytes = this.SculptTexture.GetBytes(); for (int i = 0; i < scaleBytes.Length; i++) @@ -1025,20 +899,20 @@ public ulong GetMeshKey(Vector3 size, float lod, bool convex) return hash; } - private ulong djb2(ulong hash, byte c) + private static ulong djb2(ulong hash, byte c) { //return ((hash << 5) + hash) + (ulong)c; return 33 * hash + (ulong)c; } - private ulong djb2(ulong hash, ushort c) + private static ulong djb2(ulong hash, ushort c) { //hash = ((hash << 5) + hash) + (ulong)((byte)c); //return ((hash << 5) + hash) + (ulong)(c >> 8); return 33 * hash + c; } - private ulong djb2(ulong hash, float c) + private static ulong djb2(ulong hash, float c) { //hash = ((hash << 5) + hash) + (ulong)((byte)c); //return ((hash << 5) + hash) + (ulong)(c >> 8); @@ -1097,15 +971,11 @@ public unsafe byte[] ExtraParamsToBytes() TotalBytesLength += 9 + 2 + 4; // data } - if (RenderMaterials != null) + bool hasRenderMaterials = RenderMaterials is not null && RenderMaterials.entries is not null && RenderMaterials.entries.Length > 0; + if (hasRenderMaterials) { ExtraParamsNum++; - if (RenderMaterials.entries == null || RenderMaterials.entries.Length == 0) - TotalBytesLength++; - else - { - TotalBytesLength += 1 + 17 * RenderMaterials.entries.Length + 2 + 4; // data - } + TotalBytesLength += 1 + 17 * RenderMaterials.entries.Length + 2 + 4; // data } byte[] safeReturnBytes = new byte[TotalBytesLength]; @@ -1193,7 +1063,7 @@ public unsafe byte[] ExtraParamsToBytes() *returnBytes++ = ReflectionProbe.Flags; } - if (RenderMaterials != null && RenderMaterials.entries != null && RenderMaterials.entries.Length > 0) + if (hasRenderMaterials) { *returnBytes = MaterialsEP; returnBytes += 2; @@ -1267,6 +1137,7 @@ public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) if (!inUse) { _meshFlagsEntry = false; + _meshFlags = 0; return; } ReadMeshFlagsData(data, 0); @@ -1427,7 +1298,7 @@ public void ReadLightData(byte[] data, int pos) if (data.Length - pos >= 16) { _lightEntry = true; - Color4 lColor = new Color4(data, pos, false); + Color4 lColor = new(data, pos, false); _lightIntensity = lColor.A; _lightColorA = 1f; _lightColorR = lColor.R; @@ -1476,16 +1347,8 @@ public void ReadProjectionData(byte[] data, int pos) [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ReadMeshFlagsData(byte[] data, int pos) { - if (data.Length - pos >= 4) - { - _meshFlagsEntry = true; - _meshFlags = Utils.BytesToUInt(data, pos); - } - else - { - _meshFlagsEntry = true; - _meshFlags = 0; - } + _meshFlagsEntry = true; + _meshFlags = data.Length - pos >= 4 ? Utils.BytesToUInt(data, pos) : 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -1518,10 +1381,8 @@ public int ReadRenderMaterials(byte[] data, int pos, int size) entries[i].id = new UUID(data, pos); pos += 16; } - RenderMaterials = new Primitive.RenderMaterials - { - entries = entries - }; + RenderMaterials ??= new Primitive.RenderMaterials(); + RenderMaterials.entries = entries; } } return size + 4; @@ -1547,84 +1408,172 @@ public Primitive ToOmvPrimitive() /// public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation) { - OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive(); - - prim.Scale = this.Scale; - prim.Position = position; - prim.Rotation = rotation; + OpenMetaverse.Primitive prim = new() + { + Scale = this.Scale, + Position = position, + Rotation = rotation + }; - if (this.SculptEntry) + if (SculptEntry) { - prim.Sculpt = new Primitive.SculptData(); - prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType; - prim.Sculpt.SculptTexture = this.SculptTexture; + prim.Sculpt = new Primitive.SculptData + { + Type = (SculptType)SculptType, + SculptTexture = SculptTexture + }; } - prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f; - prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f; - prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f; - prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f; + prim.PrimData.PathShearX = PathShearX < 128 ? (float)PathShearX * 0.01f : (float)(PathShearX - 256) * 0.01f; + prim.PrimData.PathShearY = PathShearY < 128 ? (float)PathShearY * 0.01f : (float)(PathShearY - 256) * 0.01f; + prim.PrimData.PathBegin = (float)PathBegin * 2.0e-5f; + prim.PrimData.PathEnd = 1.0f - (float)PathEnd * 2.0e-5f; - prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f; - prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f; + prim.PrimData.PathScaleX = (200 - PathScaleX) * 0.01f; + prim.PrimData.PathScaleY = (200 - PathScaleY) * 0.01f; - prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; - prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; + prim.PrimData.PathTaperX = PathTaperX * 0.01f; + prim.PrimData.PathTaperY = PathTaperY * 0.01f; - prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f; - prim.PrimData.PathTwist = this.PathTwist * 0.01f; + prim.PrimData.PathTwistBegin = PathTwistBegin * 0.01f; + prim.PrimData.PathTwist = PathTwist * 0.01f; - prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f; - prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f; - prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f; + prim.PrimData.ProfileBegin = (float)ProfileBegin * 2.0e-5f; + prim.PrimData.ProfileEnd = 1.0f - (float)ProfileEnd * 2.0e-5f; + prim.PrimData.ProfileHollow = (float)ProfileHollow * 2.0e-5f; - prim.PrimData.profileCurve = this.ProfileCurve; - prim.PrimData.ProfileHole = (HoleType)this.HollowShape; + prim.PrimData.profileCurve = ProfileCurve; + prim.PrimData.ProfileHole = (HoleType)HollowShape; - prim.PrimData.PathCurve = (PathCurve)this.PathCurve; - prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset; - prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions; - prim.PrimData.PathSkew = 0.01f * this.PathSkew; + prim.PrimData.PathCurve = (PathCurve)PathCurve; + prim.PrimData.PathRadiusOffset = 0.01f * PathRadiusOffset; + prim.PrimData.PathRevolutions = 1.0f + 0.015f * PathRevolutions; + prim.PrimData.PathSkew = 0.01f * PathSkew; prim.PrimData.PCode = OpenMetaverse.PCode.Prim; prim.PrimData.State = 0; - if (this.FlexiEntry) + if (FlexiEntry) { - prim.Flexible = new Primitive.FlexibleData(); - prim.Flexible.Drag = this.FlexiDrag; - prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ); - prim.Flexible.Gravity = this.FlexiGravity; - prim.Flexible.Softness = this.FlexiSoftness; - prim.Flexible.Tension = this.FlexiTension; - prim.Flexible.Wind = this.FlexiWind; + prim.Flexible = new Primitive.FlexibleData + { + Drag = FlexiDrag, + Force = new Vector3(FlexiForceX, FlexiForceY, FlexiForceZ), + Gravity = FlexiGravity, + Softness = FlexiSoftness, + Tension = FlexiTension, + Wind = FlexiWind + }; } - if (this.LightEntry) + if (LightEntry) { - prim.Light = new Primitive.LightData(); - prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA); - prim.Light.Cutoff = this.LightCutoff; - prim.Light.Falloff = this.LightFalloff; - prim.Light.Intensity = this.LightIntensity; - prim.Light.Radius = this.LightRadius; + prim.Light = new Primitive.LightData + { + Color = new Color4(LightColorR, LightColorG, LightColorB, LightColorA), + Cutoff = LightCutoff, + Falloff = LightFalloff, + Intensity = LightIntensity, + Radius = LightRadius + }; } - prim.Textures = this.Textures; + prim.Textures = Textures; - prim.Properties = new Primitive.ObjectProperties(); - prim.Properties.Name = "Object"; - prim.Properties.Description = ""; - prim.Properties.CreatorID = UUID.Zero; - prim.Properties.GroupID = UUID.Zero; - prim.Properties.OwnerID = UUID.Zero; - prim.Properties.Permissions = new Permissions(); - prim.Properties.SalePrice = 10; - prim.Properties.SaleType = new SaleType(); + prim.Properties = new Primitive.ObjectProperties + { + Name = "Object", + Description = "", + CreatorID = UUID.Zero, + GroupID = UUID.Zero, + OwnerID = UUID.Zero, + Permissions = new Permissions(), + SalePrice = 10, + SaleType = new SaleType() + }; return prim; } + public byte[] RenderMaterialsOvrToRawBin() + { + // byte: number of entries + // repeat: + // byte; entry face index + // byte; low entry override utf8 length + // byte: high entry override utf8 length + // utf8 bytes: override + + if (RenderMaterials is null) + return null; + + if (RenderMaterials.overrides is null || RenderMaterials.overrides.Length == 0) + return new byte[] { 0 }; // store so outdated viewer caches can be updated + + int nentries = 0; + for (int i = 0; i < RenderMaterials.overrides.Length; i++) + { + if (!string.IsNullOrEmpty(RenderMaterials.overrides[i].data)) + nentries++; + } + if(nentries == 0) + return new byte[] { 0 }; + + osUTF8 sb = OSUTF8Cached.Acquire(); + sb.Append((byte)nentries); + for (int i = 0; i < RenderMaterials.overrides.Length; i++) + { + if (string.IsNullOrEmpty(RenderMaterials.overrides[i].data)) + continue; + sb.Append(RenderMaterials.overrides[i].te_index); + int len = RenderMaterials.overrides[i].data.Length; + sb.Append((byte)(len & 0xff)); + sb.Append((byte)((len >> 8) & 0xff)); + sb.Append(RenderMaterials.overrides[i].data); + } + return OSUTF8Cached.GetArrayAndRelease(sb); + } + + public void RenderMaterialsOvrFromRawBin(byte[] data) + { + if (RenderMaterials is not null && RenderMaterials.overrides is not null) + RenderMaterials.overrides = null; + + if (data is null || data.Length < 1) + return; + int nentries = data[0]; + if (nentries > 128) + return; + if (nentries == 0) // for outdated viewer caches + { + RenderMaterials ??= new Primitive.RenderMaterials(); + return; + } + + int indx = 1; + Primitive.RenderMaterials.RenderMaterialOverrideEntry[] overrides = new Primitive.RenderMaterials.RenderMaterialOverrideEntry[nentries]; + try + { + for(int i = 0; i < overrides.Length; i++) + { + overrides[i].te_index = data[indx++]; + int ovrlen = data[indx++]; + ovrlen += data[indx++] << 8; + overrides[i].data = Utils.BytesToString(data,indx, ovrlen); + if(overrides[i].data.StartsWith("{\"asset")) // ignore old test data + return; + indx += ovrlen; + } + } + catch + { + return; + } + + RenderMaterials ??= new Primitive.RenderMaterials(); + RenderMaterials.overrides = overrides; + } + /// /// Encapsulates a list of media entries. /// @@ -1647,15 +1596,15 @@ public string ToXml() { lock (this) { - using (StringWriter sw = new StringWriter()) + using (StringWriter sw = new()) { - using (XmlTextWriter xtw = new XmlTextWriter(sw)) + using (XmlTextWriter xtw = new(sw)) { xtw.WriteStartElement("OSMedia"); xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); xtw.WriteAttributeString("version", "0.1"); - OSDArray meArray = new OSDArray(); + OSDArray meArray = new(); foreach (MediaEntry me in this) { OSD osd = (null == me ? new OSD() : me.GetOSD()); @@ -1684,7 +1633,7 @@ public void WriteXml(XmlWriter writer) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static MediaList FromXml(string rawXml) { - MediaList ml = new MediaList(); + MediaList ml = new(); ml.ReadXml(rawXml); if(ml.Count == 0) return null; @@ -1695,9 +1644,9 @@ public void ReadXml(string rawXml) { try { - using (StringReader sr = new StringReader(rawXml)) + using (StringReader sr = new(rawXml)) { - using (XmlTextReader xtr = new XmlTextReader(sr)) + using (XmlTextReader xtr = new(sr)) { xtr.DtdProcessing = DtdProcessing.Ignore; xtr.MoveToContent(); @@ -1710,10 +1659,9 @@ public void ReadXml(string rawXml) xtr.ReadStartElement("OSMedia"); OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); - if(osdp == null || !(osdp is OSDArray)) + if(osdp is not OSDArray osdMeArray) return; - OSDArray osdMeArray = osdp as OSDArray; if(osdMeArray.Count == 0) return; diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 7091f97d6e8..7b51c5ec96f 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -527,7 +527,7 @@ private void ReadNiniConfig(IConfigSource source, string name) config.Set("Location", location); } - string[] locationElements = location.Split(new char[] { ',' }); + string[] locationElements = location.Split(Util.SplitCommaArray); RegionLocX = Convert.ToUInt32(locationElements[0]); RegionLocY = Convert.ToUInt32(locationElements[1]); @@ -743,7 +743,7 @@ private void DoDefaultLandingSanityChecks() if (DefaultLandingPoint.Z < 0f) DefaultLandingPoint.Z = 0f; - if (ValuesCapped == true) + if (ValuesCapped) m_log.WarnFormat("[RegionInfo]: The default landing location for {0} has been capped to {1}", RegionName, DefaultLandingPoint); } @@ -955,12 +955,13 @@ public void UnpackRegionInfoData(OSDMap args) UInt32.TryParse(args["region_yloc"].AsString(), out locy); RegionLocY = locy; } - if (args.ContainsKey("region_size_x")) - RegionSizeX = (uint)args["region_size_x"].AsInteger(); - if (args.ContainsKey("region_size_y")) - RegionSizeY = (uint)args["region_size_y"].AsInteger(); - if (args.ContainsKey("region_size_z")) - RegionSizeZ = (uint)args["region_size_z"].AsInteger(); + OSD osdtmp; + if (args.TryGetValue("region_size_x", out osdtmp)) + RegionSizeX = (uint)osdtmp.AsInteger(); + if (args.TryGetValue("region_size_y", out osdtmp)) + RegionSizeY = (uint)osdtmp.AsInteger(); + if (args.TryGetValue("region_size_z", out osdtmp)) + RegionSizeZ = (uint)osdtmp.AsInteger(); IPAddress ip_addr = null; if (args["internal_ep_address"] != null) diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index ff9ae3c35d8..90814f771db 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -49,15 +49,15 @@ public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point) // Next we need to rotate this vector into the spawn point's // coordinate system rot.W = -rot.W; - offset = offset * rot; + offset *= rot; Vector3 dir = Vector3.Normalize(offset); // Get the bearing (yaw) - Yaw = (float)Math.Atan2(dir.Y, dir.X); + Yaw = MathF.Atan2(dir.Y, dir.X); // Get the elevation (pitch) - Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); + Pitch = -MathF.Atan2(dir.Z, MathF.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); } public Vector3 GetLocation(Vector3 pos, Quaternion rot) @@ -92,10 +92,12 @@ public static SpawnPoint Parse(string str) if (parts.Length != 3) throw new ArgumentException("Invalid string: " + str); - SpawnPoint sp = new SpawnPoint(); - sp.Yaw = float.Parse(parts[0]); - sp.Pitch = float.Parse(parts[1]); - sp.Distance = float.Parse(parts[2]); + SpawnPoint sp = new() + { + Yaw = float.Parse(parts[0]), + Pitch = float.Parse(parts[1]), + Distance = float.Parse(parts[2]) + }; return sp; } } @@ -109,15 +111,14 @@ public class RegionSettings /// /// These appear to be terrain textures that are shipped with the client. /// - public static readonly UUID DEFAULT_TERRAIN_TEXTURE_1 = new UUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); - public static readonly UUID DEFAULT_TERRAIN_TEXTURE_2 = new UUID("abb783e6-3e93-26c0-248a-247666855da3"); - public static readonly UUID DEFAULT_TERRAIN_TEXTURE_3 = new UUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); - public static readonly UUID DEFAULT_TERRAIN_TEXTURE_4 = new UUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); + public static readonly UUID DEFAULT_TERRAIN_TEXTURE_1 = new("b8d3965a-ad78-bf43-699b-bff8eca6c975"); + public static readonly UUID DEFAULT_TERRAIN_TEXTURE_2 = new("abb783e6-3e93-26c0-248a-247666855da3"); + public static readonly UUID DEFAULT_TERRAIN_TEXTURE_3 = new("179cdabd-398a-9b6b-1391-4dc333ba321f"); + public static readonly UUID DEFAULT_TERRAIN_TEXTURE_4 = new("beb169c7-11ea-fff2-efe5-0f24dc881df2"); public void Save() { - if (OnSave != null) - OnSave(this); + OnSave?.Invoke(this); } private UUID m_RegionUUID = UUID.Zero; @@ -287,56 +288,56 @@ public double Elevation1NW public double Elevation2NW { get { return m_Elevation2NW; } - set { m_Elevation2NW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation2NW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation1NE = 10; public double Elevation1NE { get { return m_Elevation1NE; } - set { m_Elevation1NE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation1NE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation2NE = 60; public double Elevation2NE { get { return m_Elevation2NE; } - set { m_Elevation2NE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation2NE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation1SE = 10; public double Elevation1SE { get { return m_Elevation1SE; } - set { m_Elevation1SE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation1SE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation2SE = 60; public double Elevation2SE { get { return m_Elevation2SE; } - set { m_Elevation2SE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation2SE = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation1SW = 10; public double Elevation1SW { get { return m_Elevation1SW; } - set { m_Elevation1SW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation1SW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_Elevation2SW = 60; public double Elevation2SW { get { return m_Elevation2SW; } - set { m_Elevation2SW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap); ; } + set { m_Elevation2SW = Utils.Clamp(value, Constants.MinTerrainHeightmap, Constants.MaxTerrainHeightmap);} } private double m_WaterHeight = 20; public double WaterHeight { get { return m_WaterHeight; } - set { m_WaterHeight = Utils.Clamp(value, Constants.MinWaterHeight, Constants.MaxWaterHeight); } + set { m_WaterHeight = Utils.Clamp(value, Constants.MinWaterHeight, Constants.MaxWaterHeight);} } private double m_TerrainRaiseLimit = 100; @@ -426,7 +427,7 @@ public String LoadedCreationDate { get { - TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); + TimeSpan ts = new(0, 0, LoadedCreationDateTime); DateTime stamp = new DateTime(1970, 1, 1) + ts; return stamp.ToLongDateString(); } @@ -436,7 +437,7 @@ public String LoadedCreationTime { get { - TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); + TimeSpan ts = new(0, 0, LoadedCreationDateTime); DateTime stamp = new DateTime(1970, 1, 1) + ts; return stamp.ToLongTimeString(); } @@ -479,7 +480,7 @@ public bool HasTelehub /// /// Our connected Telehub's SpawnPoints /// - public List l_SpawnPoints = new List(); + public List l_SpawnPoints = new(); // Add a SpawnPoint // ** These are not region coordinates ** diff --git a/OpenSim/Framework/RegionURI.cs b/OpenSim/Framework/RegionURI.cs index 56bb04416fe..d3e0a8dbc11 100644 --- a/OpenSim/Framework/RegionURI.cs +++ b/OpenSim/Framework/RegionURI.cs @@ -32,17 +32,18 @@ namespace OpenSim.Framework { public class RegionURI { - private static byte[] schemaSep = osUTF8.GetASCIIBytes("://"); - private static byte[] altschemaSep = osUTF8.GetASCIIBytes("|!!"); - private static byte[] nameSep = osUTF8.GetASCIIBytes(":/ "); - private static byte[] altnameSep = osUTF8.GetASCIIBytes(":/ +|"); - private static byte[] escapePref = osUTF8.GetASCIIBytes("+%"); - private static byte[] altPortSepPref = osUTF8.GetASCIIBytes(":|"); + private static readonly byte[] schemaSep = osUTF8.GetASCIIBytes("://"); + private static readonly byte[] altschemaSep = osUTF8.GetASCIIBytes("|!!"); + private static readonly byte[] nameSep = osUTF8.GetASCIIBytes(":/ "); + private static readonly byte[] altnameSep = osUTF8.GetASCIIBytes(":/ +|"); + private static readonly byte[] escapePref = osUTF8.GetASCIIBytes("+%"); + private static readonly byte[] altPortSepPref = osUTF8.GetASCIIBytes(":|"); + private static readonly byte[] forbidonname = osUTF8.GetASCIIBytes(".,:;\\/"); public enum URIFlags : int { None = 0, - Valid = 1 << 0, + //Valid = 1 << 0, HasHost = 1 << 1, HasResolvedHost = 1 << 2, HasUserName = 1 << 3, @@ -70,7 +71,7 @@ public RegionURI(string _originalURI) { originalURI = _originalURI; Parse(_originalURI); - if (!HasHost) + if (!HasHost && HasRegionName) Flags |= URIFlags.IsLocalGrid; } @@ -81,7 +82,10 @@ public RegionURI(string _originalURI, GridInfo gi) if(!HasHost) { - Flags |= URIFlags.IsLocalGrid; + if(!HasRegionName) + Flags = URIFlags.None; + else + Flags |= URIFlags.IsLocalGrid; return; } if(gi == null) @@ -290,6 +294,12 @@ public void Parse(string inputURI) if (tmpSlice.Length <= 0) return; + if(tmpSlice.IndexOfAny(forbidonname) > 0) + { + Flags = URIFlags.None; + return; + } + RegionName = tmpSlice.ToString(); Flags |= URIFlags.HasRegionName; diff --git a/OpenSim/Framework/RegistryCore.cs b/OpenSim/Framework/RegistryCore.cs index 98d595a847d..d5e13bbde7b 100644 --- a/OpenSim/Framework/RegistryCore.cs +++ b/OpenSim/Framework/RegistryCore.cs @@ -53,9 +53,9 @@ public void RegisterInterface(T iface) public bool TryGet(out T iface) { - if (m_moduleInterfaces.ContainsKey(typeof(T))) + if (m_moduleInterfaces.TryGetValue(typeof(T), out object o)) { - iface = (T)m_moduleInterfaces[typeof(T)]; + iface = (T)o; return true; } iface = default(T); diff --git a/OpenSim/Framework/RestClient.cs b/OpenSim/Framework/RestClient.cs index 4c0d9031f1f..49c7f632a55 100644 --- a/OpenSim/Framework/RestClient.cs +++ b/OpenSim/Framework/RestClient.cs @@ -29,7 +29,9 @@ using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Http; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Web; @@ -44,17 +46,6 @@ namespace OpenSim.Framework /// /// /// This class is a generic implementation of a REST (Representational State Transfer) web service. This - /// class is designed to execute both synchronously and asynchronously. - /// - /// Internally the implementation works as a two stage asynchronous web-client. - /// When the request is initiated, RestClient will query asynchronously for for a web-response, - /// sleeping until the initial response is returned by the server. Once the initial response is retrieved - /// the second stage of asynchronous requests will be triggered, in an attempt to read of the response - /// object into a memorystream as a sequence of asynchronous reads. - /// - /// The asynchronisity of RestClient is designed to move as much processing into the back-ground, allowing - /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be - /// invoked by the caller in either synchronous mode or asynchronous modes. /// public class RestClient : IDisposable { @@ -67,17 +58,17 @@ public class RestClient : IDisposable /// /// The base Uri of the web-service e.g. http://www.google.com /// - private string _url; + private readonly string _url; /// /// Path elements of the query /// - private List _pathElements = new List(); + private readonly List _pathElements = new(); /// /// Parameter elements of the query, e.g. min=34 /// - private Dictionary _parameterElements = new Dictionary(); + private readonly Dictionary _parameterElements = new(); /// /// Request method. E.g. GET, POST, PUT or DELETE @@ -87,44 +78,23 @@ public class RestClient : IDisposable /// /// Temporary buffer used to store bytes temporarily as they come in from the server /// - private byte[] _readbuf; + private readonly byte[] _readbuf; /// /// MemoryStream representing the resulting resource /// - private MemoryStream _resource; - - /// - /// WebRequest object, held as a member variable - /// - private HttpWebRequest _request; - - /// - /// WebResponse object, held as a member variable, so we can close it - /// - private HttpWebResponse _response; - - /// - /// This flag will help block the main synchroneous method, in case we run in synchroneous mode - /// - //public static ManualResetEvent _allDone = new ManualResetEvent(false); + private readonly MemoryStream _resource; /// /// Default time out period /// - //private const int DefaultTimeout = 10*1000; // 10 seconds timeout + private const int DefaultTimeout = 90000; // 90 seconds timeout /// /// Default Buffer size of a block requested from the web-server /// private const int BufferSize = 4 * 4096; // Read blocks of 4 * 4 KB. - /// - /// if an exception occours during async processing, we need to save it, so it can be - /// rethrown on the primary thread; - /// - private Exception _asyncException; - #endregion member variables #region constructors @@ -138,12 +108,10 @@ public RestClient(string url) _url = url; _readbuf = new byte[BufferSize]; _resource = new MemoryStream(); - _request = null; - _response = null; _lock = new object(); } - private object _lock; + private readonly object _lock; #endregion constructors @@ -239,12 +207,12 @@ public string RequestMethod /// fully constructed Uri private Uri buildUri() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.Append(_url); foreach (string e in _pathElements) { - sb.Append("/"); + sb.Append('/'); sb.Append(e); } @@ -253,16 +221,16 @@ private Uri buildUri() { if (firstElement) { - sb.Append("?"); + sb.Append('?'); firstElement = false; } else - sb.Append("&"); + sb.Append('&'); sb.Append(kv.Key); if (!string.IsNullOrEmpty(kv.Value)) { - sb.Append("="); + sb.Append('='); sb.Append(kv.Value); } } @@ -271,47 +239,10 @@ private Uri buildUri() return new Uri(sb.ToString()); } - #region Async communications with server - - /// - /// Async method, invoked when a block of data has been received from the service - /// - /// - private void StreamIsReadyDelegate(IAsyncResult ar) - { - try - { - Stream s = (Stream) ar.AsyncState; - int read = s.EndRead(ar); - - if (read > 0) - { - _resource.Write(_readbuf, 0, read); - // IAsyncResult asynchronousResult = - // s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); - - // TODO! Implement timeout, without killing the server - //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); - } - else - { - s.Close(); - //_allDone.Set(); - } - } - catch (Exception e) - { - //_allDone.Set(); - _asyncException = e; - } - } - - #endregion Async communications with server - /// /// Perform a synchronous request /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public MemoryStream Request() { return Request(null); @@ -324,53 +255,78 @@ public MemoryStream Request(IServiceAuth auth) { lock (_lock) { + Uri uri = null; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - _request = (HttpWebRequest) WebRequest.Create(buildUri()); - _request.ContentType = "application/xml"; - _request.Timeout = 90000; - _request.Method = RequestMethod; - _asyncException = null; - if (auth != null) - auth.AddAuthorization(_request.Headers); - else - _request.AllowWriteStreamBuffering = false; + client = WebUtil.GetNewGlobalHttpClient(DefaultTimeout); + uri = buildUri(); + request = new(new HttpMethod(RequestMethod), uri); + + auth?.AddAuthorization(request.Headers); + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; + + //if (keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; + } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); + if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[REST CLIENT] {0} to {1}", _request.Method, _request.RequestUri); + m_log.DebugFormat("[REST CLIENT] {0} to {1}", RequestMethod, uri); + + //_request.ContentType = "application/xml"; + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); - using (_response = (HttpWebResponse) _request.GetResponse()) + Stream respStream = responseMessage.Content.ReadAsStream(); + int length = respStream.Read(_readbuf, 0, BufferSize); + while (length > 0) { - using (Stream src = _response.GetResponseStream()) - { - int length = src.Read(_readbuf, 0, BufferSize); - while (length > 0) - { - _resource.Write(_readbuf, 0, length); - length = src.Read(_readbuf, 0, BufferSize); - } - } + _resource.Write(_readbuf, 0, length); + length = respStream.Read(_readbuf, 0, BufferSize); } } - catch (WebException e) + catch (HttpRequestException e) { - using (HttpWebResponse errorResponse = e.Response as HttpWebResponse) + if(uri is not null) { - if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) + if (e.StatusCode is HttpStatusCode status) { - // This is often benign. E.g., requesting a missing asset will return 404. - m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", _request.Address.ToString()); + if (status == HttpStatusCode.NotFound) + { + // This is often benign. E.g., requesting a missing asset will return 404. + m_log.DebugFormat("[REST CLIENT] Resource not found (404): {0}", uri.ToString()); + } + else + { + m_log.Error($"[REST CLIENT] Error fetching resource from server: {uri} status: {status} {e.Message}"); + } } else { - m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); + m_log.Error($"[REST CLIENT] Error fetching resource from server: {uri} {e.Message}"); } } + else + { + m_log.Error($"[REST CLIENT] Error fetching null resource from server: {e.Message}"); + } return null; } - - if (_asyncException != null) - throw _asyncException; + finally + { + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + } if (_resource != null) { @@ -388,216 +344,64 @@ public MemoryStream Request(IServiceAuth auth) // just sync post data, ignoring result public void POSTRequest(byte[] src, IServiceAuth auth) { + Uri uri = null; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); - _request.ContentType = "application/xml"; - _request.Timeout = 90000; - _request.Method = "POST"; - _asyncException = null; - _request.ContentLength = src.Length; - if (auth != null) - auth.AddAuthorization(_request.Headers); - else - _request.AllowWriteStreamBuffering = false; - } - catch (Exception e) - { - m_log.WarnFormat("[REST]: POST {0} failed with exception {1} {2}", - _request.RequestUri, e.Message, e.StackTrace); - return; - } + client = WebUtil.GetNewGlobalHttpClient(DefaultTimeout); + uri = buildUri(); + request = new(HttpMethod.Post, uri); - try - { - using (Stream dst = _request.GetRequestStream()) - { - dst.Write(src, 0, src.Length); - } + auth?.AddAuthorization(request.Headers); + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; - using(HttpWebResponse response = (HttpWebResponse)_request.GetResponse()) + //if (keepalive) { - using (Stream responseStream = response.GetResponseStream()) - { - using (StreamReader reader = new StreamReader(responseStream)) - { - string responseStr = reader.ReadToEnd(); - if (WebUtil.DebugLevel >= 5) - { - int reqnum = WebUtil.RequestNumber++; - WebUtil.LogOutgoingDetail("REST POST", responseStr); - } - } - } + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); + + request.Content = new ByteArrayContent(src); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/xml"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", src.Length.ToString()); + + responseMessage = client.Send(request, HttpCompletionOption.ResponseContentRead); + responseMessage.EnsureSuccessStatusCode(); } - catch (WebException e) + catch (HttpRequestException e) { - m_log.WarnFormat("[REST]: POST {0} failed with status {1} and message {2}", - _request.RequestUri, e.Status, e.Message); + if(uri is not null) + { + if (e.StatusCode is HttpStatusCode status) + m_log.Warn($"[REST]: POST {uri} failed with status {status} and message {e.Message}"); + else + m_log.Warn($"[REST]: POST {uri} failed with message {e.Message}"); + } + else + m_log.Warn($"[REST]: POST failed {e.Message}"); return; } catch (Exception e) { - m_log.WarnFormat("[REST]: AsyncPOST {0} failed with exception {1} {2}", - _request.RequestUri, e.Message, e.StackTrace); + if (uri is not null) + m_log.Warn($"[REST]: POST {uri} failed with message {e.Message}"); + else + m_log.Warn($"[REST]: POST failed {e.Message}"); return; } - } - - } - - internal class SimpleAsyncResult : IAsyncResult - { - private readonly AsyncCallback m_callback; - - /// - /// Is process completed? - /// - /// Should really be boolean, but VolatileRead has no boolean method - private byte m_completed; - - /// - /// Did process complete synchronously? - /// - /// I have a hard time imagining a scenario where this is the case, again, same issue about - /// booleans and VolatileRead as m_completed - /// - private byte m_completedSynchronously; - - private readonly object m_asyncState; - private ManualResetEvent m_waitHandle; - private Exception m_exception; - - internal SimpleAsyncResult(AsyncCallback cb, object state) - { - m_callback = cb; - m_asyncState = state; - m_completed = 0; - m_completedSynchronously = 1; - } - - #region IAsyncResult Members - - public object AsyncState - { - get { return m_asyncState; } - } - - public WaitHandle AsyncWaitHandle - { - get + finally { - if (m_waitHandle == null) - { - bool done = IsCompleted; - ManualResetEvent mre = new ManualResetEvent(done); - if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null) - { - mre.Close(); - } - else - { - if (!done && IsCompleted) - { - m_waitHandle.Set(); - } - } - } - - return m_waitHandle; + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); } } - - public bool CompletedSynchronously - { - get { return Thread.VolatileRead(ref m_completedSynchronously) == 1; } - } - - - public bool IsCompleted - { - get { return Thread.VolatileRead(ref m_completed) == 1; } - } - - #endregion - - #region class Methods - - internal void SetAsCompleted(bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - - SignalCompletion(); - } - - internal void HandleException(Exception e, bool completedSynchronously) - { - m_completed = 1; - if (completedSynchronously) - m_completedSynchronously = 1; - else - m_completedSynchronously = 0; - m_exception = e; - - SignalCompletion(); - } - - private void SignalCompletion() - { - if (m_waitHandle != null) m_waitHandle.Set(); - - if (m_callback != null) m_callback(this); - } - - public void EndInvoke() - { - // This method assumes that only 1 thread calls EndInvoke - if (!IsCompleted) - { - // If the operation isn't done, wait for it - AsyncWaitHandle.WaitOne(); - AsyncWaitHandle.Close(); - m_waitHandle.Close(); - m_waitHandle = null; // Allow early GC - } - - // Operation is done: if an exception occured, throw it - if (m_exception != null) throw m_exception; - } - - #endregion - } - - internal class AsyncResult : SimpleAsyncResult - { - private T m_result = default(T); - - public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) - { - } - - public void SetAsCompleted(T result, bool completedSynchronously) - { - // Save the asynchronous operation's result - m_result = result; - - // Tell the base class that the operation completed - // sucessfully (no exception) - base.SetAsCompleted(completedSynchronously); - } - - public new T EndInvoke() - { - base.EndInvoke(); - return m_result; - } } - } diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index fd539a3e420..d824bbdf2f9 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -27,23 +27,21 @@ using OpenMetaverse; using System; +using System.Collections.Frozen; using System.Collections.Generic; using System.Globalization; +using System.Runtime.CompilerServices; namespace OpenSim.Framework { public static class SLUtil { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Asset types used only in OpenSim. /// To avoid clashing with the code numbers used in Second Life, use only negative numbers here. /// - public enum OpenSimAssetType : sbyte - { - Material = -2 - } #region SL / file extension / content-type conversions @@ -55,81 +53,48 @@ public static object AssetTypeFromCode(sbyte assetType) { if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) return (OpenMetaverse.AssetType)assetType; - else if (Enum.IsDefined(typeof(OpenSimAssetType), assetType)) - return (OpenSimAssetType)assetType; else return OpenMetaverse.AssetType.Unknown; } - private class TypeMapping + private struct TypeMapping { - private sbyte assetType; - private sbyte inventoryType; - private string contentType; - private string contentType2; - private string extension; - - public sbyte AssetTypeCode - { - get { return assetType; } - } - - public object AssetType - { - get { return AssetTypeFromCode(assetType); } - } - - public sbyte InventoryType - { - get { return inventoryType; } - } - - public string ContentType - { - get { return contentType; } - } - - public string ContentType2 - { - get { return contentType2; } - } - - public string Extension - { - get { return extension; } - } + public readonly sbyte AssetType; + public readonly sbyte InventoryType; + public readonly string ContentType; + public readonly string ContentType2; + public readonly string Extension; private TypeMapping(sbyte assetType, sbyte inventoryType, string contentType, string contentType2, string extension) { - this.assetType = assetType; - this.inventoryType = inventoryType; - this.contentType = contentType; - this.contentType2 = contentType2; - this.extension = extension; + AssetType = assetType; + InventoryType = inventoryType; + ContentType = contentType; + ContentType2 = contentType2; + Extension = extension; } public TypeMapping(AssetType assetType, sbyte inventoryType, string contentType, string contentType2, string extension) - : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) { + AssetType = (sbyte)assetType; + InventoryType = inventoryType; + ContentType = contentType; + ContentType2 = contentType2; + Extension = extension; } public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) - : this((sbyte)assetType, (sbyte)inventoryType, contentType, contentType2, extension) + : this(assetType, (sbyte)inventoryType, contentType, contentType2, extension) { } public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) - : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension) + : this(assetType, (sbyte)inventoryType, contentType, null, extension) { } public TypeMapping(AssetType assetType, FolderType inventoryType, string contentType, string extension) - : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension) - { - } - - public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension) - : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension) + : this(assetType, (sbyte)inventoryType, contentType, null, extension) { } } @@ -140,7 +105,7 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" /// - private static TypeMapping[] MAPPINGS = new TypeMapping[] { + private static TypeMapping[] MAPPINGS = [ new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), @@ -183,15 +148,15 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), // OpenSim specific - new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material") - }; - - private static Dictionary asset2Content; - private static Dictionary asset2Extension; - private static Dictionary inventory2Content; - private static Dictionary content2Asset; - private static Dictionary content2Inventory; - private static Dictionary name2Asset = new Dictionary() + new TypeMapping(AssetType.OSMaterial, InventoryType.Unknown, "application/llsd+xml", "material") + ]; + + private static readonly FrozenDictionary asset2Content; + private static readonly FrozenDictionary asset2Extension; + private static readonly FrozenDictionary inventory2Content; + private static readonly FrozenDictionary content2Asset; + private static readonly FrozenDictionary content2Inventory; + private static readonly FrozenDictionary name2Asset = new Dictionary() { {"texture", AssetType.Texture }, {"sound", AssetType.Sound}, @@ -215,8 +180,9 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri {"mesh", AssetType.Mesh}, {"settings", AssetType.Settings}, {"material", AssetType.Material} - }; - private static Dictionary name2Inventory = new Dictionary() + }.ToFrozenDictionary(); + + private static readonly FrozenDictionary name2Inventory = new Dictionary() { {"texture", FolderType.Texture}, {"sound", FolderType.Sound}, @@ -242,108 +208,94 @@ public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, stri {"settings", FolderType.Settings}, {"material", FolderType.Material}, {"suitcase", FolderType.Suitcase} - }; + }.ToFrozenDictionary(); static SLUtil() { - asset2Content = new Dictionary(); - asset2Extension = new Dictionary(); - inventory2Content = new Dictionary(); - content2Asset = new Dictionary(); - content2Inventory = new Dictionary(); + Dictionary asset2Contentd = []; + Dictionary asset2Extensiond = []; + Dictionary inventory2Contentd = []; + Dictionary content2Assetd = []; + Dictionary content2Inventoryd = []; foreach (TypeMapping mapping in MAPPINGS) { - sbyte assetType = mapping.AssetTypeCode; - if (!asset2Content.ContainsKey(assetType)) - asset2Content.Add(assetType, mapping.ContentType); - - if (!asset2Extension.ContainsKey(assetType)) - asset2Extension.Add(assetType, mapping.Extension); + sbyte assetType = mapping.AssetType; + asset2Contentd.TryAdd(assetType, mapping.ContentType); + asset2Extensiond.TryAdd(assetType, mapping.Extension); - if (!inventory2Content.ContainsKey(mapping.InventoryType)) - inventory2Content.Add(mapping.InventoryType, mapping.ContentType); + inventory2Contentd.TryAdd(mapping.InventoryType, mapping.ContentType); - if (!content2Asset.ContainsKey(mapping.ContentType)) - content2Asset.Add(mapping.ContentType, assetType); + content2Assetd.TryAdd(mapping.ContentType, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType)) - content2Inventory.Add(mapping.ContentType, mapping.InventoryType); + content2Inventoryd.TryAdd(mapping.ContentType, mapping.InventoryType); if (mapping.ContentType2 != null) { - if (!content2Asset.ContainsKey(mapping.ContentType2)) - content2Asset.Add(mapping.ContentType2, assetType); - if (!content2Inventory.ContainsKey(mapping.ContentType2)) - content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); + content2Assetd.TryAdd(mapping.ContentType2, assetType); + content2Inventoryd.TryAdd(mapping.ContentType2, mapping.InventoryType); } } + asset2Content = asset2Contentd.ToFrozenDictionary(); + asset2Extension = asset2Extensiond.ToFrozenDictionary(); + inventory2Content = inventory2Contentd.ToFrozenDictionary(); + content2Asset = content2Assetd.ToFrozenDictionary(); + content2Inventory = content2Inventoryd.ToFrozenDictionary(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AssetType SLAssetName2Type(string name) { - if (name2Asset.TryGetValue(name, out AssetType type)) - return type; - return AssetType.Unknown; + return name2Asset.TryGetValue(name, out AssetType type) ? type : AssetType.Unknown; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static FolderType SLInvName2Type(string name) { - if (name2Inventory.TryGetValue(name, out FolderType type)) - return type; - return FolderType.None; + return name2Inventory.TryGetValue(name, out FolderType type) ? type : FolderType.None; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string SLAssetTypeToContentType(int assetType) { - string contentType; - if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) - contentType = asset2Content[(sbyte)AssetType.Unknown]; - return contentType; + return asset2Content.TryGetValue((sbyte)assetType, out string contentType) ? contentType : asset2Content[(sbyte)AssetType.Unknown]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string SLInvTypeToContentType(int invType) { - string contentType; - if (!inventory2Content.TryGetValue((sbyte)invType, out contentType)) - contentType = inventory2Content[(sbyte)InventoryType.Unknown]; - return contentType; + return inventory2Content.TryGetValue((sbyte)invType, out string contentType) ? contentType : inventory2Content[(sbyte)InventoryType.Unknown]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static sbyte ContentTypeToSLAssetType(string contentType) { - sbyte assetType; - if (!content2Asset.TryGetValue(contentType, out assetType)) - assetType = (sbyte)AssetType.Unknown; - return (sbyte)assetType; + return content2Asset.TryGetValue(contentType, out sbyte assetType) ? assetType : (sbyte)AssetType.Unknown; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static sbyte ContentTypeToSLInvType(string contentType) { - sbyte invType; - if (!content2Inventory.TryGetValue(contentType, out invType)) - invType = (sbyte)InventoryType.Unknown; - return (sbyte)invType; + return content2Inventory.TryGetValue(contentType, out sbyte invType) ? invType : (sbyte)InventoryType.Unknown; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string SLAssetTypeToExtension(int assetType) { - string extension; - if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) - extension = asset2Extension[(sbyte)AssetType.Unknown]; - return extension; + return asset2Extension.TryGetValue((sbyte)assetType, out string extension) ? extension : asset2Extension[(sbyte)AssetType.Unknown]; } #endregion SL / file extension / content-type conversions - static char[] seps = new char[] { '\t', '\n' }; - static char[] stringseps = new char[] { '|', '\n' }; + static readonly char[] seps = new char[] { '\t', '\n' }; + static readonly char[] stringseps = new char[] { '|', '\n' }; static byte[] moronize = new byte[16] { 60, 17, 94, 81, 4, 244, 82, 60, 159, 166, 152, 175, 241, 3, 71, 48 }; + [MethodImpl(MethodImplOptions.AggressiveInlining)] static int getField(string note, int start, string name, bool isString, out string value) { value = String.Empty; @@ -615,8 +567,8 @@ public static List GetEmbeddedAssetIDs(byte[] data) if(indx > 0) { indx += 14; - List textIDs = Util.GetUUIDsOnString(ref note, indx, note.Length - indx); - if(textIDs.Count > 0) + List textIDs = Util.GetUUIDsOnString(note.AsSpan(indx, note.Length - indx)); + if (textIDs.Count > 0) ids.AddRange(textIDs); } if (ids.Count == 0) diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 8715d0196d6..245bc0bf286 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs @@ -29,7 +29,6 @@ using System.Collections.Generic; using System.Text; using OpenMetaverse; -using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; namespace OpenSim.Framework.Serialization { @@ -96,7 +95,7 @@ public class ArchiveConstants /// /// Template used for creating filenames in OpenSim Archives. /// - public const string OAR_OBJECT_FILENAME_TEMPLATE = "{0}_{1:000}-{2:000}-{3:000}__{4}.xml"; + public const string OAR_OBJECT_FILENAME_TEMPLATE = "{0}_{1:#000}-{2:#000}-{3:#000}__{4}.xml"; /// /// Extensions used for asset types in the archive @@ -125,7 +124,7 @@ static ArchiveConstants() ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga"; - ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.OSMaterial] = ASSET_EXTENSION_SEPARATOR + "material.xml"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Settings] = ASSET_EXTENSION_SEPARATOR + "settings.bin"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Material] = ASSET_EXTENSION_SEPARATOR + "prmat.dat"; @@ -148,14 +147,14 @@ static ArchiveConstants() EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV; EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture; EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA; - EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material; + EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)AssetType.OSMaterial; EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "settings.bin"] = (sbyte)AssetType.Settings; EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "prmat.dat"] = (sbyte)AssetType.Material; } public static string CreateOarLandDataPath(LandData ld) { - return string.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, ld.GlobalID); + return $"{ArchiveConstants.LANDDATA_PATH}{ld.GlobalID}.xml"; } /// @@ -169,7 +168,7 @@ public static string CreateOarObjectFilename(string objectName, UUID uuid, Vecto { return string.Format( OAR_OBJECT_FILENAME_TEMPLATE, objectName, - Math.Round(pos.X), Math.Round(pos.Y), Math.Round(pos.Z), + MathF.Round(pos.X), MathF.Round(pos.Y), MathF.Round(pos.Z), uuid); } @@ -192,7 +191,7 @@ public static string CreateOarObjectPath(string objectName, UUID uuid, Vector3 p /// public static string ExtractPlainPathFromIarPath(string iarPath) { - List plainDirs = new List(); + List plainDirs = new(); string[] iarDirs = iarPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 423c1dc75ef..7aa8b1ae1e6 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs @@ -222,7 +222,7 @@ public static string RewriteSOP(string xmlData, string sceneName, string homeURL using (StringWriter sw = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(sw)) using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) - using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore})) + using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings)) { TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); diff --git a/OpenSim/Framework/Serialization/OpenSim.Framework.Serialization.csproj b/OpenSim/Framework/Serialization/OpenSim.Framework.Serialization.csproj index 8260c678602..ed01cd433fd 100644 --- a/OpenSim/Framework/Serialization/OpenSim.Framework.Serialization.csproj +++ b/OpenSim/Framework/Serialization/OpenSim.Framework.Serialization.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Framework.Serialization http://opensimulator.org OpenSim diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs deleted file mode 100644 index e81cb78cfd2..00000000000 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenMetaverse.StructuredData; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Serialization.External; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Serialization.Tests -{ - [TestFixture] - public class LandDataSerializerTest : OpenSimTestCase - { - private LandData land; - private LandData landWithParcelAccessList; - -// private static string preSerialized = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; - private static string preSerializedWithParcelAccessList - = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n \n 62d65d45-c91a-4f77-862c-46557d978b6c\n \n 2\n \n \n ec2a8d18-2378-4fe0-8b68-2a31b57c481e\n \n 1\n \n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; - - [SetUp] - public void setup() - { - // setup LandData object - this.land = new LandData(); - this.land.AABBMax = new Vector3(1, 2, 3); - this.land.AABBMin = new Vector3(129, 130, 131); - this.land.Area = 128; - this.land.AuctionID = 4; - this.land.AuthBuyerID = new UUID("7176df0c-6c50-45db-8a37-5e78be56a0cd"); - this.land.Category = ParcelCategory.Residential; - this.land.ClaimDate = 1; - this.land.ClaimPrice = 2; - this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50"); - this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5"); - this.land.Description = "land data to test LandDataSerializer"; - this.land.Flags = (uint)(ParcelFlags.AllowDamage | ParcelFlags.AllowVoiceChat); - this.land.LandingType = (byte)LandingType.Direct; - this.land.Name = "LandDataSerializerTest Land"; - this.land.Status = ParcelStatus.Leased; - this.land.LocalID = 1; - this.land.MediaAutoScale = (byte)0x01; - this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7"); - this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4"; - this.land.OwnerID = new UUID("1b8eedf9-6d15-448b-8015-24286f1756bf"); - - this.landWithParcelAccessList = this.land.Copy(); - this.landWithParcelAccessList.ParcelAccessList.Clear(); - - LandAccessEntry pae0 = new LandAccessEntry(); - pae0.AgentID = new UUID("62d65d45-c91a-4f77-862c-46557d978b6c"); - pae0.Flags = AccessList.Ban; - pae0.Expires = 0; - this.landWithParcelAccessList.ParcelAccessList.Add(pae0); - - LandAccessEntry pae1 = new LandAccessEntry(); - pae1.AgentID = new UUID("ec2a8d18-2378-4fe0-8b68-2a31b57c481e"); - pae1.Flags = AccessList.Access; - pae1.Expires = 0; - this.landWithParcelAccessList.ParcelAccessList.Add(pae1); - } - - /// - /// Test the LandDataSerializer.Serialize() method - /// -// [Test] -// public void LandDataSerializerSerializeTest() -// { -// TestHelpers.InMethod(); -// -// string serialized = LandDataSerializer.Serialize(this.land).Replace("\r\n", "\n"); -// Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string"); -// -// // adding a simple boolean variable because resharper nUnit integration doesn't like this -// // XML data in the Assert.That statement. Not sure why. -// bool result = (serialized == preSerialized); -// Assert.That(result, "result of Serialize LandData does not match expected result"); -// -// string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList).Replace("\r\n", "\n"); -// Assert.That(serializedWithParcelAccessList.Length > 0, -// "Serialize(LandData) returned empty string for LandData object with ParcelAccessList"); -// result = (serializedWithParcelAccessList == preSerializedWithParcelAccessList); -// Assert.That(result, -// "result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list"); -// } - - /// - /// Test the LandDataSerializer.Deserialize() method - /// - [Test] - public void TestLandDataDeserializeNoAccessLists() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - Dictionary options = new Dictionary(); - LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, options)); - Assert.That(ld, Is.Not.Null, "Deserialize(string) returned null"); -// Assert.That(ld.AABBMax, Is.EqualTo(land.AABBMax)); -// Assert.That(ld.AABBMin, Is.EqualTo(land.AABBMin)); - Assert.That(ld.Area, Is.EqualTo(land.Area)); - Assert.That(ld.AuctionID, Is.EqualTo(land.AuctionID)); - Assert.That(ld.AuthBuyerID, Is.EqualTo(land.AuthBuyerID)); - Assert.That(ld.Category, Is.EqualTo(land.Category)); - Assert.That(ld.ClaimDate, Is.EqualTo(land.ClaimDate)); - Assert.That(ld.ClaimPrice, Is.EqualTo(land.ClaimPrice)); - Assert.That(ld.GlobalID, Is.EqualTo(land.GlobalID), "Reified LandData.GlobalID != original LandData.GlobalID"); - Assert.That(ld.GroupID, Is.EqualTo(land.GroupID)); - Assert.That(ld.Description, Is.EqualTo(land.Description)); - Assert.That(ld.Flags, Is.EqualTo(land.Flags)); - Assert.That(ld.LandingType, Is.EqualTo(land.LandingType)); - Assert.That(ld.Name, Is.EqualTo(land.Name), "Reified LandData.Name != original LandData.Name"); - Assert.That(ld.Status, Is.EqualTo(land.Status)); - Assert.That(ld.LocalID, Is.EqualTo(land.LocalID)); - Assert.That(ld.MediaAutoScale, Is.EqualTo(land.MediaAutoScale)); - Assert.That(ld.MediaID, Is.EqualTo(land.MediaID)); - Assert.That(ld.MediaURL, Is.EqualTo(land.MediaURL)); - Assert.That(ld.OwnerID, Is.EqualTo(land.OwnerID)); - } - - [Test] - public void TestLandDataDeserializeWithAccessLists() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - LandData ld = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList); - Assert.That(ld != null, - "Deserialize(string) returned null (pre-serialized with parcel access list)"); - Assert.That(ld.GlobalID == this.landWithParcelAccessList.GlobalID, - "Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)"); - Assert.That(ld.Name == this.landWithParcelAccessList.Name, - "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)"); - Assert.That(ld.ParcelAccessList.Count, Is.EqualTo(2)); - Assert.That(ld.ParcelAccessList[0].AgentID, Is.EqualTo(UUID.Parse("62d65d45-c91a-4f77-862c-46557d978b6c"))); - } - } -} diff --git a/OpenSim/Framework/Serialization/Tests/OpenSim.Framework.Serialization.Tests.csproj b/OpenSim/Framework/Serialization/Tests/OpenSim.Framework.Serialization.Tests.csproj deleted file mode 100644 index 1a9ddda6c3c..00000000000 --- a/OpenSim/Framework/Serialization/Tests/OpenSim.Framework.Serialization.Tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - net48 - - - - - - - - - - ..\..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\..\bin\OpenMetaverseTypes.dll - False - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs deleted file mode 100644 index 4f3f2ddde31..00000000000 --- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenMetaverse.StructuredData; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Serialization.External; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Serialization.Tests -{ - [TestFixture] - public class RegionSettingsSerializerTests : OpenSimTestCase - { - private string m_serializedRs = @" - - - True - True - True - True - True - True - True - True - True - 1 - True - 40 - 1.4 - - - 00000000-0000-0000-0000-000000000020 - 00000000-0000-0000-0000-000000000040 - 00000000-0000-0000-0000-000000000060 - 00000000-0000-0000-0000-000000000080 - 1.9 - 15.9 - 49 - 45.3 - 2.1 - 4.5 - 9.2 - 19.2 - - - 23 - 17.9 - 0.4 - True - true - 12 - - - 00000000-0000-0000-0000-111111111111 - 1,-2,0.33 - -"; - - private RegionSettings m_rs; - - [SetUp] - public void Setup() - { - m_rs = new RegionSettings(); - m_rs.AgentLimit = 17; - m_rs.AllowDamage = true; - m_rs.AllowLandJoinDivide = true; - m_rs.AllowLandResell = true; - m_rs.BlockFly = true; - m_rs.BlockShowInSearch = true; - m_rs.BlockTerraform = true; - m_rs.DisableCollisions = true; - m_rs.DisablePhysics = true; - m_rs.DisableScripts = true; - m_rs.Elevation1NW = 15.9; - m_rs.Elevation1NE = 45.3; - m_rs.Elevation1SE = 49; - m_rs.Elevation1SW = 1.9; - m_rs.Elevation2NW = 4.5; - m_rs.Elevation2NE = 19.2; - m_rs.Elevation2SE = 9.2; - m_rs.Elevation2SW = 2.1; - m_rs.FixedSun = true; - m_rs.SunPosition = 12.0; - m_rs.ObjectBonus = 1.4; - m_rs.RestrictPushing = true; - m_rs.TerrainLowerLimit = 0.4; - m_rs.TerrainRaiseLimit = 17.9; - m_rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020"); - m_rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040"); - m_rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060"); - m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); - m_rs.UseEstateSun = true; - m_rs.WaterHeight = 23; - m_rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); - m_rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); - } - - [Test] - public void TestRegionSettingsDeserialize() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs, out ViewerEnvironment dummy, new EstateSettings()); - Assert.That(deserRs, Is.Not.Null); - Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2)); - Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics)); - Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit)); - Assert.That(deserRs.TelehubObject, Is.EqualTo(m_rs.TelehubObject)); - Assert.That(deserRs.SpawnPoints()[0].ToString(), Is.EqualTo(m_rs.SpawnPoints()[0].ToString())); - } - } -} diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 5feb7b521fb..940713b17cb 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -27,28 +27,21 @@ using System; using System.Collections.Generic; -using System.IO; using System.Reflection; using System.Text; -using System.Text.RegularExpressions; using System.Threading; using System.Timers; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using log4net; -using log4net.Appender; -using log4net.Core; -using log4net.Repository; using OpenMetaverse; -using OpenMetaverse.StructuredData; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Monitoring; -using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using Timer=System.Timers.Timer; using Nini.Config; +using System.Runtime.InteropServices; namespace OpenSim.Framework.Servers { @@ -89,8 +82,8 @@ public BaseOpenSimServer() : base() m_osSecret = UUID.Random().ToString(); } - private static bool m_NoVerifyCertChain = false; - private static bool m_NoVerifyCertHostname = false; + private static bool m_NoVerifyCertChain = true; + private static bool m_NoVerifyCertHostname = true; public static bool ValidateServerCertificate( object sender, @@ -124,6 +117,8 @@ protected virtual void StartupSpecific() m_NoVerifyCertHostname = startupConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; + WebUtil.SetupHTTPClients(m_NoVerifyCertChain, m_NoVerifyCertHostname, null, 32 ); + int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); @@ -184,21 +179,9 @@ public virtual void Startup() { m_log.Info("[STARTUP]: Beginning startup processing"); - m_log.Info("[STARTUP]: version: " + m_version + Environment.NewLine); - // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and - // the clr version number doesn't match the project version number under Mono. - //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine); - m_log.InfoFormat( - "[STARTUP]: Operating system version: {0}, .NET platform {1}, {2}-bit\n", - Environment.OSVersion, Environment.OSVersion.Platform, Environment.Is64BitProcess ? "64" : "32"); - - // next code can be changed on .net 4.7.x - if(Util.IsWindows()) - m_log.InfoFormat("[STARTUP]: Processor Architecture: {0}({1})", - System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine), - BitConverter.IsLittleEndian ?"le":"be"); - - // on other platforms we need to wait for .net4.7.1 + m_log.Info("[STARTUP]: version: " + m_version); + m_log.Info($"[STARTUP]: Operating system version: {Environment.OSVersion}, .NET platform {Util.RuntimePlatformStr}, Runtime {Environment.Version}"); + m_log.Info($"[STARTUP]: Processor Architecture: {RuntimeInformation.ProcessArchitecture}({(BitConverter.IsLittleEndian ? "le" : "be")} {(Environment.Is64BitProcess ? "64" : "32")}bit)"); try { StartupSpecific(); @@ -208,12 +191,6 @@ public virtual void Startup() m_log.Fatal("Fatal error: " + e.ToString()); Environment.Exit(1); } - - //TimeSpan timeTaken = DateTime.Now - m_startuptime; - -// MainConsole.Instance.OutputFormat( -// "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.", -// timeTaken.Minutes, timeTaken.Seconds); } public string osSecret diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index be6c97346df..9fa9edfe2e0 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -46,17 +46,17 @@ using Nwc.XmlRpc; using OpenSim.Framework.Monitoring; using OpenMetaverse.StructuredData; - +using OpenMetaverse; namespace OpenSim.Framework.Servers.HttpServer { public class BaseHttpServer : IHttpServer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); - private static Encoding UTF8NoBOM = new System.Text.UTF8Encoding(false); + private readonly HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); + private static readonly Encoding UTF8NoBOM = new System.Text.UTF8Encoding(false); public static PollServiceRequestManager m_pollServiceManager; - private static object m_generalLock = new object(); + private static readonly object m_generalLock = new object(); private string HTTP404; /// @@ -90,7 +90,6 @@ public class BaseHttpServer : IHttpServer /// private Stat m_requestsProcessedStat; - private volatile int NotSocketErrors = 0; public volatile bool HTTPDRunning = false; protected tinyHTTPListener m_httpListener; @@ -218,7 +217,7 @@ private void load_cert(string CPath, string CPass) { try { - m_cert = new X509Certificate2(CPath, CPass); + m_cert = new X509Certificate2(CPath, CPass); X509Extension ext = m_cert.Extensions["2.5.29.17"]; if(ext != null) { @@ -283,7 +282,7 @@ static bool MatchDNS(string hostname, string dns) if (indx2 != -1) return false; // there can only be one; - string end = dns.Substring(indx + 1); + string end = dns[(indx + 1)..]; int hostlen = hostname.Length; int endlen = end.Length; int length = hostlen - endlen; @@ -299,7 +298,7 @@ static bool MatchDNS(string hostname, string dns) return ((indx2 == -1) || (indx2 >= length)); } - string start = dns.Substring(0, indx); + string start = dns[..indx]; return (String.Compare(hostname, 0, start, 0, start.Length, true, CultureInfo.InvariantCulture) == 0); } @@ -336,19 +335,15 @@ public bool CheckSSLCertHost(string hostname) /// public void AddStreamHandler(IRequestHandler handler) { - string httpMethod = handler.HttpMethod; - string path = handler.Path; - - if(path == "/") + if(handler.Path.Equals("/")) { - if(httpMethod == "GET") + if(handler.HttpMethod.Equals("GET")) m_RootDefaultGET = handler; return; } - string handlerKey = GetHandlerKey(httpMethod, path); - + string handlerKey = GetHandlerKey(handler.HttpMethod, handler.Path); // m_log.DebugFormat("[BASE HTTP SERVER]: Adding handler key {0}", handlerKey); m_streamHandlers.TryAdd(handlerKey, handler); } @@ -419,7 +414,6 @@ public bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive m_rpcHandlers[method] = handler; m_rpcHandlersKeepAlive[method] = keepAlive; // default } - return true; } @@ -427,7 +421,7 @@ public XmlRpcMethod GetXmlRPCHandler(string method) { lock (m_rpcHandlers) { - return (m_rpcHandlers.TryGetValue(method, out XmlRpcMethod xm)) ? xm : null; + return m_rpcHandlers.TryGetValue(method, out XmlRpcMethod xm) ? xm : null; } } @@ -435,7 +429,7 @@ public bool TryGetXmlRPCHandler(string method, out XmlRpcMethod handler) { lock (m_rpcHandlers) { - return (m_rpcHandlers.TryGetValue(method, out handler)); + return m_rpcHandlers.TryGetValue(method, out handler); } } @@ -450,9 +444,8 @@ public bool AddJsonRPCHandler(string method, JsonRPCMethod handler) { lock(jsonRpcHandlers) { - jsonRpcHandlers.Add(method, handler); + return jsonRpcHandlers.TryAdd(method, handler); } - return true; } public JsonRPCMethod GetJsonRPCHandler(string method) @@ -472,18 +465,10 @@ public List GetJsonRpcHandlerKeys() public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) { //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); - lock (m_HTTPHandlers) { - if (!m_HTTPHandlers.ContainsKey(methodName)) - { - m_HTTPHandlers.Add(methodName, handler); - return true; - } + return m_HTTPHandlers.TryAdd(methodName, handler); } - - //must already have a handler for that path so return false - return false; } public List GetHTTPHandlerKeys() @@ -518,13 +503,8 @@ public bool AddLLSDHandler(string path, LLSDMethod handler) { lock (m_llsdHandlers) { - if (!m_llsdHandlers.ContainsKey(path)) - { - m_llsdHandlers.Add(path, handler); - return true; - } + return m_llsdHandlers.TryAdd(path, handler); } - return false; } public List GetLLSDHandlerKeys() @@ -594,12 +574,12 @@ public void OnRequest(object source, RequestEventArgs args) { psEvArgs.RequestsReceived++; PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, request); - if(psEvArgs.Request == null) + if(psEvArgs.Request is null) m_pollServiceManager.Enqueue(psreq); else { OSHttpResponse resp = psEvArgs.Request.Invoke(psreq.RequestID, osRequest); - if(resp == null) + if(resp is null) m_pollServiceManager.Enqueue(psreq); else resp.Send(); @@ -613,7 +593,7 @@ public void OnRequest(object source, RequestEventArgs args) } catch (Exception e) { - m_log.Error(string.Format("[BASE HTTP SERVER]: OnRequest() failed: {0} ", e.Message), e); + m_log.Error($"[BASE HTTP SERVER]: OnRequest() failed: {e.Message}"); } } @@ -624,28 +604,22 @@ public void OnRequest(object source, RequestEventArgs args) /// public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) { - string requestMethod = request.HttpMethod; - string uriString = request.RawUrl; - int requestStartTick = Environment.TickCount; - - // Will be adjusted later on. int requestEndTick = requestStartTick; IRequestHandler requestHandler = null; - byte[] responseData = null; try { // OpenSim.Framework.WebUtil.OSHeaderRequestID -// if (request.Headers["opensim-request-id"] != null) -// reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); - //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); + // if (request.Headers["opensim-request-id"] != null) + // reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); + // m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); Culture.SetCurrentCulture(); - if (request.HttpMethod == "OPTIONS") + if (request.HttpMethod.Equals("OPTIONS")) { //need to check this response.AddHeader("Access-Control-Allow-Origin", "*"); @@ -653,7 +627,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response response.AddHeader("Access-Control-Allow-Headers", "Content-Type"); response.StatusCode = (int)HttpStatusCode.OK; - if (request.InputStream != null && request.InputStream.CanRead) + if (request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); requestEndTick = Environment.TickCount; @@ -662,20 +636,18 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response return; } - string path = request.UriPath; - if (path == "/") + if (request.UriPath.Equals("/")) { response.StatusCode = (int)HttpStatusCode.NotFound; // default - if (m_RootDefaultGET != null && request.HttpMethod == "GET") + if (m_RootDefaultGET is not null && request.HttpMethod.Equals("GET")) { - if(m_RootDefaultGET is IStreamedRequestHandler) + if(m_RootDefaultGET is IStreamedRequestHandler isrh) { - IStreamedRequestHandler isrh = m_RootDefaultGET as IStreamedRequestHandler; - response.RawBuffer = isrh.Handle(path, request.InputStream, request, response); + response.RawBuffer = isrh.Handle(request.UriPath, request.InputStream, request, response); response.StatusCode = (int)HttpStatusCode.OK; } - if (request.InputStream != null && request.InputStream.CanRead) + if (request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); requestEndTick = Environment.TickCount; @@ -720,7 +692,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response } } - if (request.InputStream != null && request.InputStream.CanRead) + if (request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); requestEndTick = Environment.TickCount; @@ -729,7 +701,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response return; } - path = Util.TrimEndSlash(path); + string path = Util.TrimEndSlash(request.UriPath); if (TryGetSimpleStreamHandler(path, out ISimpleStreamHandler hdr)) { @@ -737,7 +709,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response LogIncomingToStreamHandler(request, hdr); hdr.Handle(request, response); - if (request.InputStream != null && request.InputStream.CanRead) + if (request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); requestEndTick = Environment.TickCount; @@ -756,16 +728,13 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. - if (requestHandler is IStreamedRequestHandler) + if (requestHandler is IStreamedRequestHandler streamedRequestHandler) { - IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; - buffer = streamedRequestHandler.Handle(path, request.InputStream, request, response); } - else if (requestHandler is IGenericHTTPHandler) + else if (requestHandler is IGenericHTTPHandler HTTPRequestHandler) { //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); - IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; string requestBody; Encoding encoding = Encoding.UTF8; @@ -854,10 +823,10 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response } } - if(request.InputStream != null && request.InputStream.CanRead) + if(request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); - if (buffer != null) + if (buffer is not null) { if (WebUtil.DebugLevel >= 5) { @@ -866,10 +835,10 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response if (WebUtil.DebugLevel >= 6) { // Always truncate binary blobs. We don't have a ContentType, so detect them using the request name. - if ((requestHandler != null && requestHandler.Name == "GetMesh")) + if (requestHandler is not null && requestHandler.Name.Equals("GetMesh")) { if (output.Length > WebUtil.MaxRequestDiagLength) - output = output.Substring(0, WebUtil.MaxRequestDiagLength) + "..."; + output = string.Concat(output.AsSpan(0, WebUtil.MaxRequestDiagLength), "..."); } } @@ -903,7 +872,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response // // An alternative may be to turn off all response write exceptions on the HttpListener, but let's go // with the minimum first - m_log.Warn(String.Format("[BASE HTTP SERVER]: HandleRequest threw {0}.\nNOTE: this may be spurious on Linux ", e.Message), e); + m_log.Warn($"[BASE HTTP SERVER]: HandleRequest threw {e.Message}.\nNOTE: this may be spurious on Linux"); } catch (IOException e) { @@ -922,7 +891,7 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response } finally { - if(request.InputStream != null && request.InputStream.CanRead) + if(request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Close(); int tickdiff = requestEndTick - requestStartTick; @@ -931,10 +900,10 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response m_log.InfoFormat( "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", RequestNumber, - requestMethod, - uriString, - requestHandler != null ? requestHandler.Name : "", - requestHandler != null ? requestHandler.Description : "", + request.HttpMethod, + request.RawUrl, + requestHandler is null ? "" : requestHandler.Name, + requestHandler is null ? "" : requestHandler.Description, request.RemoteIPEndPoint, tickdiff); } @@ -953,12 +922,10 @@ public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response if (DebugLevel == 5) { if (output.Length > WebUtil.MaxRequestDiagLength) - output = output.Substring(0, WebUtil.MaxRequestDiagLength) + "..."; + output = string.Concat(output.AsSpan(0, WebUtil.MaxRequestDiagLength), "..."); } m_log.DebugFormat("[LOGHTTP] RESPONSE {0}: {1}", RequestNumber, output); } - - responseData = null; } } @@ -1101,7 +1068,7 @@ private bool TryGetPollServiceHTTPHandler(string handlerKey, out PollServiceEven if(m_pollHandlers.TryGetValue(handlerKey, out oServiceEventArgs)) return true; - if(m_pollHandlersVarPath.Count > 0 && handlerKey.Length >= 45) + if(!m_pollHandlersVarPath.IsEmpty && handlerKey.Length >= 45) { // tuned for lsl requests, the only ones that should reach this, so be strict (/lslhttp/uuid.ToString()) int indx = handlerKey.IndexOf('/', 44); @@ -1110,7 +1077,7 @@ private bool TryGetPollServiceHTTPHandler(string handlerKey, out PollServiceEven if(m_pollHandlersVarPath.TryGetValue(handlerKey, out oServiceEventArgs)) return true; } - else if(m_pollHandlersVarPath.TryGetValue(handlerKey.Substring(0, indx), out oServiceEventArgs)) + else if(m_pollHandlersVarPath.TryGetValue(handlerKey[..indx], out oServiceEventArgs)) return true; } @@ -1165,7 +1132,7 @@ private bool TryGetSimpleStreamHandler(string uripath, out ISimpleStreamHandler if(indx < 0 || indx == uripath.Length - 1) return false; - return m_simpleStreamVarPath.TryGetValue(uripath.Substring(0,indx), out handler); + return m_simpleStreamVarPath.TryGetValue(uripath[..indx], out handler); } /// @@ -1209,7 +1176,7 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) { if (requestStream.CanRead) requestStream.Dispose(); - if (innerStream != null && innerStream.CanRead) + if (innerStream is not null && innerStream.CanRead) innerStream.Dispose(); response.StatusCode = (int)HttpStatusCode.BadRequest; @@ -1235,11 +1202,11 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) { if (requestStream.CanRead) requestStream.Dispose(); - if (innerStream != null && innerStream.CanRead) + if (innerStream is not null && innerStream.CanRead) innerStream.Dispose(); } - if (xmlRprcRequest == null) + if (xmlRprcRequest is null) return; string methodName = xmlRprcRequest.MethodName; @@ -1267,7 +1234,7 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) string xfflower = xff.ToLower(); foreach (string s in request.Headers.AllKeys) { - if (s != null && s.Equals(xfflower)) + if (s is not null && s.Equals(xfflower)) { xff = xfflower; break; @@ -1291,12 +1258,8 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) } catch(Exception e) { - string errorMessage - = String.Format( - "Requested method [{0}] from {1} threw exception: {2} {3}", - methodName, request.RemoteIPEndPoint.Address, e.Message, e.StackTrace); - - m_log.ErrorFormat("[BASE HTTP SERVER]: {0}", errorMessage); + string errorMessage = $"Requested method [{methodName}] from {request.RemoteIPEndPoint.Address} threw exception: {e.Message}"; + m_log.Error($"[BASE HTTP SERVER]: {errorMessage}"); // if the registered XmlRpc method threw an exception, we pass a fault-code along xmlRpcResponse = new XmlRpcResponse(); @@ -1349,7 +1312,7 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response, { if (requestStream.CanRead) requestStream.Dispose(); - if (innerStream != null && innerStream.CanRead) + if (innerStream is not null && innerStream.CanRead) innerStream.Dispose(); response.StatusCode = (int)HttpStatusCode.BadRequest; @@ -1376,11 +1339,11 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response, { if (requestStream.CanRead) requestStream.Dispose(); - if (innerStream != null && innerStream.CanRead) + if (innerStream is not null && innerStream.CanRead) innerStream.Dispose(); } - if (xmlRprcRequest == null) + if (xmlRprcRequest is null) { response.StatusCode = (int)HttpStatusCode.NotFound; response.KeepAlive = false; @@ -1395,10 +1358,9 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response, return; } - XmlRpcMethod method; bool methodWasFound; - methodWasFound = rpcHandlers.TryGetValue(methodName, out method); + methodWasFound = rpcHandlers.TryGetValue(methodName, out XmlRpcMethod method); XmlRpcResponse xmlRpcResponse; if (methodWasFound) @@ -1406,27 +1368,20 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response, xmlRprcRequest.Params.Add(request.RemoteIPEndPoint); // Param[1] xmlRprcRequest.Params.Add(request.Url); // Param[2] - string xff = "X-Forwarded-For"; - string xfflower = xff.ToLower(); foreach (string s in request.Headers.AllKeys) { - if (s != null && s.Equals(xfflower)) + if (s is not null && s.Equals("x-forwarded-for", StringComparison.OrdinalIgnoreCase)) { - xff = xfflower; + xmlRprcRequest.Params.Add(request.Headers.Get(s)); // Param[3] break; } } - xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] // reserve this for // ... by Fumi.Iseki for DTLNSLMoneyServer // BUT make its presence possible to detect/parse - string rcn = request.IHttpClientContext.SSLCommonName; - if (!string.IsNullOrWhiteSpace(rcn)) - { - rcn = "SSLCN:" + rcn; - xmlRprcRequest.Params.Add(rcn); // Param[4] or Param[5] - } + if (!string.IsNullOrWhiteSpace(request.IHttpClientContext.SSLCommonName)) + xmlRprcRequest.Params.Add("SSLCN:" + request.IHttpClientContext.SSLCommonName); // Param[4] or Param[5] try { @@ -1435,8 +1390,8 @@ public void HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response, catch (Exception e) { string errorMessage = string.Format( - "Requested method [{0}] from {1} threw exception: {2} {3}", - methodName, request.RemoteIPEndPoint.Address, e.Message, e.StackTrace); + "Requested method [{0}] from {1} threw exception: {2}", + methodName, request.RemoteIPEndPoint.Address, e.Message); m_log.ErrorFormat("[BASE HTTP SERVER]: {0}", errorMessage); @@ -1492,10 +1447,10 @@ private void HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse respons jsonRpcResponse.Error.Message = e.Message; } - if (request.InputStream != null && request.InputStream.CanRead) + if (request.InputStream is not null && request.InputStream.CanRead) request.InputStream.Dispose(); - if (jsonRpcRequest != null) + if (jsonRpcRequest is not null) { // If we have no id, then it's a "notification" if (jsonRpcRequest.TryGetValue("id", out OSD val)) @@ -1547,7 +1502,7 @@ private void HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse respons private void HandleLLSDLogin(OSHttpRequest request, OSHttpResponse response) { - if (m_defaultLlsdHandler == null) + if (m_defaultLlsdHandler is null) return; response.StatusCode = (int)HttpStatusCode.BadRequest; @@ -1555,11 +1510,11 @@ private void HandleLLSDLogin(OSHttpRequest request, OSHttpResponse response) try { OSD llsdRequest = OSDParser.DeserializeLLSDXml(request.InputStream); - if (llsdRequest == null || !(llsdRequest is OSDMap)) + if (llsdRequest is not OSDMap) return; OSD llsdResponse = m_defaultLlsdHandler(llsdRequest, request.RemoteIPEndPoint); - if (llsdResponse != null) + if (llsdResponse is not null) { response.ContentType = "application/llsd+xml"; response.RawBuffer = OSDParser.SerializeLLSDXmlBytes(llsdResponse); @@ -1593,7 +1548,7 @@ private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message); } - if (llsdRequest == null) + if (llsdRequest is null) { response.StatusCode = (int)HttpStatusCode.BadRequest; return null; @@ -1609,14 +1564,14 @@ private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response llsdResponse = null; } - if (llsdResponse == null) + if (llsdResponse is null) { response.StatusCode = (int)HttpStatusCode.BadRequest; return null; } byte[] buffer = Array.Empty(); - if (llsdResponse.ToString() == "shutdown404!") + if (llsdResponse.ToString().Equals("shutdown404!")) { response.ContentType = "text/plain"; response.StatusCode = (int)HttpStatusCode.NotFound; @@ -1634,9 +1589,9 @@ private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response return buffer; } - private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, OSD llsdResponse) + private static byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, OSD llsdResponse) { - if (request.AcceptTypes != null && request.AcceptTypes.Length > 0) + if (request.AcceptTypes is not null && request.AcceptTypes.Length > 0) { foreach (string strAccept in request.AcceptTypes) { @@ -1655,7 +1610,7 @@ private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, } } - if (!String.IsNullOrEmpty(request.ContentType)) + if (!string.IsNullOrEmpty(request.ContentType)) { switch (request.ContentType) { @@ -1677,6 +1632,14 @@ private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, return OSDParser.SerializeLLSDXmlBytes(llsdResponse); } + private ReadOnlySpan CleanSearchPath(ReadOnlySpan path) + { + path = path.Trim().TrimEnd('/'); + if (path[0] == '/') + return path; + return ("/" + path.ToString()).AsSpan(); + } + /// /// Checks if we have an Exact path in the LLSD handlers for the path provided /// @@ -1684,38 +1647,22 @@ private byte[] BuildLLSDResponse(OSHttpRequest request, OSHttpResponse response, /// true if we have one, false if not private bool DoWeHaveALLSDHandler(string path) { - string[] pathbase = path.Split('/'); - string searchquery = "/"; - - if (pathbase.Length < 1) - return false; - - for (int i = 1; i < pathbase.Length; i++) + if(m_llsdHandlers.Count == 0) { - searchquery += pathbase[i]; - if (pathbase.Length - 1 != i) - searchquery += "/"; + return false; } - string bestMatch = null; + var searchquery = CleanSearchPath(path.AsSpan()); lock (m_llsdHandlers) { foreach (string pattern in m_llsdHandlers.Keys) { - if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) - bestMatch = pattern; + if (searchquery.Length >= pattern.Length && searchquery.StartsWith(pattern)) + return true; } } - - if (String.IsNullOrEmpty(bestMatch)) - { - return false; - } - else - { - return true; - } + return false; } /// @@ -1725,64 +1672,34 @@ private bool DoWeHaveALLSDHandler(string path) /// true if we have one, false if not private bool DoWeHaveAHTTPHandler(string path) { - string[] pathbase = path.Split('/'); - string searchquery = "/"; - - if (pathbase.Length < 1) - return false; - - for (int i = 1; i < pathbase.Length; i++) - { - searchquery += pathbase[i]; - if (pathbase.Length - 1 != i) - searchquery += "/"; - } - - string bestMatch = null; + var searchquery = CleanSearchPath(path.AsSpan()); //m_log.DebugFormat("[BASE HTTP HANDLER]: Checking if we have an HTTP handler for {0}", searchquery); - lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { - if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) - { - bestMatch = pattern; - } - } - - if (String.IsNullOrEmpty(bestMatch)) - { - return false; - } - else - { - return true; + if (searchquery.Length >= pattern.Length && searchquery.StartsWith(pattern)) + return true; } } + return false; } private bool TryGetLLSDHandler(string path, out LLSDMethod llsdHandler) { - llsdHandler = null; + if(m_llsdHandlers.Count == 0) + { + llsdHandler = null; + return false; + } + // Pull out the first part of the path // splitting the path by '/' means we'll get the following return.. // {0}/{1}/{2} // where {0} isn't something we really control 100% - string[] pathbase = path.Split('/'); - string searchquery = "/"; - - if (pathbase.Length < 1) - return false; - - for (int i=1; i bestMatch.Length) + if (nomatch || searchquery.Length > bestMatch.Length) { - // You have to specifically register for '/' and to get it, you must specificaly request it - // - if (pattern == "/" && searchquery == "/" || pattern != "/") - bestMatch = pattern; + bestMatch = pattern; + nomatch = false; } } } - if (String.IsNullOrEmpty(bestMatch)) + if (nomatch) { llsdHandler = null; return false; } - else + if (bestMatch == "/" && searchquery != "/") { - llsdHandler = m_llsdHandlers[bestMatch]; - return true; + llsdHandler = null; + return false; } + + llsdHandler = m_llsdHandlers[bestMatch]; + return true; } } @@ -1848,8 +1766,6 @@ public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) // to display the form, or process it. // a better way would be nifty. - byte[] buffer; - string requestBody; using(StreamReader reader = new StreamReader(request.InputStream, Encoding.UTF8)) requestBody = reader.ReadToEnd(); @@ -1859,7 +1775,7 @@ public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) Hashtable requestVars = new Hashtable(); - string host = String.Empty; + string host = string.Empty; string[] querystringkeys = request.QueryString.AllKeys; string[] rHeaders = request.Headers.AllKeys; @@ -1871,8 +1787,8 @@ public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) foreach (string queryname in querystringkeys) { -// m_log.DebugFormat( -// "[BASE HTTP SERVER]: Got query paremeter {0}={1}", queryname, request.QueryString[queryname]); + //m_log.DebugFormat( + // "[BASE HTTP SERVER]: Got query paremeter {0}={1}", queryname, request.QueryString[queryname]); if(!string.IsNullOrEmpty(queryname)) { keysvals.Add(queryname, request.QueryString[queryname]); @@ -1882,93 +1798,73 @@ public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) foreach (string headername in rHeaders) { -// m_log.Debug("[BASE HTTP SERVER]: " + headername + "=" + request.Headers[headername]); + //m_log.Debug("[BASE HTTP SERVER]: " + headername + "=" + request.Headers[headername]); headervals[headername] = request.Headers[headername]; } keysvals.Add("headers", headervals); keysvals.Add("querystringkeys", querystringkeys); keysvals.Add("requestvars", requestVars); -// keysvals.Add("form", request.Form); + //keysvals.Add("form", request.Form); Hashtable responsedata2 = requestprocessor(keysvals); - buffer = DoHTTPGruntWork(responsedata2, response); - return buffer; + return DoHTTPGruntWork(responsedata2, response); } private bool TryGetHTTPHandlerPathBased(string path, out GenericHTTPMethod httpHandler) { - httpHandler = null; - // Pull out the first part of the path - // splitting the path by '/' means we'll get the following return.. - // {0}/{1}/{2} - // where {0} isn't something we really control 100% - - string[] pathbase = path.Split('/'); - string searchquery = "/"; - - if (pathbase.Length < 1) - return false; - - for (int i = 1; i < pathbase.Length; i++) + if(m_HTTPHandlers.Count == 0) { - searchquery += pathbase[i]; - if (pathbase.Length - 1 != i) - searchquery += "/"; + httpHandler = null; + return false; } - // while the matching algorithm below doesn't require it, we're expecting a query in the form - // - // [] = optional - // /resource/UUID/action[/action] - // - // now try to get the closest match to the reigstered path - // at least for OGP, registered path would probably only consist of the /resource/ - + var searchquery = CleanSearchPath(path); string bestMatch = null; + bool nomatch = true; -// m_log.DebugFormat( -// "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery); + //m_log.DebugFormat( + // "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery); lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { - if (searchquery.ToLower().StartsWith(pattern.ToLower())) + if (searchquery.StartsWith(pattern, StringComparison.InvariantCultureIgnoreCase)) { - if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) + if (nomatch || searchquery.Length > bestMatch.Length) { - // You have to specifically register for '/' and to get it, you must specifically request it - if (pattern == "/" && searchquery == "/" || pattern != "/") - bestMatch = pattern; + bestMatch = pattern; + nomatch = false; } } } - if (string.IsNullOrEmpty(bestMatch)) + if (nomatch) { httpHandler = null; return false; } - else - { - if (bestMatch == "/" && searchquery != "/") - return false; - httpHandler = m_HTTPHandlers[bestMatch]; - return true; + if (bestMatch == "/" && searchquery != "/") + { + httpHandler = null; + return false; } + + httpHandler = m_HTTPHandlers[bestMatch]; + return true; } } - internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) + internal static byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) { int responsecode; - string responseString = String.Empty; + string responseString = string.Empty; byte[] responseData = null; string contentType; - if (responsedata == null) + if (responsedata is null) { responsecode = 500; responseString = "No response could be obtained"; @@ -1981,13 +1877,11 @@ internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) { //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); responsecode = (int)responsedata["int_response_code"]; - if (responsedata["bin_response_data"] != null) - responseData = (byte[])responsedata["bin_response_data"]; + contentType = (string)responsedata["content_type"]; + if (responsedata["bin_response_data"] is byte[] b) + responseData = b; else responseString = (string)responsedata["str_response_string"]; - contentType = (string)responsedata["content_type"]; - if (responseString == null) - responseString = String.Empty; } catch { @@ -1999,13 +1893,10 @@ internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) } if (responsedata.ContainsKey("error_status_text")) - { response.StatusDescription = (string)responsedata["error_status_text"]; - } + if (responsedata.ContainsKey("http_protocol_version")) - { response.ProtocolVersion = (string)responsedata["http_protocol_version"]; - } if (responsedata.ContainsKey("keepalive")) { @@ -2045,12 +1936,15 @@ internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) byte[] buffer; - if (responseData != null) + if (responseData is not null) { buffer = responseData; } else { + if(string.IsNullOrEmpty(responseString)) + return null; + if (!(contentType.Contains("image") || contentType.Contains("x-shockwave-flash") || contentType.Contains("application/x-oar") @@ -2064,11 +1958,9 @@ internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) // Binary! buffer = Convert.FromBase64String(responseString); } - response.ContentLength64 = buffer.Length; response.ContentEncoding = Encoding.UTF8; } - return buffer; } @@ -2100,14 +1992,11 @@ public void Start() /// public void Start(bool performPollResponsesAsync, bool runPool) { - m_log.InfoFormat( - "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); + m_log.Info($"[BASE HTTP SERVER]: Starting HTTP{(UseSSL ? "S" : "")} server on port {Port}"); try { //m_httpListener = new HttpListener(); - - NotSocketErrors = 0; if (!m_ssl) { m_httpListener = tinyHTTPListener.Create(m_listenIPAddress, (int)m_port); @@ -2124,7 +2013,7 @@ public void Start(bool performPollResponsesAsync, bool runPool) else { m_httpListener = tinyHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); - if(m_certificateValidationCallback != null) + if(m_certificateValidationCallback is not null) m_httpListener.CertificateValidationCallback = m_certificateValidationCallback; m_httpListener.ExceptionThrown += httpServerException; if (DebugLevel > 0) @@ -2141,8 +2030,7 @@ public void Start(bool performPollResponsesAsync, bool runPool) { if (runPool) { - if(m_pollServiceManager == null) - m_pollServiceManager = new PollServiceRequestManager(performPollResponsesAsync, 2, 25000); + m_pollServiceManager ??= new PollServiceRequestManager(performPollResponsesAsync, 2, 25000); m_pollServiceManager.Start(); } } @@ -2174,20 +2062,9 @@ public void Start(bool performPollResponsesAsync, bool runPool) StatsManager.RegisterStat(m_requestsProcessedStat); } - public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) + public static void httpServerException(object source, Exception exception) { - switch (err) - { - case SocketError.NotSocket: - NotSocketErrors++; - - break; - } - } - - public void httpServerException(object source, Exception exception) - { - if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) + if (source.ToString().Equals("HttpServer.HttpListener") && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) return; m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); } @@ -2221,34 +2098,35 @@ public void Stop(bool stopPool = false) public void RemoveStreamHandler(string httpMethod, string path) { - if (m_streamHandlers.TryRemove(path, out IRequestHandler dummy)) + if (m_streamHandlers.TryRemove(path, out _)) return; string handlerKey = GetHandlerKey(httpMethod, path); //m_log.DebugFormat("[BASE HTTP SERVER]: Removing handler key {0}", handlerKey); - m_streamHandlers.TryRemove(handlerKey, out dummy); + m_streamHandlers.TryRemove(handlerKey, out _); } public void RemoveStreamHandler(string path) { - m_streamHandlers.TryRemove(path, out IRequestHandler dummy); + m_streamHandlers.TryRemove(path, out IRequestHandler _); } public void RemoveSimpleStreamHandler(string path) { - if(m_simpleStreamHandlers.TryRemove(path, out ISimpleStreamHandler dummy)) + if(m_simpleStreamHandlers.TryRemove(path, out _)) return; - m_simpleStreamVarPath.TryRemove(path, out ISimpleStreamHandler dummy2); + m_simpleStreamVarPath.TryRemove(path, out _); } public void RemoveHTTPHandler(string httpMethod, string path) { - if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null + if (string.IsNullOrEmpty(path)) + return; // Caps module isn't loaded, tries to remove handler where path = null lock (m_HTTPHandlers) { - if (httpMethod != null && httpMethod.Length == 0) + if (httpMethod is not null && httpMethod.Length == 0) { m_HTTPHandlers.Remove(path); return; @@ -2260,14 +2138,14 @@ public void RemoveHTTPHandler(string httpMethod, string path) public void RemovePollServiceHTTPHandler(string httpMethod, string path) { - if(!m_pollHandlers.TryRemove(path, out PollServiceEventArgs dummy)) - m_pollHandlersVarPath.TryRemove(path, out PollServiceEventArgs dummy2); + if(!m_pollHandlers.TryRemove(path, out _)) + m_pollHandlersVarPath.TryRemove(path, out _); } public void RemovePollServiceHTTPHandler(string path) { - if(!m_pollHandlers.TryRemove(path, out PollServiceEventArgs dummy)) - m_pollHandlersVarPath.TryRemove(path, out PollServiceEventArgs dummy2); + if(!m_pollHandlers.TryRemove(path, out _)) + m_pollHandlersVarPath.TryRemove(path, out _); } //public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) @@ -2301,9 +2179,7 @@ public bool RemoveLLSDHandler(string path, LLSDMethod handler) { lock (m_llsdHandlers) { - LLSDMethod foundHandler; - - if (m_llsdHandlers.TryGetValue(path, out foundHandler) && foundHandler == handler) + if (m_llsdHandlers.TryGetValue(path, out LLSDMethod foundHandler) && foundHandler == handler) { m_llsdHandlers.Remove(path); return true; @@ -2410,7 +2286,7 @@ public void Write(object source, LogPrio priority, string message) public class IndexPHPHandler : SimpleStreamHandler { - BaseHttpServer m_server; + readonly BaseHttpServer m_server; public IndexPHPHandler(BaseHttpServer server) : base("/index.php") @@ -2421,7 +2297,7 @@ public IndexPHPHandler(BaseHttpServer server) protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.KeepAlive = false; - if (m_server == null || !m_server.HTTPDRunning) + if (m_server is null || !m_server.HTTPDRunning) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; @@ -2434,17 +2310,19 @@ protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpRespon } if (httpRequest.QueryFlags.Contains("about")) { - httpResponse.Redirect("http://opensimulator.org/wiki/0.9.2.2_Release"); + httpResponse.Redirect("http://opensimulator.org/wiki/0.9.3.0_Release"); return; } - if (!httpRequest.QueryAsDictionary.TryGetValue("method", out string methods) || string.IsNullOrWhiteSpace(methods)) + if (!httpRequest.QueryAsDictionary.TryGetValue("method", out string method) || string.IsNullOrWhiteSpace(method)) { - httpResponse.StatusCode = (int)HttpStatusCode.NotFound; ; + httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } - string[] splited = methods.Split(new char[] { ',' }); - string method = splited[0]; + int indx = method.IndexOf(','); + if(indx > 0) + method = method[..indx]; + if (string.IsNullOrWhiteSpace(method)) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; @@ -2452,7 +2330,7 @@ protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpRespon } SimpleStreamMethod sh = m_server.TryGetIndexPHPMethodHandler(method); - if (sh == null) + if (sh is null) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs index 62558f2b572..2f75276b987 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs @@ -43,7 +43,6 @@ public interface IOSHttpRequest long ContentLength { get; } long ContentLength64 { get; } string ContentType { get; } - HttpCookieCollection Cookies { get; } bool HasEntityBody { get; } NameValueCollection Headers { get; } string HttpMethod { get; } diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index c615961d9f3..4bd3a82b923 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs @@ -68,28 +68,30 @@ public JsonRpcRequestManager() /// public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId) { - if (jsonId == null) + if (jsonId is null) throw new ArgumentNullException("jsonId"); - if (uri == null) + if (uri is null) throw new ArgumentNullException("uri"); - if (method == null) + if (method is null) throw new ArgumentNullException("method"); - if (parameters == null) + if (parameters is null) throw new ArgumentNullException("parameters"); if(string.IsNullOrWhiteSpace(uri)) return false; - OSDMap request = new OSDMap(); - request.Add("jsonrpc", OSD.FromString("2.0")); - request.Add("id", OSD.FromString(jsonId)); - request.Add("method", OSD.FromString(method)); - request.Add("params", OSD.SerializeMembers(parameters)); + OSDMap request = new() + { + { "jsonrpc", OSD.FromString("2.0") }, + { "id", OSD.FromString(jsonId) }, + { "method", OSD.FromString(method) }, + { "params", OSD.SerializeMembers(parameters) } + }; - OSDMap response; + OSDMap outerResponse; try { - response = WebUtil.PostToService(uri, request, 10000, true); + outerResponse = WebUtil.PostToService(uri, request, 10000, true); } catch (Exception e) { @@ -98,14 +100,13 @@ public bool JsonRpcRequest(ref object parameters, string method, string uri, str } OSD osdtmp; - if (!response.TryGetValue("_Result", out osdtmp) || !(osdtmp is OSDMap)) + if (!outerResponse.TryGetValue("_Result", out osdtmp) || (osdtmp is not OSDMap response)) { m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", - method, uri, OSDParser.SerializeJsonString(response)); + method, uri, OSDParser.SerializeJsonString(outerResponse)); return false; } - response = osdtmp as OSDMap; if (response.TryGetValue("error", out osdtmp)) { m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", @@ -113,14 +114,14 @@ public bool JsonRpcRequest(ref object parameters, string method, string uri, str return false; } - if (!response.TryGetValue("result", out osdtmp) || !(osdtmp is OSDMap)) + if (!response.TryGetValue("result", out osdtmp) || (osdtmp is not OSDMap resultmap)) { m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", method, uri, OSDParser.SerializeJsonString(response)); return false; } - OSD.DeserializeMembers(ref parameters, (OSDMap)osdtmp); + OSD.DeserializeMembers(ref parameters, resultmap); return true; } @@ -147,16 +148,18 @@ public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonI if (string.IsNullOrEmpty(jsonId)) jsonId = UUID.Random().ToString(); - OSDMap request = new OSDMap(); - request.Add("jsonrpc", OSD.FromString("2.0")); - request.Add("id", OSD.FromString(jsonId)); - request.Add("method", OSD.FromString(method)); - request.Add("params", data); + OSDMap request = new() + { + { "jsonrpc", OSD.FromString("2.0") }, + { "id", OSD.FromString(jsonId) }, + { "method", OSD.FromString(method) }, + { "params", data } + }; - OSDMap response; + OSDMap outerresponse; try { - response = WebUtil.PostToService(uri, request, 10000, true); + outerresponse = WebUtil.PostToService(uri, request, 10000, true); } catch (Exception e) { @@ -165,13 +168,12 @@ public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonI } OSD osdtmp; - if (!response.TryGetValue("_Result", out osdtmp) || !(osdtmp is OSDMap)) + if (!outerresponse.TryGetValue("_Result", out osdtmp) || (osdtmp is not OSDMap response)) { m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", - method, uri, OSDParser.SerializeJsonString(response)); + method, uri, OSDParser.SerializeJsonString(outerresponse)); return false; } - response = osdtmp as OSDMap; if (response.TryGetValue("error", out osdtmp)) { diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index f3487d8b9a2..7510e04469a 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -33,99 +33,97 @@ using System.Net; using System.Reflection; using System.Text; -using System.Web; using OSHttpServer; using log4net; +using System.Runtime.CompilerServices; + namespace OpenSim.Framework.Servers.HttpServer { public class OSHttpRequest : IOSHttpRequest { - private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected IHttpRequest m_request = null; - protected IHttpClientContext m_context = null; + protected readonly IHttpRequest m_request = null; public string[] AcceptTypes { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.AcceptTypes; } } public Encoding ContentEncoding { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_contentEncoding; } } private Encoding m_contentEncoding; public long ContentLength { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.ContentLength; } } public long ContentLength64 { - get { return ContentLength; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return m_request.ContentLength; } } public string ContentType { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_contentType; } } private string m_contentType; - public HttpCookieCollection Cookies - { - get - { - RequestCookies cookies = m_request.Cookies; - HttpCookieCollection httpCookies = new HttpCookieCollection(); - if(cookies != null) - { - foreach (RequestCookie cookie in cookies) - httpCookies.Add(new HttpCookie(cookie.Name, cookie.Value)); - } - return httpCookies; - } - } - public bool HasEntityBody { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.ContentLength != 0; } } public NameValueCollection Headers { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.Headers; } } public string HttpMethod { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.Method; } } public Stream InputStream { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.Body; } } public bool IsSecured { - get { return m_context.IsSecured; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return m_request.Context.IsSecured; } } public bool KeepAlive { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ConnectionType.KeepAlive == m_request.Connection; } } public NameValueCollection QueryString { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.QueryString;} } private Hashtable m_queryAsHashtable = null; public Hashtable Query { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (m_queryAsHashtable == null) @@ -138,6 +136,7 @@ public Hashtable Query private Dictionary _queryAsDictionay = null; public Dictionary QueryAsDictionary { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (_queryAsDictionay == null) @@ -149,6 +148,7 @@ public Dictionary QueryAsDictionary private HashSet m_queryFlags = null; public HashSet QueryFlags { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (m_queryFlags == null) @@ -163,48 +163,57 @@ public HashSet QueryFlags public string RawUrl { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.Uri.AbsolutePath; } } public IPEndPoint RemoteIPEndPoint { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.RemoteIPEndPoint; } } public IPEndPoint LocalIPEndPoint { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.LocalIPEndPoint; } } public Uri Url { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.Uri; } } public string UriPath { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.UriPath; } } public string UserAgent { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_userAgent; } } private string m_userAgent; public double ArrivalTS { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request.ArrivalTS;} } internal IHttpRequest IHttpRequest { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_request; } } internal IHttpClientContext IHttpClientContext { - get { return m_context; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return m_request.Context; } } /// @@ -213,6 +222,7 @@ internal IHttpClientContext IHttpClientContext /// internal Dictionary Whiteboard { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return _whiteboard; } } private Dictionary _whiteboard = new Dictionary(); @@ -222,7 +232,6 @@ public OSHttpRequest() {} public OSHttpRequest(IHttpRequest req) { m_request = req; - m_context = req.Context; if (null != req.Headers["content-encoding"]) { @@ -241,12 +250,12 @@ public OSHttpRequest(IHttpRequest req) if (null != req.Headers["user-agent"]) m_userAgent = req.Headers["user-agent"]; -// Form = new Hashtable(); -// foreach (HttpInputItem item in req.Form) -// { -// _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value); -// Form.Add(item.Name, item.Value); -// } + //Form = new Hashtable(); + //foreach (HttpInputItem item in req.Form) + //{ + // _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value); + // Form.Add(item.Name, item.Value); + //} } private void BuildQueryDictionary() @@ -254,7 +263,7 @@ private void BuildQueryDictionary() NameValueCollection q = m_request.QueryString; _queryAsDictionay = new Dictionary(); m_queryFlags = new HashSet(); - for(int i = 0; i public virtual string ContentType { - get - { - return _httpResponse.ContentType; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.ContentType; } - set - { - _httpResponse.ContentType = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.ContentType = value; } } /// @@ -77,15 +74,11 @@ public virtual string ContentType /// public long ContentLength { - get - { - return _httpResponse.ContentLength; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.ContentLength; } - set - { - _httpResponse.ContentLength = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.ContentLength = value; } } /// @@ -93,7 +86,10 @@ public long ContentLength /// public long ContentLength64 { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ContentLength; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] set { ContentLength = value; } } @@ -102,31 +98,20 @@ public long ContentLength64 /// public Encoding ContentEncoding { - get - { - return _httpResponse.Encoding; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Encoding; } - set - { - _httpResponse.Encoding = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Encoding = value; } } public bool KeepAlive { - get - { - return _httpResponse.Connection == ConnectionType.KeepAlive; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Connection == ConnectionType.KeepAlive; } - set - { - if (value) - _httpResponse.Connection = ConnectionType.KeepAlive; - else - _httpResponse.Connection = ConnectionType.Close; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Connection = value ? ConnectionType.KeepAlive : ConnectionType.Close; } } /// @@ -136,11 +121,10 @@ public bool KeepAlive /// public int KeepAliveTimeout { - get - { - return _httpResponse.KeepAlive; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.KeepAlive; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] set { if (value == 0) @@ -148,7 +132,6 @@ public int KeepAliveTimeout _httpResponse.Connection = ConnectionType.Close; _httpResponse.KeepAlive = 0; } - else { _httpResponse.Connection = ConnectionType.KeepAlive; @@ -165,23 +148,17 @@ public int KeepAliveTimeout /// public Stream OutputStream { - get - { - return _httpResponse.Body; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Body; } } public string ProtocolVersion { - get - { - return _httpResponse.ProtocolVersion; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.ProtocolVersion; } - set - { - _httpResponse.ProtocolVersion = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.ProtocolVersion = value; } } /// @@ -189,58 +166,44 @@ public string ProtocolVersion /// public Stream Body { - get - { - return _httpResponse.Body; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Body; } } public byte[] RawBuffer { - get - { - return _httpResponse.RawBuffer; - } - set - { - _httpResponse.RawBuffer = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.RawBuffer; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.RawBuffer = value; } } public int RawBufferStart { - get - { - return _httpResponse.RawBufferStart; - } - set - { - _httpResponse.RawBufferStart = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.RawBufferStart; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.RawBufferStart = value; } } public int RawBufferLen { - get - { - return _httpResponse.RawBufferLen; - } - set - { - _httpResponse.RawBufferLen = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.RawBufferLen; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.RawBufferLen = value; } } public int Priority { - get - { - return _httpResponse.Priority; - } - set - { - _httpResponse.Priority = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Priority; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Priority = value; } } /// @@ -248,15 +211,11 @@ public int Priority /// public bool SendChunked { - get - { - return _httpResponse.Chunked; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Chunked; } - set - { - _httpResponse.Chunked = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Chunked = value; } } /// @@ -264,20 +223,17 @@ public bool SendChunked /// public virtual int StatusCode { - get - { - return (int)_httpResponse.Status; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return (int)_httpResponse.Status; } - set - { - _httpResponse.Status = (HttpStatusCode)value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Status = (HttpStatusCode)value; } } public double RequestTS { - get {return _httpResponse.RequestTS; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.RequestTS; } } /// @@ -285,18 +241,14 @@ public double RequestTS /// public string StatusDescription { - get - { - return _httpResponse.Reason; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get { return _httpResponse.Reason; } - set - { - _httpResponse.Reason = value; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + set { _httpResponse.Reason = value; } } - protected IHttpResponse _httpResponse; + protected readonly IHttpResponse _httpResponse; public OSHttpResponse() {} @@ -326,6 +278,7 @@ public OSHttpResponse(HttpResponse resp) /// /// redirection target url /// the response Status, must be Found, Redirect, Moved,MovedPermanently,RedirectKeepVerb, RedirectMethod, TemporaryRedirect. Defaults to Redirect + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Redirect(string url, HttpStatusCode redirStatusCode = HttpStatusCode.Redirect) { _httpResponse.Redirect(url, redirStatusCode); @@ -338,6 +291,7 @@ public void Redirect(string url, HttpStatusCode redirStatusCode = HttpStatusCode /// name /// string containing the header field /// value + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddHeader(string key, string value) { _httpResponse.AddHeader(key, value); @@ -346,6 +300,7 @@ public void AddHeader(string key, string value) /// /// Send the response back to the remote client /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Send() { _httpResponse.Chunked = false; diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/BodyEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/BodyEventArgs.cs index 91dec7945ab..a1ed60056ac 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/BodyEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/BodyEventArgs.cs @@ -3,53 +3,23 @@ namespace OSHttpServer.Parser { /// - /// Arguments used when more body bytes have come. + /// Arguments used when body bytes have come. /// public class BodyEventArgs : EventArgs { /// - /// Initializes a new instance of the class. + /// Gets or sets buffer that contains the received bytes. /// - /// buffer that contains the received bytes. - /// offset in buffer where to start processing. - /// number of bytes from that should be parsed. - public BodyEventArgs(byte[] buffer, int offset, int count) - { - Buffer = buffer; - Offset = offset; - Count = count; - } + public byte[] Buffer; /// - /// Initializes a new instance of the class. + /// number of bytes from that should be parsed. /// - public BodyEventArgs() - { - } + public int Count; /// - /// Gets or sets buffer that contains the received bytes. - /// - public byte[] Buffer { get; set; } - /* - /// - /// Gets or sets number of bytes used by the request. - /// - public int BytesUsed { get; set; } - */ - /// - /// Gets or sets number of bytes from that should be parsed. - /// - public int Count { get; set; } - /* - /// - /// Gets or sets whether the body is complete. - /// - public bool IsBodyComplete { get; set; } - */ - /// - /// Gets or sets offset in buffer where to start processing. + /// offset in buffer where to start processing. /// - public int Offset { get; set; } + public int Offset; } } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ContextTimeoutManager.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ContextTimeoutManager.cs index e2c3dc21391..dbf0c2d596d 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ContextTimeoutManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ContextTimeoutManager.cs @@ -43,12 +43,12 @@ public static class ContextTimeoutManager /// Use a Thread or a Timer to monitor the ugly /// private static Thread m_internalThread = null; - private static object m_threadLock = new object(); - private static ConcurrentQueue m_contexts = new ConcurrentQueue(); - private static ConcurrentQueue m_highPrio = new ConcurrentQueue(); - private static ConcurrentQueue m_midPrio = new ConcurrentQueue(); - private static ConcurrentQueue m_lowPrio = new ConcurrentQueue(); - private static AutoResetEvent m_processWaitEven = new AutoResetEvent(false); + private static readonly object m_threadLock = new(); + private static readonly ConcurrentQueue m_contexts = new(); + private static readonly ConcurrentQueue m_highPrio = new(); + private static readonly ConcurrentQueue m_midPrio = new(); + private static readonly ConcurrentQueue m_lowPrio = new(); + private static AutoResetEvent m_processWaitEven = new(false); private static bool m_shuttingDown; private static int m_ActiveSendingCount; @@ -100,7 +100,7 @@ private static void ThreadRunProcess() break; double now = GetTimeStamp(); - if(m_contexts.Count > 0) + if(!m_contexts.IsEmpty) { ProcessSendQueues(); diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HeaderEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HeaderEventArgs.cs index 23a57e97e2b..35bb894d3d8 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HeaderEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HeaderEventArgs.cs @@ -9,24 +9,6 @@ namespace OSHttpServer.Parser public class HeaderEventArgs : EventArgs { public osUTF8Slice Name; - public string Value; - - /// - /// Initializes a new instance of the class. - /// - public HeaderEventArgs() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// Name of header. - /// Header value. - public HeaderEventArgs(osUTF8Slice name, string value) - { - Name = name; - Value = value; - } + public osUTF8Slice Value; } } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs index cf636cede5d..5d5682fefc9 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpClientContext.cs @@ -26,7 +26,7 @@ public class HttpClientContext : IHttpClientContext, IDisposable static private int basecontextID; Queue m_requests; - object m_requestsLock = new object(); + readonly object m_requestsLock = new(); public int m_maxRequests = MAXREQUESTS; public bool m_waitingResponse; @@ -130,10 +130,10 @@ public HttpClientContext(bool secured, IPEndPoint remoteEndPoint, { SslStream _ssl = (SslStream)m_stream; X509Certificate _cert1 = _ssl.RemoteCertificate; - if (_cert1 != null) + if (_cert1 is not null) { - X509Certificate2 _cert2 = new X509Certificate2(_cert1); - if (_cert2 != null) + X509Certificate2 _cert2 = new(_cert1); + if (_cert2 is not null) SSLCommonName = _cert2.GetNameInfo(X509NameType.SimpleName, false); } } @@ -150,7 +150,7 @@ public bool CanSend() if (contextID < 0 || m_isClosing) return false; - if (m_stream == null || m_sock == null || !m_sock.Connected) + if (m_stream is null || m_sock is null || !m_sock.Connected) return false; return true; @@ -182,14 +182,14 @@ protected virtual void OnHeaderReceived(object sender, HeaderEventArgs e) Respond("HTTP/1.1", HttpStatusCode.Continue, null); } } - m_currentRequest.AddHeader(e.Name.ToString(), e.Value); + m_currentRequest.AddHeader(e.Name.ToString(), e.Value.ToString()); } private void OnRequestLine(object sender, RequestLineEventArgs e) { - m_currentRequest.Method = e.HttpMethod; - m_currentRequest.HttpVersion = e.HttpVersion; - m_currentRequest.UriPath = e.UriPath; + m_currentRequest.Method = e.HttpMethod.ToString(); + m_currentRequest.HttpVersion = e.HttpVersion.ToString(); + m_currentRequest.UriPath = e.UriPath.ToString(); m_currentRequest.AddHeader("remote_addr", LocalIPEndPoint.Address.ToString()); m_currentRequest.AddHeader("remote_port", LocalIPEndPoint.Port.ToString()); m_currentRequest.ArrivalTS = ContextTimeoutManager.GetTimeStamp(); @@ -212,7 +212,7 @@ public virtual void Start() { m_stream.BeginRead(m_ReceiveBuffer, 0, m_ReceiveBuffer.Length, OnReceive, null); } - catch (IOException err) + catch (Exception err) { LogWriter.Write(this, LogPrio.Debug, err.ToString()); } @@ -230,7 +230,7 @@ public virtual void Cleanup() contextID = -100; - if (m_stream != null) + if (m_stream is not null) { m_stream.Close(); m_stream = null; @@ -322,7 +322,7 @@ public void Disconnect(SocketError error) { try { - if (m_stream != null) + if (m_stream is not null) { if (error == SocketError.Success) { @@ -353,7 +353,7 @@ private void OnReceive(IAsyncResult ar) try { int bytesRead = 0; - if (m_stream == null) + if (m_stream is null) return; try { @@ -377,24 +377,24 @@ private void OnReceive(IAsyncResult ar) m_ReceiveBytesLeft += bytesRead; int offset = m_parser.Parse(m_ReceiveBuffer, 0, m_ReceiveBytesLeft); - if (m_stream == null) + if (m_stream is null) return; // "Connection: Close" in effect. - while (offset != 0) + if(offset > 0) { - int nextBytesleft = m_ReceiveBytesLeft - offset; - if (nextBytesleft <= 0) - break; - - int nextOffset = m_parser.Parse(m_ReceiveBuffer, offset, nextBytesleft); + int nextBytesleft, nextOffset; + while ((nextBytesleft = m_ReceiveBytesLeft - offset) > 0) + { + nextOffset = m_parser.Parse(m_ReceiveBuffer, offset, nextBytesleft); - if (m_stream == null) - return; // "Connection: Close" in effect. + if (m_stream is null) + return; // "Connection: Close" in effect. - if (nextOffset == 0) - break; + if (nextOffset == 0) + break; - offset = nextOffset; + offset = nextOffset; + } } // copy unused bytes to the beginning of the array @@ -437,8 +437,8 @@ private void OnReceive(IAsyncResult ar) catch (IOException err) { LogWriter.Write(this, LogPrio.Debug, "Failed to end receive: " + err.Message); - if (err.InnerException is SocketException) - Disconnect((SocketError)((SocketException)err.InnerException).ErrorCode); + if (err.InnerException is SocketException exception) + Disconnect((SocketError)exception.ErrorCode); else Disconnect(SocketError.ConnectionReset); } @@ -466,18 +466,18 @@ private void OnRequestCompleted(object source, EventArgs args) FullRequestReceived = true; LastActivityTimeMS = ContextTimeoutManager.EnvironmentTickCount(); - if (m_maxRequests <= 0 || RequestReceived == null) + if (m_maxRequests <= 0 || RequestReceived is null) return; if (--m_maxRequests == 0) m_currentRequest.Connection = ConnectionType.Close; - if(m_currentRequest.Uri == null) + if(m_currentRequest.Uri is null) { // should not happen try { - Uri uri = new Uri(m_currentRequest.Secure ? "https://" : "http://" + m_currentRequest.UriPath); + Uri uri = new(m_currentRequest.Secure ? "https://" : "http://" + m_currentRequest.UriPath); m_currentRequest.Uri = uri; m_currentRequest.UriPath = uri.AbsolutePath; } @@ -488,7 +488,7 @@ private void OnRequestCompleted(object source, EventArgs args) } // load cookies if they exist - if(m_currentRequest.Headers["cookie"] != null) + if(m_currentRequest.Headers["cookie"] is not null) m_currentRequest.SetCookies(new RequestCookies(m_currentRequest.Headers["cookie"])); m_currentRequest.Body.Seek(0, SeekOrigin.Begin); @@ -519,7 +519,7 @@ public void StartSendResponse(HttpResponse response) public bool TrySendResponse(int bytesLimit) { - if (m_currentResponse == null) + if (m_currentResponse is null) return false; try { @@ -540,7 +540,7 @@ public bool TrySendResponse(int bytesLimit) public void ContinueSendResponse() { - if(m_currentResponse == null) + if(m_currentResponse is null) return; LastActivityTimeMS = ContextTimeoutManager.EnvironmentTickCount(); ContextTimeoutManager.EnqueueSend(this, m_currentResponse.Priority); @@ -566,16 +566,16 @@ public void EndSendResponse(uint requestID, ConnectionType ctype) } else { - if (Stream == null || !Stream.CanWrite) + if (Stream is null || !Stream.CanWrite) return; LastActivityTimeMS = ContextTimeoutManager.EnvironmentTickCount(); HttpRequest nextRequest = null; lock (m_requestsLock) { - if (m_requests != null && m_requests.Count > 0) + if (m_requests is not null && m_requests.Count > 0) nextRequest = m_requests.Dequeue(); - if (nextRequest != null && RequestReceived != null) + if (nextRequest is not null && RequestReceived is not null) { m_waitingResponse = true; TriggerKeepalive = false; @@ -583,7 +583,7 @@ public void EndSendResponse(uint requestID, ConnectionType ctype) else TriggerKeepalive = true; } - if (nextRequest != null) + if (nextRequest is not null) RequestReceived?.Invoke(this, new RequestEventArgs(nextRequest)); } ContextTimeoutManager.PulseWaitSend(); @@ -641,7 +641,7 @@ public void Respond(string httpVersion, HttpStatusCode statusCode, string reason /// public bool Send(byte[] buffer) { - if (buffer == null) + if (buffer is null) throw new ArgumentNullException("buffer"); return Send(buffer, 0, buffer.Length); } @@ -655,11 +655,11 @@ public bool Send(byte[] buffer) /// /// - private object sendLock = new object(); + private readonly object sendLock = new(); public bool Send(byte[] buffer, int offset, int size) { - if (m_stream == null || m_sock == null || !m_sock.Connected) + if (m_stream is null || m_sock is null || !m_sock.Connected) return false; if (offset + size > buffer.Length) @@ -682,7 +682,7 @@ public bool Send(byte[] buffer, int offset, int size) } ContextTimeoutManager.ContextLeaveActiveSend(); - if (!ok && m_stream != null) + if (!ok && m_stream is not null) Disconnect(SocketError.NoRecovery); return ok; } @@ -693,14 +693,15 @@ private void SendAsyncEnd(IAsyncResult res) try { m_stream.EndWrite(res); + ContextTimeoutManager.ContextLeaveActiveSend(); - didleave = true; m_currentResponse.CheckSendNextAsyncContinue(); + didleave = true; } catch (Exception e) { e.GetHashCode(); - if (m_stream != null) + if (m_stream is not null) Disconnect(SocketError.NoRecovery); } if(!didleave) @@ -709,7 +710,7 @@ private void SendAsyncEnd(IAsyncResult res) public bool SendAsyncStart(byte[] buffer, int offset, int size) { - if (m_stream == null || m_sock == null || !m_sock.Connected) + if (m_stream is null || m_sock is null || !m_sock.Connected) return false; if (offset + size > buffer.Length) @@ -728,7 +729,7 @@ public bool SendAsyncStart(byte[] buffer, int offset, int size) ok = false; } - if (!ok && m_stream != null) + if (!ok && m_stream is not null) Disconnect(SocketError.NoRecovery); return ok; } @@ -758,7 +759,7 @@ public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing() m_currentRequest = null; m_currentResponse?.Clear(); m_currentResponse = null; - if (m_requests != null) + if (m_requests is not null) { while (m_requests.Count > 0) { diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs index e6f4bd7c9da..eed59510aaa 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpContextFactory.cs @@ -15,7 +15,7 @@ namespace OSHttpServer /// public class HttpContextFactory : IHttpContextFactory { - private readonly ConcurrentDictionary m_activeContexts = new ConcurrentDictionary(); + private readonly ConcurrentDictionary m_activeContexts = new(); private readonly ILogWriter m_logWriter; /// diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInput.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInput.cs index e4701903a3c..939377158bb 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInput.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInput.cs @@ -11,8 +11,8 @@ namespace OSHttpServer public class HttpInput : IHttpInput { /// Representation of a non-initialized class instance - public static readonly HttpInput Empty = new HttpInput("Empty", true); - private readonly IDictionary _items = new Dictionary(); + public static readonly HttpInput Empty = new("Empty", true); + private readonly Dictionary _items = new(); private string _name; /// Variable telling the class that it is non-initialized @@ -70,7 +70,7 @@ public string Name /// Cannot add stuff to . public void Add(string name, string value) { - if (name == null) + if (name is null) throw new ArgumentNullException("name"); if (_ignoreChanges) throw new InvalidOperationException("Cannot add stuff to HttpInput.Empty."); @@ -80,16 +80,19 @@ public void Add(string name, string value) int pos = name.IndexOf('['); if (pos != -1) { - string name1 = name.Substring(0, pos); + string name1 = name[..pos]; string name2 = ExtractOne(name); - if (!_items.ContainsKey(name1)) - _items.Add(name1, new HttpInputItem(name1, null)); - _items[name1].Add(name2, value); + if (!_items.TryGetValue(name1, out HttpInputItem it)) + { + it = new HttpInputItem(name1, null); + _items.Add(name1, it); + } + it.Add(name2, value); } else { - if (_items.ContainsKey(name)) - _items[name].Add(value); + if (_items.TryGetValue(name, out HttpInputItem it)) + it.Add(value); else _items.Add(name, new HttpInputItem(name, value)); } @@ -115,7 +118,7 @@ public HttpInputItem this[string name] /// True if the value exists public bool Contains(string name) { - return _items.ContainsKey(name) && _items[name].Value != null; + return _items.TryGetValue(name, out HttpInputItem it) && it.Value is not null; } /// @@ -134,10 +137,12 @@ public static HttpInputItem ParseItem(string name, string value) int pos = name.IndexOf('['); if (pos != -1) { - string name1 = name.Substring(0, pos); + string name1 = name[..pos]; string name2 = ExtractOne(name); - item = new HttpInputItem(name1, null); - item.Add(name2, value); + item = new HttpInputItem(name1, null) + { + { name2, value } + }; } else item = new HttpInputItem(name, value); @@ -166,7 +171,7 @@ public string ToString(bool asQueryString) foreach (KeyValuePair item in _items) temp += item.Value.ToString(null, true) + '&'; - return temp.Length > 0 ? temp.Substring(0, temp.Length - 1) : string.Empty; + return temp.Length > 0 ? temp[..^1] : string.Empty; } /// @@ -190,7 +195,7 @@ public static string ExtractOne(string value) ++pos; int gotMore = value.IndexOf('[', pos + 1); if (gotMore != -1) - value = value.Substring(pos, gotMore - pos - 1) + value.Substring(gotMore); + value = string.Concat(value.AsSpan(pos, gotMore - pos - 1), value.AsSpan(gotMore)); else value = value.Substring(pos, value.Length - pos - 1); } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInputItem.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInputItem.cs index 2172c7da520..8ca7cde52b8 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInputItem.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpInputItem.cs @@ -18,9 +18,9 @@ namespace OSHttpServer public class HttpInputItem : IHttpInput { /// Representation of a non-initialized . - public static readonly HttpInputItem Empty = new HttpInputItem(string.Empty, true); + public static readonly HttpInputItem Empty = new(string.Empty, true); private readonly IDictionary _items = new Dictionary(); - private readonly List _values = new List(); + private readonly List _values = new(); private string _name; private readonly bool _ignoreChanges; @@ -71,8 +71,9 @@ public int Count /// if no item was found. public HttpInputItem this[string name] { - get { - return _items.ContainsKey(name) ? _items[name] : Empty; + get + { + return _items.TryGetValue(name, out HttpInputItem hii) ? hii : Empty; } } @@ -109,7 +110,7 @@ public string LastValue { get { - return _values.Count == 0 ? null : _values[_values.Count - 1]; + return _values.Count == 0 ? null : _values[^1]; } } @@ -129,7 +130,7 @@ public IList Values /// Cannot add stuff to . public void Add(string value) { - if (value == null) + if (value is null) return; if (_ignoreChanges) throw new InvalidOperationException("Cannot add stuff to HttpInput.Empty."); @@ -144,7 +145,7 @@ public void Add(string value) /// true if the sub-item exists and has a value; otherwise false. public bool Contains(string name) { - return _items.ContainsKey(name) && _items[name].Value != null; + return _items.TryGetValue(name, out HttpInputItem hii) && hii.Value != null; } /// Returns a formatted representation of the instance with the values of all contained parameters @@ -185,7 +186,7 @@ public string ToString(string prefix, bool asQuerySting) foreach (KeyValuePair item in _items) temp += item.Value.ToString(name, true) + '&'; - return _items.Count > 0 ? temp.Substring(0, temp.Length - 1) : temp; + return _items.Count > 0 ? temp[..^1] : temp; } else { @@ -216,7 +217,7 @@ HttpInputItem IHttpInput.this[string name] { get { - return _items.ContainsKey(name) ? _items[name] : Empty; + return _items.TryGetValue(name, out HttpInputItem hii) ? hii : Empty; } } @@ -239,11 +240,15 @@ public void Add(string name, string value) int pos = name.IndexOf('['); if (pos != -1) { - string name1 = name.Substring(0, pos); + string name1 = name[..pos]; string name2 = HttpInput.ExtractOne(name); - if (!_items.ContainsKey(name1)) - _items.Add(name1, new HttpInputItem(name1, null)); - _items[name1].Add(name2, value); + if (!_items.TryGetValue(name1, out HttpInputItem it)) + { + it = new HttpInputItem(name1, null); + _items.Add(name1, it); + } + it.Add(name2, value); + /* HttpInputItem item = HttpInput.ParseItem(name, value); @@ -256,8 +261,8 @@ public void Add(string name, string value) } else { - if (_items.ContainsKey(name)) - _items[name].Add(value); + if (_items.TryGetValue(name, out HttpInputItem it2)) + it2.Add(value); else _items.Add(name, new HttpInputItem(name, value)); } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs index f48dfdae857..af9f9ea622b 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs @@ -14,12 +14,9 @@ public class OSHttpListener: IDisposable private readonly X509Certificate m_certificate; private readonly IHttpContextFactory m_contextFactory; private readonly int m_port; - private readonly ManualResetEvent m_shutdownEvent = new ManualResetEvent(false); -#if NET48 - private readonly SslProtocols m_sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13 | SslProtocols.Ssl3 | SslProtocols.Ssl2; -#else - private readonly SslProtocols m_sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Ssl3 | SslProtocols.Ssl2; -#endif + private readonly ManualResetEvent m_shutdownEvent = new(false); + private readonly SslProtocols m_sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + private TcpListener m_listener; private ILogWriter m_logWriter = NullLogWriter.Instance; private int m_pendingAccepts; @@ -67,8 +64,7 @@ protected OSHttpListener(IPAddress address, int port, X509Certificate certificat /// Factory used to create es. /// Certificate to use /// which HTTPS protocol to use, default is TLS. - protected OSHttpListener(IPAddress address, int port, X509Certificate certificate, - SslProtocols protocols) + protected OSHttpListener(IPAddress address, int port, X509Certificate certificate, SslProtocols protocols) : this(address, port) { m_certificate = certificate; @@ -112,11 +108,10 @@ public ILogWriter LogWriter set { m_logWriter = value ?? NullLogWriter.Instance; - if (m_certificate != null) - m_logWriter.Write(this, LogPrio.Info, - "HTTPS(" + m_sslProtocols + ") listening on " + m_address + ":" + m_port); + if (m_certificate is not null) + m_logWriter.Write(this, LogPrio.Info, $"HTTPS({m_sslProtocols}) listening on {m_address}:{m_port}"); else - m_logWriter.Write(this, LogPrio.Info, "HTTP listening on " + m_address + ":" + m_port); + m_logWriter.Write(this, LogPrio.Info, $"HTTP listening on {m_address}:{m_port}"); } } @@ -160,9 +155,9 @@ private void OnAccept(IAsyncResult ar) if(socket.Connected) { - m_logWriter.Write(this, LogPrio.Debug, "Accepted connection from: " + socket.RemoteEndPoint); + m_logWriter.Write(this, LogPrio.Debug, $"Accepted connection from: {socket.RemoteEndPoint}"); - if (m_certificate != null) + if (m_certificate is not null) m_contextFactory.CreateSecureContext(socket, m_certificate, m_sslProtocols, m_clientCertValCallback); else m_contextFactory.CreateContext(socket); @@ -207,7 +202,7 @@ protected bool OnAcceptingSocket(Socket socket) { if(Accepted!=null) { - ClientAcceptedEventArgs args = new ClientAcceptedEventArgs(socket); + ClientAcceptedEventArgs args = new(socket); Accepted?.Invoke(this, args); return !args.Revoked; } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs index a0bdaeceec0..d0ed6677e3e 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs @@ -4,6 +4,7 @@ using System.Net; using System.Text; using System.Web; +using OpenSim.Framework; using OSHttpServer.Exceptions; @@ -21,8 +22,8 @@ public class HttpRequest : IHttpRequest public static readonly char[] UriSplitters = new[] { '/' }; public static uint baseID = 0; - private readonly NameValueCollection m_headers = new NameValueCollection(); - private readonly HttpParam m_param = new HttpParam(HttpInput.Empty, HttpInput.Empty); + private readonly NameValueCollection m_headers = new(); + //private readonly HttpParam m_param = new(HttpInput.Empty, HttpInput.Empty); private Stream m_body = new MemoryStream(); private int m_bodyBytesLeft; private ConnectionType m_connection = ConnectionType.KeepAlive; @@ -150,9 +151,9 @@ public NameValueCollection QueryString { get { - if(m_queryString == null) + if(m_queryString is null) { - if(m_uri == null || m_uri.Query.Length == 0) + if(m_uri is null || m_uri.Query.Length == 0) m_queryString = new NameValueCollection(); else { @@ -168,7 +169,7 @@ public NameValueCollection QueryString } } - public static readonly Uri EmptyUri = new Uri("http://localhost/"); + public static readonly Uri EmptyUri = new("http://localhost/"); /// /// Gets or sets requested URI. /// @@ -178,6 +179,7 @@ public Uri Uri set { m_uri = value ?? EmptyUri; } // not safe } + /* /// /// Gets parameter from or . /// @@ -185,6 +187,7 @@ public HttpParam Param { get { return m_param; } } + */ /// /// Gets form parameters. @@ -218,16 +221,18 @@ public object Clone() { // this method was mainly created for testing. // dont use it that much... - var request = new HttpRequest(Context); - request.Method = m_method; + var request = new HttpRequest(Context) + { + Method = m_method, + m_httpVersion = m_httpVersion, + m_queryString = m_queryString, + Uri = m_uri + }; if (AcceptTypes != null) { request.AcceptTypes = new string[AcceptTypes.Length]; AcceptTypes.CopyTo(request.AcceptTypes, 0); } - request.m_httpVersion = m_httpVersion; - request.m_queryString = m_queryString; - request.Uri = m_uri; var buffer = new byte[m_body.Length]; m_body.Read(buffer, 0, (int)m_body.Length); @@ -295,8 +300,7 @@ public IPEndPoint RemoteIPEndPoint } } } - if (m_remoteIPEndPoint == null) - m_remoteIPEndPoint = m_context.LocalIPEndPoint; + m_remoteIPEndPoint ??= m_context.LocalIPEndPoint; return m_remoteIPEndPoint; } @@ -362,7 +366,7 @@ public void AddHeader(string name, string value) break; case "forwarded": - string[] parts = value.Split(new char[]{';'}); + string[] parts = value.Split(Util.SplitSemicolonArray); string addr = string.Empty; for(int i = 0; i < parts.Length; ++i) { @@ -374,7 +378,7 @@ public void AddHeader(string name, string value) int indx = s.IndexOf("=", 3); if(indx < 0 || indx >= s.Length - 1) continue; - s = s.Substring(indx); + s = s[indx..]; addr = s.Trim(); } } @@ -386,7 +390,7 @@ public void AddHeader(string name, string value) case "x-forwarded-for": if (value.Length > 7) { - string[] xparts = value.Split(new char[]{','}); + string[] xparts = value.Split(Util.SplitCommaArray); if(xparts.Length > 0) { string xs = xparts[0].Trim(); diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs index f63a30fb348..c5d7f6c2b22 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs @@ -1,5 +1,4 @@ using System; -using System.Text; using OSHttpServer.Exceptions; using OpenMetaverse; @@ -11,11 +10,11 @@ namespace OSHttpServer.Parser public class HttpRequestParser : IHttpRequestParser { private ILogWriter m_log; - private readonly HeaderEventArgs m_headerArgs = new HeaderEventArgs(); - private readonly BodyEventArgs m_bodyEventArgs = new BodyEventArgs(); - private readonly RequestLineEventArgs m_requestLineArgs = new RequestLineEventArgs(); - private osUTF8Slice m_curHeaderName = new osUTF8Slice(); - private osUTF8Slice m_curHeaderValue = new osUTF8Slice(); + private readonly HeaderEventArgs m_headerArgs = new(); + private readonly BodyEventArgs m_bodyEventArgs = new(); + private readonly RequestLineEventArgs m_requestLineArgs = new(); + private osUTF8Slice m_curHeaderName = new(); + private osUTF8Slice m_curHeaderValue = new(); private int m_bodyBytesLeft; /// @@ -68,7 +67,7 @@ private int AddToBody(byte[] buffer, int offset, int count) if (m_bodyBytesLeft == 0) { // got a complete request. - m_log.Write(this, LogPrio.Trace, "Request parsed successfully."); + m_log.Write(this, LogPrio.Trace, "Request parsed successfully"); OnRequestCompleted(); Clear(); } @@ -102,56 +101,60 @@ public ILogWriter LogWriter /// /// If line is incorrect /// Expects the following format: "Method SP Request-URI SP HTTP-Version CRLF" - protected void OnFirstLine(string value) + protected void OnFirstLine(osUTF8Slice value) { // //todo: In the interest of robustness, servers SHOULD ignore any empty line(s) received where a Request-Line is expected. // In other words, if the server is reading the protocol stream at the beginning of a message and receives a CRLF first, it should ignore the CRLF. // - m_log.Write(this, LogPrio.Debug, "Got request: " + value); + m_log.Write(this, LogPrio.Debug, $"Got request: {value}"); //Request-Line = Method SP Request-URI SP HTTP-Version CRLF - int pos = value.IndexOf(' '); - if (pos == -1 || pos + 1 >= value.Length) + int pos = value.IndexOf((byte)' '); + int oldPos = pos + 1; + if (pos == -1 || oldPos >= value.Length) { - m_log.Write(this, LogPrio.Warning, "Invalid request line, missing Method. Line: " + value); - throw new BadRequestException("Invalid request line, missing Method. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid request line, missing Method. Line: {value}"); + throw new BadRequestException($"Invalid request line, missing Method. Line: {value}"); } - string method = value.Substring(0, pos).ToUpper(); - int oldPos = pos + 1; - pos = value.IndexOf(' ', oldPos); + osUTF8Slice method = value.SubUTF8(0, pos); + value.SubUTF8Self(oldPos); + pos = value.IndexOf((byte)' '); if (pos == -1) { - m_log.Write(this, LogPrio.Warning, "Invalid request line, missing URI. Line: " + value); - throw new BadRequestException("Invalid request line, missing URI. Line: " + value); + m_log.Write(this, LogPrio.Warning, "Invalid request line, missing URI"); + throw new BadRequestException("Invalid request line, missing URI"); } - string path = value.Substring(oldPos, pos - oldPos); - if (path.Length > 4196) - throw new BadRequestException("Too long URI."); - if (path == "*") - throw new BadRequestException("Not supported URI."); + if(pos > 4196) + throw new BadRequestException("URI too long"); - if (pos + 1 >= value.Length) + osUTF8Slice path = value.SubUTF8(0, pos); + if (path.ACSIILowerEquals("*")) + throw new BadRequestException("URI not supported"); + + oldPos = pos + 1; + if (oldPos >= value.Length) { - m_log.Write(this, LogPrio.Warning, "Invalid request line, missing HTTP-Version. Line: " + value); - throw new BadRequestException("Invalid request line, missing HTTP-Version. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid request line, missing HTTP-Version. Line: {value}"); + throw new BadRequestException($"Invalid request line, missing HTTP-Version. Line: {value}"); } - string version = value.Substring(pos + 1); - if (version.Length < 4 || string.Compare(version.Substring(0, 4), "HTTP", true) != 0) + osUTF8Slice version = value.SubUTF8(oldPos); + if (version.Length < 4 || !version.SubUTF8(0,4).ACSIILowerEquals("http")) { - m_log.Write(this, LogPrio.Warning, "Invalid HTTP version in request line. Line: " + value); - throw new BadRequestException("Invalid HTTP version in Request line. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid HTTP version in request line. Line: {value}"); + throw new BadRequestException($"Invalid HTTP version in Request line. Line: {value}"); } - if(RequestLineReceived != null) + if(RequestLineReceived is not null) { + method.ToASCIIUpperSelf(); m_requestLineArgs.HttpMethod = method; m_requestLineArgs.HttpVersion = version; m_requestLineArgs.UriPath = path; RequestLineReceived?.Invoke(this, m_requestLineArgs); - } + } } private static readonly byte[] OSUTF8contentlength = osUTF8.GetASCIIBytes("content-length"); @@ -174,7 +177,7 @@ protected void OnHeader() if (HeaderReceived != null) { m_headerArgs.Name = m_curHeaderName; - m_headerArgs.Value = m_curHeaderValue.ToString(); + m_headerArgs.Value = m_curHeaderValue; HeaderReceived?.Invoke(this, m_headerArgs); } @@ -255,7 +258,7 @@ public int Parse(byte[] buffer, int offset, int count) else if(ch == '\r' || ch == '\n') { int size = GetLineBreakSize(buffer, currentPos); - OnFirstLine(Encoding.UTF8.GetString(buffer, startPos, currentPos - startPos)); + OnFirstLine(new osUTF8Slice(buffer, startPos, currentPos - startPos)); currentPos += size - 1; handledBytes = currentPos + 1; startPos = -1; @@ -269,7 +272,7 @@ public int Parse(byte[] buffer, int offset, int count) if (m_bodyBytesLeft == 0) { CurrentState = RequestParserState.FirstLine; - m_log.Write(this, LogPrio.Trace, "Request parsed successfully (no content)."); + m_log.Write(this, LogPrio.Trace, "Request parsed successfully (no content)"); OnRequestCompleted(); Clear(); return currentPos; @@ -288,9 +291,8 @@ public int Parse(byte[] buffer, int offset, int count) { if (startPos == -1) { - m_log.Write(this, LogPrio.Warning, - "Expected header name, got colon on line " + currentLine); - throw new BadRequestException("Expected header name, got colon on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Expected header name, got colon on line {currentLine}"); + throw new BadRequestException($"Expected header name, got colon on line {currentLine}"); } m_curHeaderName = new osUTF8Slice(buffer, startPos, currentPos - startPos); handledBytes = currentPos + 1; @@ -302,15 +304,15 @@ public int Parse(byte[] buffer, int offset, int count) } else if (!char.IsLetterOrDigit(ch) && ch != '-') { - m_log.Write(this, LogPrio.Warning, "Invalid character in header name on line " + currentLine); - throw new BadRequestException("Invalid character in header name on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Invalid character in header name on line {currentLine}"); + throw new BadRequestException($"Invalid character in header name on line {currentLine}"); } if (startPos == -1) startPos = currentPos; else if (currentPos - startPos > 200) { - m_log.Write(this, LogPrio.Warning, "Invalid header name on line " + currentLine); - throw new BadRequestException("Invalid header name on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Invalid header name on line {currentLine}"); + throw new BadRequestException($"Invalid header name on line {currentLine}"); } break; case RequestParserState.AfterName: @@ -332,21 +334,22 @@ public int Parse(byte[] buffer, int offset, int count) { if (currentPos - startPos > 256) { - m_log.Write(this, LogPrio.Warning, "header value too far" + currentLine); - throw new BadRequestException("header value too far" + currentLine); + m_log.Write(this, LogPrio.Warning, $"header value too far {currentLine}"); + throw new BadRequestException($"header value too far {currentLine}"); } } else { int newLineSize = GetLineBreakSize(buffer, currentPos); - if (newLineSize > 0 && currentPos + newLineSize < endOfBufferPos && - char.IsWhiteSpace((char)buffer[currentPos + newLineSize])) + int tsize = currentPos + newLineSize; + if (newLineSize > 0 && tsize < endOfBufferPos && + char.IsWhiteSpace((char)buffer[tsize])) { if (currentPos - startPos > 256) { - m_log.Write(this, LogPrio.Warning, "header value too" + currentLine); - throw new BadRequestException("header value too far" + currentLine); - } + m_log.Write(this, LogPrio.Warning, $"header value too far {currentLine}"); + throw new BadRequestException($"header value too far {currentLine}"); + } ++currentPos; } else @@ -363,23 +366,23 @@ public int Parse(byte[] buffer, int offset, int count) if (ch == '\r' || ch == '\n') { if (m_curHeaderName.Length == 0) - throw new BadRequestException("Missing header on line " + currentLine); - + throw new BadRequestException($"Missing header on line {currentLine}"); + if (currentPos - startPos > 8190) { - m_log.Write(this, LogPrio.Warning, "Too large header value on line " + currentLine); - throw new BadRequestException("Too large header value on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Too large header value on line {currentLine}"); + throw new BadRequestException($"Too large header value on line {currentLine}"); } // Header fields can be extended over multiple lines by preceding each extra line with at // least one SP or HT. int newLineSize = GetLineBreakSize(buffer, currentPos); - if (endOfBufferPos > currentPos + newLineSize - && (buffer[currentPos + newLineSize] == ' ' || buffer[currentPos + newLineSize] == '\t')) + int tnext = currentPos + newLineSize; + if (endOfBufferPos > tnext && (buffer[tnext] == ' ' || buffer[tnext] == '\t')) { if (startPos != -1) { - osUTF8Slice osUTF8SliceTmp = new osUTF8Slice(buffer, startPos, currentPos - startPos); + osUTF8Slice osUTF8SliceTmp = new(buffer, startPos, currentPos - startPos); if (m_curHeaderValue.Length == 0) m_curHeaderValue = osUTF8SliceTmp.Clone(); else @@ -393,13 +396,13 @@ public int Parse(byte[] buffer, int offset, int count) } else { - osUTF8Slice osUTF8SliceTmp = new osUTF8Slice(buffer, startPos, currentPos - startPos); + osUTF8Slice osUTF8SliceTmp = new(buffer, startPos, currentPos - startPos); if (m_curHeaderValue.Length == 0) m_curHeaderValue = osUTF8SliceTmp.Clone(); else m_curHeaderValue.Append(osUTF8SliceTmp); - m_log.Write(this, LogPrio.Trace, "Header [" + m_curHeaderName + ": " + m_curHeaderValue + "]"); + m_log.Write(this, LogPrio.Trace, $"Header [{m_curHeaderName}:{m_curHeaderValue}]"); OnHeader(); @@ -432,23 +435,23 @@ public int Parse(byte[] buffer, int offset, int count) return handledBytes; } - int GetLineBreakSize(byte[] buffer, int offset) + static int GetLineBreakSize(byte[] buffer, int offset) { - if (buffer[offset] == '\r') + byte c = buffer[offset]; + if (c == '\r') { - if (buffer.Length > offset + 1 && buffer[offset + 1] == '\n') + ++offset; + if (buffer.Length > offset && buffer[offset] == '\n') return 2; else throw new BadRequestException("Got invalid linefeed."); } - else if (buffer[offset] == '\n') + else if (c == '\n') { - if (buffer.Length == offset + 1) + ++offset; + if (buffer.Length == offset) return 1; // linux line feed - if (buffer[offset + 1] != '\r') - return 1; // linux line feed - else - return 2; // win line feed + return buffer[offset] == '\r' ? 2 : 1; } else return 0; diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs index 73f87998f69..e1c5f6eac98 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpResponse.cs @@ -11,8 +11,8 @@ public class HttpResponse : IHttpResponse { private const string DefaultContentType = "text/html;charset=UTF-8"; private readonly IHttpClientContext m_context; - private readonly ResponseCookies m_cookies = new ResponseCookies(); - private readonly NameValueCollection m_headers = new NameValueCollection(); + private readonly ResponseCookies m_cookies = new(); + private readonly NameValueCollection m_headers = new(); private string m_httpVersion; private Stream m_body; private long m_contentLength; @@ -25,7 +25,7 @@ public class HttpResponse : IHttpResponse public int RawBufferLen { get; set; } public double RequestTS { get; private set; } - internal byte[] m_headerBytes = null; + internal osUTF8 m_headerBytes = null; /// /// Initializes a new instance of the class. @@ -86,8 +86,7 @@ public Stream Body { get { - if(m_body == null) - m_body = new MemoryStream(); + m_body ??= new MemoryStream(); return m_body; } } @@ -229,55 +228,65 @@ public void AddHeader(string name, string value) m_headers[name] = value; } - public byte[] GetHeaders() + public void GetHeaders() { HeadersSent = true; - var sb = osStringBuilderCache.Acquire(); + osUTF8 osu = OSUTF8Cached.Acquire(8 * 1024); - if(string.IsNullOrWhiteSpace(m_httpVersion)) - sb.AppendFormat("HTTP/1.1 {0} {1}\r\n", (int)Status, - string.IsNullOrEmpty(Reason) ? Status.ToString() : Reason); + if (string.IsNullOrWhiteSpace(m_httpVersion)) + { + osu.AppendASCII($"HTTP/1.1 {(int)Status} "); + if (string.IsNullOrEmpty(Reason)) + osu.AppendASCII($"{Status}"); + else + osu.Append($"{Reason}"); + osu.AppendASCII("\r\n"); + } else - sb.AppendFormat("{0} {1} {2}\r\n", m_httpVersion, (int)Status, - string.IsNullOrEmpty(Reason) ? Status.ToString() : Reason); + { + osu.AppendASCII($"{m_httpVersion} {(int)Status} "); + if (string.IsNullOrEmpty(Reason)) + osu.AppendASCII($"{Status}"); + else + osu.Append($"{Reason}"); + osu.AppendASCII("\r\n"); + } - sb.AppendFormat("Date: {0}\r\n", DateTime.Now.ToString("r")); + osu.AppendASCII($"Date: {DateTime.Now:r}\r\n"); - long len = 0; - if(m_body!= null) - len = m_body.Length; - if (RawBuffer != null && RawBufferLen > 0) + long len = m_body is null ? 0 : m_body.Length; + if (RawBuffer is not null) len += RawBufferLen; - sb.AppendFormat("Content-Length: {0}\r\n", len); + osu.AppendASCII($"Content-Length: {len}\r\n"); - if (m_headers["Content-Type"] == null) - sb.AppendFormat("Content-Type: {0}\r\n", m_contentType ?? DefaultContentType); + if (m_headers["Content-Type"] is null) + osu.AppendASCII($"Content-Type: {m_contentType ?? DefaultContentType}\r\n"); - switch(Status) + switch (Status) { case HttpStatusCode.OK: case HttpStatusCode.PartialContent: case HttpStatusCode.Accepted: case HttpStatusCode.Continue: case HttpStatusCode.Found: - { - int keepaliveS = m_context.TimeoutKeepAlive / 1000; - if (Connection == ConnectionType.KeepAlive && keepaliveS > 0 && m_context.MaxRequests > 0) { - sb.AppendFormat("Keep-Alive:timeout={0}, max={1}\r\n", keepaliveS, m_context.MaxRequests); - sb.Append("Connection: Keep-Alive\r\n"); - } - else - { - sb.Append("Connection: close\r\n"); - Connection = ConnectionType.Close; + int keepaliveS = m_context.TimeoutKeepAlive / 1000; + if (Connection == ConnectionType.KeepAlive && keepaliveS > 0 && m_context.MaxRequests > 0) + { + osu.AppendASCII($"Keep-Alive:timeout={keepaliveS}, max={m_context.MaxRequests}\r\n"); + osu.AppendASCII("Connection: Keep-Alive\r\n"); + } + else + { + osu.AppendASCII("Connection: close\r\n"); + Connection = ConnectionType.Close; + } + break; } - break; - } default: - sb.Append("Connection: close\r\n"); + osu.AppendASCII("Connection: close\r\n"); Connection = ConnectionType.Close; break; } @@ -285,7 +294,7 @@ public byte[] GetHeaders() for (int i = 0; i < m_headers.Count; ++i) { string headerName = m_headers.AllKeys[i]; - switch(headerName) + switch (headerName) { case "Connection": case "Content-Length": @@ -295,21 +304,27 @@ public byte[] GetHeaders() continue; } string[] values = m_headers.GetValues(i); - if (values == null) continue; - foreach (string value in values) - sb.AppendFormat("{0}: {1}\r\n", headerName, value); + if (values is not null) + { + foreach (string value in values) + { + osu.AppendASCII($"{headerName}: "); + osu.Append($"{value}"); + osu.AppendASCII("\r\n"); + } + } } - sb.Append("Server: OSWebServer\r\n"); + osu.AppendASCII("Server: OSWebServer\r\n"); foreach (ResponseCookie cookie in Cookies) - sb.AppendFormat("Set-Cookie: {0}\r\n", cookie); + osu.Append($"Set-Cookie: {cookie}\r\n"); - sb.Append("\r\n"); + osu.AppendASCII("\r\n"); m_headers.Clear(); - return Encoding.GetBytes(osStringBuilderCache.GetStringAndRelease(sb)); + m_headerBytes = osu; } public void Send() @@ -331,7 +346,7 @@ public void Send() m_context.TimeoutKeepAlive = m_keepAlive * 1000; } - if (RawBuffer != null) + if (RawBuffer is not null) { if (RawBufferStart > RawBuffer.Length) return; @@ -346,33 +361,29 @@ public void Send() RawBufferLen = RawBuffer.Length - RawBufferStart; } - m_headerBytes = GetHeaders(); + if (RawBufferLen == 0) + RawBuffer = null; - if (RawBuffer != null && RawBufferLen > 0) + GetHeaders(); + + if (RawBuffer is not null && RawBufferLen > 0) { int tlen = m_headerBytes.Length + RawBufferLen; if(tlen < 8 * 1024) { - byte[] tmp = new byte[tlen]; - Buffer.BlockCopy(m_headerBytes, 0, tmp, 0, m_headerBytes.Length); - Buffer.BlockCopy(RawBuffer, RawBufferStart, tmp, m_headerBytes.Length, RawBufferLen); - m_headerBytes = null; - RawBuffer = tmp; - RawBufferStart = 0; - RawBufferLen = tlen; - } - - if (RawBufferLen == 0) + m_headerBytes.Append(RawBuffer, RawBufferStart, RawBufferLen); RawBuffer = null; + RawBufferLen = 0; + } } - if (m_body != null && m_body.Length == 0) + if (m_body is not null && m_body.Length == 0) { m_body.Dispose(); m_body = null; } - if (m_headerBytes == null && RawBuffer == null && m_body == null) + if (m_headerBytes is null && RawBuffer is null && m_body is null) { Sent = true; m_context.EndSendResponse(requestID, Connection); @@ -383,14 +394,17 @@ public void Send() public bool SendNextAsync(int bytesLimit) { - if (m_headerBytes != null) + if (m_headerBytes is not null) { - byte[] b = m_headerBytes; - m_headerBytes = null; - - if (!m_context.SendAsyncStart(b, 0, b.Length)) + if (!m_context.SendAsyncStart(m_headerBytes.GetArray(), 0, m_headerBytes.Length)) { - if (m_body != null) + if(m_headerBytes is not null) + { + OSUTF8Cached.Release(m_headerBytes); + m_headerBytes = null; + } + + if (m_body is not null) { m_body.Dispose(); m_body = null; @@ -403,7 +417,7 @@ public bool SendNextAsync(int bytesLimit) } bool sendRes; - if (RawBuffer != null) + if (RawBuffer is not null) { if(RawBufferLen > 0) { @@ -429,7 +443,7 @@ public bool SendNextAsync(int bytesLimit) if (!sendRes) { RawBuffer = null; - if(m_body != null) + if(m_body is not null) { m_body.Dispose(); m_body = null; @@ -443,7 +457,7 @@ public bool SendNextAsync(int bytesLimit) RawBuffer = null; } - if (m_body != null) + if (m_body is not null) { if(m_body.Length != 0) { @@ -500,7 +514,13 @@ public bool SendNextAsync(int bytesLimit) public void CheckSendNextAsyncContinue() { - if(m_headerBytes == null && RawBuffer == null && m_body == null) + if (m_headerBytes is not null) + { + OSUTF8Cached.Release(m_headerBytes); + m_headerBytes = null; + } + + if (m_headerBytes is null && RawBuffer is null && m_body is null) { Sent = true; m_context.EndSendResponse(requestID, Connection); @@ -513,8 +533,18 @@ public void CheckSendNextAsyncContinue() public void Clear() { - if(m_body != null && m_body.CanRead) + if(m_headerBytes is not null) + { + OSUTF8Cached.Release(m_headerBytes); + m_headerBytes = null; + } + + if(m_body is not null && m_body.CanRead) + { m_body.Dispose(); + m_body = null; + } + RawBuffer = null; } #endregion } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/IHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/IHttpRequest.cs index 2ca5f4e1bec..8a12febc58b 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/IHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/IHttpRequest.cs @@ -72,10 +72,12 @@ public interface IHttpRequest /// string Method { get; set; } + /* /// /// Gets parameter from or . /// HttpParam Param { get; } + */ /// /// Gets variables sent in the query string diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs index 790c9a500de..03093d0afdf 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.Text; +using System.Runtime.CompilerServices; namespace OSHttpServer { @@ -68,7 +66,7 @@ public sealed class NullLogWriter : ILogWriter /// /// The logging instance. /// - public static readonly NullLogWriter Instance = new NullLogWriter(); + public static readonly NullLogWriter Instance = new(); /// /// Writes everything to null @@ -76,6 +74,7 @@ public sealed class NullLogWriter : ILogWriter /// object that wrote the log entry. /// Importance of the log message /// The message. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write(object source, LogPrio prio, string message) {} } } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/RequestLineEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/RequestLineEventArgs.cs index 1b9b8dc69be..e2b72e3df84 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/RequestLineEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/RequestLineEventArgs.cs @@ -1,4 +1,5 @@ -using System; +using OpenMetaverse; +using System; namespace OSHttpServer.Parser { @@ -8,41 +9,18 @@ namespace OSHttpServer.Parser public class RequestLineEventArgs : EventArgs { /// - /// Initializes a new instance of the class. + /// http method. /// - /// The HTTP method. - /// The URI path. - /// The HTTP version. - public RequestLineEventArgs(string httpMethod, string uriPath, string httpVersion) - { - HttpMethod = httpMethod; - UriPath = uriPath; - HttpVersion = httpVersion; - } + public osUTF8Slice HttpMethod; /// - /// Initializes a new instance of the class. + /// version of the HTTP protocol that the client want to use. /// - public RequestLineEventArgs() - { - } + public osUTF8Slice HttpVersion; /// - /// Gets or sets http method. + /// requested URI path. /// - /// - /// Should be one of the methods declared in . - /// - public string HttpMethod { get; set; } - - /// - /// Gets or sets the version of the HTTP protocol that the client want to use. - /// - public string HttpVersion { get; set; } - - /// - /// Gets or sets requested URI path. - /// - public string UriPath { get; set; } + public osUTF8Slice UriPath; } } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/OpenSim.Framework.Servers.HttpServer.csproj b/OpenSim/Framework/Servers/HttpServer/OpenSim.Framework.Servers.HttpServer.csproj index 94d2cdfd242..7922205eb5d 100644 --- a/OpenSim/Framework/Servers/HttpServer/OpenSim.Framework.Servers.HttpServer.csproj +++ b/OpenSim/Framework/Servers/HttpServer/OpenSim.Framework.Servers.HttpServer.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Framework.Servers.HttpServer http://opensimulator.org OpenSim diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index e7b44b2936e..e35e067761a 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -33,7 +33,6 @@ namespace OpenSim.Framework.Servers.HttpServer { public delegate OSHttpResponse RequestMethod(UUID ID, OSHttpRequest request); public delegate bool HasEventsMethod(UUID requestID, UUID pId); - public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 784e84fa05d..10ad3530700 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs @@ -73,14 +73,14 @@ internal void DoHTTPGruntWork(Hashtable responsedata) OSHttpResponse response = new OSHttpResponse(new HttpResponse(Request)); - if (responsedata == null) + if (responsedata is null) { SendNoContentError(response); return; } int responsecode = 200; - string responseString = String.Empty; + string responseString = null; string contentType; byte[] buffer = null; int rangeStart = 0; @@ -105,10 +105,7 @@ internal void DoHTTPGruntWork(Hashtable responsedata) } else responseString = (string)responsedata["str_response_string"]; - contentType = (string)responsedata["content_type"]; - if (responseString == null) - responseString = String.Empty; } catch { @@ -158,7 +155,9 @@ internal void DoHTTPGruntWork(Hashtable responsedata) if(buffer == null) { - if (contentType != null && (!(contentType.Contains("image") + if(string.IsNullOrEmpty(responseString)) + buffer = Array.Empty(); + else if (contentType != null && (!(contentType.Contains("image") || contentType.Contains("x-shockwave-flash") || contentType.Contains("application/x-oar") || contentType.Contains("application/vnd.ll.mesh")))) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index a84df2a28a5..beb8d88ac20 100755 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -41,16 +41,14 @@ public class PollServiceRequestManager { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private ConcurrentQueue m_retryRequests = new ConcurrentQueue(); - - private int m_WorkerThreadCount = 0; + private readonly ConcurrentQueue m_retryRequests = new(); + private readonly int m_WorkerThreadCount = 0; private ObjectJobEngine m_workerPool; private Thread m_retrysThread; private bool m_running = false; - public PollServiceRequestManager( - bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) + public PollServiceRequestManager(bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) { m_WorkerThreadCount = (int)pWorkerThreadCount; } @@ -59,6 +57,7 @@ public void Start() { if(m_running) return; + m_running = true; m_workerPool = new ObjectJobEngine(PoolWorkerJob, "PollServiceWorker", 4000, m_WorkerThreadCount); @@ -86,12 +85,11 @@ public void Enqueue(PollServiceHttpRequest req) private void CheckRetries() { - PollServiceHttpRequest preq; while (m_running) { Thread.Sleep(100); Watchdog.UpdateThread(); - while (m_running && m_retryRequests.TryDequeue(out preq)) + while (m_running && m_retryRequests.TryDequeue(out PollServiceHttpRequest preq)) m_workerPool.Enqueue(preq); } } @@ -126,8 +124,7 @@ public void Stop() private void PoolWorkerJob(object o) { - PollServiceHttpRequest req = o as PollServiceHttpRequest; - if(req == null) + if (o is not PollServiceHttpRequest req) return; try { @@ -176,7 +173,7 @@ private void PoolWorkerJob(object o) } catch (Exception e) { - m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); + m_log.Error($"Exception in poll service thread: {e}"); } } } diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj index b3d234901fc..0a6fba9b3ca 100644 --- a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj +++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Framework.Servers http://opensimulator.org OpenSim diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 1def987169b..87eeb136b09 100755 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -82,9 +82,7 @@ public ServerBase() protected void CreatePIDFile(string path) { if (File.Exists(path)) - m_log.ErrorFormat( - "[SERVER BASE]: Previous pid file {0} still exists on startup. Possibly previously unclean shutdown.", - path); + m_log.Error($"[SERVER BASE]: Previous pid file {path} still exists on startup. Possibly previously unclean shutdown."); try { @@ -108,7 +106,7 @@ protected void CreatePIDFile(string path) protected void RemovePIDFile() { - if (m_pidFile != String.Empty) + if (!string.IsNullOrEmpty(m_pidFile)) { try { @@ -116,7 +114,7 @@ protected void RemovePIDFile() } catch (Exception e) { - m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e); + m_log.Error($"[SERVER BASE]: Error whilst removing {m_pidFile}", e); } m_pidFile = String.Empty; @@ -131,16 +129,15 @@ public void LogEnvironmentInformation() { // FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net // XmlConfigurator calls first accross servers. - m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory); + m_log.Info($"[SERVER BASE]: Starting in {m_startupDirectory}"); - m_log.InfoFormat("[SERVER BASE]: OpenSimulator version: {0}", m_version); + m_log.Info($"[SERVER BASE]: OpenSimulator version: {m_version}"); // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and // the clr version number doesn't match the project version number under Mono. //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine); - m_log.InfoFormat( - "[SERVER BASE]: Operating system version: {0}, .NET platform {1}, {2}-bit", - Environment.OSVersion, Environment.OSVersion.Platform, Environment.Is64BitProcess ? "64" : "32"); + m_log.Info( + $"[SERVER BASE]: Operating system version: {Environment.OSVersion}, .NET platform {Util.RuntimePlatformStr}, {(Environment.Is64BitProcess ? "64" : "32")}-bit"); } public void RegisterCommonAppenders(IConfig startupConfig) @@ -174,10 +171,10 @@ public void RegisterCommonAppenders(IConfig startupConfig) m_consoleAppender.Console = (ConsoleBase)m_console; // If there is no threshold set then the threshold is effectively everything. - if (null == m_consoleAppender.Threshold) + if (m_consoleAppender.Threshold is null) m_consoleAppender.Threshold = Level.All; - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); + //Notice($"Console log level is {m_consoleAppender.Threshold}"); } if (m_logFileAppender != null && startupConfig != null) @@ -298,11 +295,11 @@ public void RegisterCommonCommands() + " 3 = full stack trace, including common threads\n", HandleDebugThreadpoolLevel); -// m_console.Commands.AddCommand( -// "Debug", false, "show threadpool calls active", -// "show threadpool calls active", -// "Show details about threadpool calls that are still active (currently waiting or in progress)", -// HandleShowThreadpoolCallsActive); + //m_console.Commands.AddCommand( + // "Debug", false, "show threadpool calls active", + // "show threadpool calls active", + // "Show details about threadpool calls that are still active (currently waiting or in progress)", + // HandleShowThreadpoolCallsActive); m_console.Commands.AddCommand( "Debug", false, "show threadpool calls complete", @@ -334,7 +331,7 @@ public void RegisterCommonCommands() public void RegisterCommonComponents(IConfigSource configSource) { -// IConfig networkConfig = configSource.Configs["Network"]; + //IConfig networkConfig = configSource.Configs["Network"]; m_serverStatsCollector = new ServerStatsCollector(); m_serverStatsCollector.Initialise(configSource); @@ -417,9 +414,7 @@ private void HandleDebugThreadpoolSet(string module, string[] args) return; } - int newThreads; - - if (!ConsoleUtil.TryParseConsoleInt(m_console, args[5], out newThreads)) + if (!ConsoleUtil.TryParseConsoleInt(m_console, args[5], out int newThreads)) return; string poolType = args[3]; @@ -469,10 +464,8 @@ private void HandleDebugThreadpoolSet(string module, string[] args) } else { - int minWorkerThreads, maxWorkerThreads, minIocpThreads, maxIocpThreads; - - ThreadPool.GetMinThreads(out minWorkerThreads, out minIocpThreads); - ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxIocpThreads); + ThreadPool.GetMinThreads(out int minWorkerThreads, out int minIocpThreads); + ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxIocpThreads); Notice("Min worker threads now {0}", minWorkerThreads); Notice("Min IOCP threads now {0}", minIocpThreads); @@ -756,48 +749,50 @@ protected void ShowInfo() /// protected void EnhanceVersionInformation() { + const string manualVersionFileName = ".version"; string buildVersion = string.Empty; - string manualVersionFileName = ".version"; - - string gitDir = "../.git/"; - string gitRefPointerPath = gitDir + "HEAD"; - if (File.Exists(manualVersionFileName)) { using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) buildVersion = CommitFile.ReadLine(); - m_version += buildVersion ?? ""; + if (!string.IsNullOrEmpty(buildVersion)) + { + m_version += buildVersion; + return; + } } - else if (File.Exists(gitRefPointerPath)) + + string gitDir = Path.Combine("..", ".git"); + string gitRefPointerPath = Path.Combine(gitDir, "HEAD"); + if (File.Exists(gitRefPointerPath)) { -// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath); + //m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath); string rawPointer = ""; using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) rawPointer = pointerFile.ReadLine(); -// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer); + //m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer); Match m = Regex.Match(rawPointer, "^ref: (.+)$"); if (m.Success) { -// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value); + //m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value); string gitRef = m.Groups[1].Value; - string gitRefPath = gitDir + gitRef; + string gitRefPath = Path.Combine(gitDir, gitRef); if (File.Exists(gitRefPath)) { -// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath); - + //m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath); using (StreamReader refFile = File.OpenText(gitRefPath)) - { - string gitHash = refFile.ReadLine(); - m_version += gitHash.Substring(0, 7); - } + buildVersion = refFile.ReadLine(); + + if (!string.IsNullOrEmpty(buildVersion)) + m_version += buildVersion[..7]; } } } @@ -805,8 +800,7 @@ protected void EnhanceVersionInformation() public string GetVersionText() { - return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})", - m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax); + return $"Version: {m_version} (SIM-{VersionInfo.SimulationServiceVersionSupportedMin}/{VersionInfo.SimulationServiceVersionSupportedMax})"; } /// diff --git a/OpenSim/Framework/Servers/Tests/OpenSim.Framework.Servers.Tests.csproj b/OpenSim/Framework/Servers/Tests/OpenSim.Framework.Servers.Tests.csproj deleted file mode 100644 index 4a51ecd08c7..00000000000 --- a/OpenSim/Framework/Servers/Tests/OpenSim.Framework.Servers.Tests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - net48 - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs b/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs deleted file mode 100644 index 68a1c78aa4b..00000000000 --- a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using NUnit.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Servers.Tests -{ - [TestFixture] - public class VersionInfoTests : OpenSimTestCase - { - [Test] - public void TestVersionLength() - { - Assert.AreEqual(VersionInfo.VERSIONINFO_VERSION_LENGTH, VersionInfo.Version.Length," VersionInfo.Version string not " + VersionInfo.VERSIONINFO_VERSION_LENGTH + " chars."); - } - } -} diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs index 9126cfb5f44..c1c94e16458 100644 --- a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -33,6 +33,7 @@ using Nini.Config; using log4net; +using System.Net.Http.Headers; namespace OpenSim.Framework.ServiceAuth { @@ -54,14 +55,13 @@ public string Credentials public BasicHttpAuthentication(IConfigSource config, string section) { -// remove_me = section; m_Username = Util.GetConfigVarFromSections(config, "HttpAuthUsername", new string[] { "Network", section }, string.Empty); m_Password = Util.GetConfigVarFromSections(config, "HttpAuthPassword", new string[] { "Network", section }, string.Empty); string str = m_Username + ":" + m_Password; byte[] encData_byte = Util.UTF8.GetBytes(str); m_CredentialsB64 = Convert.ToBase64String(encData_byte); -// m_log.DebugFormat("[HTTP BASIC AUTH]: {0} {1} [{2}]", m_Username, m_Password, section); + //m_log.DebugFormat("[HTTP BASIC AUTH]: {0} {1} [{2}]", m_Username, m_Password, section); } public void AddAuthorization(NameValueCollection headers) @@ -70,12 +70,18 @@ public void AddAuthorization(NameValueCollection headers) headers["Authorization"] = "Basic " + m_CredentialsB64; } + public void AddAuthorization(HttpRequestHeaders headers) + { + //m_log.DebugFormat("[HTTP BASIC AUTH]: Adding authorization for {0}", remove_me); + headers.TryAddWithoutValidation("Authorization","Basic " + m_CredentialsB64); + } + public bool Authenticate(string data) { string recovered = Util.Base64ToString(data); if (!String.IsNullOrEmpty(recovered)) { - string[] parts = recovered.Split(new char[] { ':' }); + string[] parts = recovered.Split(Util.SplitColonArray); if (parts.Length >= 2) { return m_Username.Equals(parts[0]) && m_Password.Equals(parts[1]); diff --git a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs index 79d6ff429b7..4b13a80b5b4 100644 --- a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs @@ -30,6 +30,7 @@ using System.Collections.Specialized; using System.Linq; using System.Net; +using System.Net.Http.Headers; namespace OpenSim.Framework.ServiceAuth { @@ -62,6 +63,12 @@ public void AddAuthorization(NameValueCollection headers) auth.AddAuthorization(headers); } + public void AddAuthorization(HttpRequestHeaders headers) + { + foreach (IServiceAuth auth in m_authentications) + auth.AddAuthorization(headers); + } + public bool Authenticate(string data) { return m_authentications.TrueForAll(a => a.Authenticate(data)); diff --git a/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs b/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs index e0c413bac90..e2f64ce99fb 100644 --- a/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs +++ b/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Specialized; using System.Net; +using System.Net.Http.Headers; namespace OpenSim.Framework.ServiceAuth { @@ -35,7 +36,8 @@ public class DisallowLlHttpRequest : IServiceAuth { public string Name { get { return "DisallowllHTTPRequest"; } } - public void AddAuthorization(NameValueCollection headers) {} + public void AddAuthorization(NameValueCollection headers) { } + public void AddAuthorization(HttpRequestHeaders headers) { } public bool Authenticate(string data) { diff --git a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs index 5f744cbe102..4fe309dd794 100644 --- a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs +++ b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs @@ -29,6 +29,7 @@ using System.Net; using System.Collections.Generic; using System.Collections.Specialized; +using System.Net.Http.Headers; namespace OpenSim.Framework.ServiceAuth { @@ -44,5 +45,6 @@ public interface IServiceAuth bool Authenticate(string data); bool Authenticate(NameValueCollection headers, AddHeaderDelegate d, out HttpStatusCode statusCode); void AddAuthorization(NameValueCollection headers); + void AddAuthorization(HttpRequestHeaders headers); } } diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 217b8b2849d..68e2babe2d0 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -38,78 +38,19 @@ namespace OpenSim.Framework public class TaskInventoryItem : ICloneable { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// XXX This should really be factored out into some constants class. - /// private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; - private UUID _assetID = UUID.Zero; - - private uint _baseMask = FULL_MASK_PERMISSIONS_GENERAL; - private uint _creationDate = 0; - private UUID _creatorID = UUID.Zero; - private string _creatorData = String.Empty; - private string _description = String.Empty; - private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL; - private uint _flags = 0; - private UUID _groupID = UUID.Zero; - private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL; - - private int _invType = 0; - private UUID _itemID = UUID.Zero; - private UUID _lastOwnerID = UUID.Zero; - private UUID _rezzerID = UUID.Zero; - private string _name = String.Empty; - private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; - private UUID _ownerID = UUID.Zero; - private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL; - private UUID _parentID = UUID.Zero; //parent folder id - private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside - private UUID _permsGranter; - private int _permsMask; - private int _type = 0; - private UUID _oldID; - private UUID _loadedID = UUID.Zero; - - private bool _ownerChanged = false; - - public UUID AssetID { - get { - return _assetID; - } - set { - _assetID = value; - } - } + public UUID AssetID { get; set; } + public uint CreationDate { get; set; } - public uint BasePermissions { - get { - return _baseMask; - } - set { - _baseMask = value; - } - } - - public uint CreationDate { - get { - return _creationDate; - } - set { - _creationDate = value; - } - } - - public UUID CreatorID { - get { - return _creatorID; - } - set { - _creatorID = value; - } + UUID _creatorID = UUID.Zero; + public UUID CreatorID + { + get { return _creatorID; } + set { _creatorID = value; } } + private string _creatorData = string.Empty; public string CreatorData // = ; { get { return _creatorData; } @@ -138,11 +79,9 @@ public string CreatorIdentification return; } - if (!value.Contains(";")) // plain UUID + if (!value.Contains(';')) // plain UUID { - UUID uuid = UUID.Zero; - UUID.TryParse(value, out uuid); - _creatorID = uuid; + _= UUID.TryParse(value, out _creatorID); } else // [;[;name]] { @@ -150,9 +89,7 @@ public string CreatorIdentification string[] parts = value.Split(';'); if (parts.Length >= 1) { - UUID uuid = UUID.Zero; - UUID.TryParse(parts[0], out uuid); - _creatorID = uuid; + _ = UUID.TryParse(parts[0], out _creatorID); } if (parts.Length >= 2) _creatorData = parts[1]; @@ -165,199 +102,38 @@ public string CreatorIdentification } } - public string Description { - get { - return _description; - } - set { - _description = value; - } - } - - public uint EveryonePermissions { - get { - return _everyoneMask; - } - set { - _everyoneMask = value; - } - } - - public uint Flags { - get { - return _flags; - } - set { - _flags = value; - } - } - - public UUID GroupID { - get { - return _groupID; - } - set { - _groupID = value; - } - } - - public uint GroupPermissions { - get { - return _groupMask; - } - set { - _groupMask = value; - } - } - - public int InvType { - get { - return _invType; - } - set { - _invType = value; - } - } - - public UUID ItemID { - get { - return _itemID; - } - set { - _itemID = value; - } - } - - public UUID OldItemID { - get { - return _oldID; - } - set { - _oldID = value; - } - } - - public UUID LoadedItemID { - get { - return _loadedID; - } - set { - _loadedID = value; - } - } - - public UUID LastOwnerID { - get { - return _lastOwnerID; - } - set { - _lastOwnerID = value; - } - } - - public UUID RezzerID - { - get { - return _rezzerID; - } - set { - _rezzerID = value; - } - } - - public string Name { - get { - return _name; - } - set { - _name = value; - } - } - - public uint NextPermissions { - get { - return _nextOwnerMask; - } - set { - _nextOwnerMask = value; - } - } - - public UUID OwnerID { - get { - return _ownerID; - } - set { - _ownerID = value; - } - } - - public uint CurrentPermissions { - get { - return _ownerMask; - } - set { - _ownerMask = value; - } - } - - public UUID ParentID { - get { - return _parentID; - } - set { - _parentID = value; - } - } - - public UUID ParentPartID { - get { - return _parentPartID; - } - set { - _parentPartID = value; - } - } - - public UUID PermsGranter { - get { - return _permsGranter; - } - set { - _permsGranter = value; - } - } - - public int PermsMask { - get { - return _permsMask; - } - set { - _permsMask = value; - } - } - - public int Type { - get { - return _type; - } - set { - _type = value; - } - } + public uint Flags { get; set; } + public int Type { get; set; } + public int InvType { get; set; } + public UUID ItemID { get; set; } + public UUID OldItemID { get; set; } + public UUID LoadedItemID { get; set; } + public UUID RezzerID { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public UUID OwnerID { get; set; } + public UUID LastOwnerID { get; set; } + public UUID GroupID { get; set; } + public UUID ParentID { get; set; } + public UUID ParentPartID { get; set; } + public uint BasePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint CurrentPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint EveryonePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint GroupPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint NextPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public UUID PermsGranter { get; set; } + public int PermsMask { get; set; } + private bool _ownerChanged = false; public bool OwnerChanged { - get - { - return _ownerChanged; - } + get { return _ownerChanged; } set { _ownerChanged = value; -// m_log.DebugFormat( -// "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}", -// _ownerChanged, Name, ItemID, OwnerID); + //m_log.DebugFormat( + // "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}", + // _ownerChanged, Name, ItemID, OwnerID); } } diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index 7b4905ac2b4..bbaebb838c0 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs @@ -86,7 +86,7 @@ public class TerrainData public int SizeX { get; protected set; } public int SizeY { get; protected set; } - public int SizeZ { get; protected set; } + public const int SizeZ = 0; // A height used when the user doesn't specify anything public const float DefaultTerrainHeight = 21f; @@ -121,6 +121,97 @@ public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, set { this[x, y] = value; } } + public float GetHeight(float x, float y) + { + // integer indexs + int ix, mix; + int iy, miy; + // interpolators offset + float dx; + float dy; + + if (x <= 0) + { + if(y <= 0) + return m_heightmap[0, 0]; + + iy = (int)y; + miy = SizeY - 1; + if (iy >= miy) + return m_heightmap[0, miy]; + + dy = y - iy; + + float h = m_heightmap[0, iy]; + ++iy; + return h + (m_heightmap[0, iy] - h) * dy; + } + + ix = (int)x; + mix = SizeX - 1; + + if (ix >= mix) + { + if(y <= 0) + return m_heightmap[mix, 0]; + + iy = (int)y; + miy = SizeY - 1; + + if (y >= miy) + return m_heightmap[mix, miy]; + + dy = y - iy; + + float h = m_heightmap[mix, iy]; + ++iy; + return h + (m_heightmap[mix, iy] - h) * dy; + } + + dx = x - ix; + + if (y <= 0) + { + float h = m_heightmap[ix, 0]; + ++ix; + return h + (m_heightmap[ix, 0] - h) * dx; + } + + iy = (int)y; + miy = SizeY - 1; + + if (iy >= miy) + { + float h = m_heightmap[ix, miy]; + ++ix; + return h + (m_heightmap[ix, miy] - h) * dx; + } + + dy = y - iy; + + float h0 = m_heightmap[ix, iy]; // 0,0 vertice + float h1; + float h2; + + if (dy > dx) + { + ++iy; + h2 = m_heightmap[ix, iy]; // 0,1 vertice + h1 = (h2 - h0) * dy; // 0,1 vertice minus 0,0 + ++ix; + h2 = (m_heightmap[ix, iy] - h2) * dx; // 1,1 vertice minus 0,1 + } + else + { + ++ix; + h2 = m_heightmap[ix, iy]; // vertice 1,0 + h1 = (h2 - h0) * dx; // 1,0 vertice minus 0,0 + ++iy; + h2 = (m_heightmap[ix, iy] - h2) * dy; // 1,1 vertice minus 1,0 + } + return h0 + h1 + h2; + } + public TerrainTaintsArray GetTaints() { return m_taints; @@ -367,7 +458,6 @@ public TerrainData(double[,] pTerrain) m_mapStride = SizeY; m_mapPatchsStride = m_mapStride * Constants.TerrainPatchSize; - SizeZ = (int)Constants.RegionHeight; CompressionFactor = 100.0f; @@ -390,7 +480,6 @@ public TerrainData(int pX, int pY, int pZ) { SizeX = pX; SizeY = pY; - SizeZ = pZ; m_taintSizeX = SizeX / Constants.TerrainPatchSize; m_taintSizeY = SizeY / Constants.TerrainPatchSize; m_mapStride = SizeY; @@ -519,7 +608,7 @@ public Array ToCompressedTerrainSerializationV2D() for (int xx = 0; xx < SizeX; xx++) { // reduce to 1mm resolution - float val = (float)Math.Round(m_heightmap[xx, yy],3,MidpointRounding.AwayFromZero); + float val = MathF.Round(m_heightmap[xx, yy],3,MidpointRounding.AwayFromZero); bw.Write(val); } } @@ -549,7 +638,7 @@ public Array ToCompressedTerrainSerializationV2DGzip() for (int xx = 0; xx < SizeX; xx++) { //bw.Write((float)m_heightmap[xx, yy]); - bw.Write((float)Math.Round(m_heightmap[xx, yy], 3, MidpointRounding.AwayFromZero)); + bw.Write(MathF.Round(m_heightmap[xx, yy], 3, MidpointRounding.AwayFromZero)); } bw.Flush(); diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs deleted file mode 100644 index c8eb57dd591..00000000000 --- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using NUnit.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class AgentCircuitDataTest : OpenSimTestCase - { - private UUID AgentId; - private AvatarAppearance AvAppearance; - private byte[] VisualParams; - private UUID BaseFolder; - private string CapsPath; - private Dictionary ChildrenCapsPaths; - private uint circuitcode = 0949030; - private string firstname; - private string lastname; - private UUID SecureSessionId; - private UUID SessionId; - private Vector3 StartPos; - - - [SetUp] - public void setup() - { - AgentId = UUID.Random(); - BaseFolder = UUID.Random(); - CapsPath = "http://www.opensimulator.org/Caps/Foo"; - ChildrenCapsPaths = new Dictionary(); - ChildrenCapsPaths.Add(ulong.MaxValue, "http://www.opensimulator.org/Caps/Foo2"); - firstname = "CoolAvatarTest"; - lastname = "test"; - StartPos = new Vector3(5,23,125); - - SecureSessionId = UUID.Random(); - SessionId = UUID.Random(); - - AvAppearance = new AvatarAppearance(); - VisualParams = new byte[218]; - - //body - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_THICKNESS] = 00; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BODY_FAT] = 0; - - //Torso - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_TORSO_MUSCLES] = 48; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_NECK_THICKNESS] = 43; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_NECK_LENGTH] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SHOULDERS] = 94; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_CHEST_MALE_NO_PECS] = 199; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_ARM_LENGTH] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HAND_SIZE] = 33; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_TORSO_LENGTH] = 240; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LOVE_HANDLES] = 0; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BELLY_SIZE] = 0; - - // legs - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LEG_MUSCLES] = 82; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LEG_LENGTH] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HIP_WIDTH] = 84; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HIP_LENGTH] = 166; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BUTT_SIZE] = 64; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SADDLEBAGS] = 89; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BOWED_LEGS] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOOT_SIZE] = 45; - - - // head - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SIZE] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SQUASH_STRETCH_HEAD] = 0; // head stretch - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SHAPE] = 155; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EGG_HEAD] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_POINTY_EARS] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_LENGTH] = 45; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FACE_SHEAR] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOREHEAD_ANGLE] = 104; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BIG_BROW] = 94; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_PUFFY_UPPER_CHEEKS] = 0; // upper cheeks - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_DOUBLE_CHIN] = 122; // lower cheeks - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HIGH_CHEEK_BONES] = 130; - - - - // eyes - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYE_SIZE] = 105; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_WIDE_EYES] = 135; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYE_SPACING] = 184; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYELID_CORNER_UP] = 230; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYELID_INNER_CORNER_UP] = 120; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYE_DEPTH] = 158; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_UPPER_EYELID_FOLD] = 69; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BAGGY_EYES] = 38; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EYELASHES_LONG] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_POP_EYE] = 127; - - VisualParams[(int)AvatarAppearance.VPElement.EYES_EYE_COLOR] = 25; - VisualParams[(int)AvatarAppearance.VPElement.EYES_EYE_LIGHTNESS] = 127; - - // ears - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BIG_EARS] = 255; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_EARS_OUT] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_ATTACHED_EARLOBES] = 127; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_POINTY_EARS] = 255; - - // nose - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_NOSE_BIG_OUT] = 79; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_WIDE_NOSE] = 35; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BROAD_NOSTRILS] = 86; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LOW_SEPTUM_NOSE] = 112; // nostril division - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BULBOUS_NOSE] = 25; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_NOBLE_NOSE_BRIDGE] = 25; // upper bridge - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LOWER_BRIDGE_NOSE] = 25; // lower bridge - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_WIDE_NOSE_BRIDGE] = 25; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_UPTURNED_NOSE_TIP] = 107; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BULBOUS_NOSE_TIP] = 25; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_CROOKED_NOSE] = 127; - - - // Mouth - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LIP_WIDTH] = 122; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_TALL_LIPS] = 10; // lip fullness - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LIP_THICKNESS] = 112; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LIP_RATIO] = 137; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MOUTH_HEIGHT] = 176; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_MOUTH_CORNER] = 140; // Sad --> happy - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_LIP_CLEFT_DEEP] = 84; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_WIDE_LIP_CLEFT] = 84; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SHIFT_MOUTH] = 127; - - - // chin - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_WEAK_CHIN] = 119; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SQUARE_JAW] = 5; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_DEEP_CHIN] = 132; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_JAW_ANGLE] = 153; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_JAW_JUT] = 100; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_JOWLS] = 38; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_CLEFT_CHIN] = 89; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_CLEFT_CHIN_UPPER] = 89; - VisualParams[(int)AvatarAppearance.VPElement.SHAPE_DOUBLE_CHIN] = 0; - - - // hair color - VisualParams[(int)AvatarAppearance.VPElement.HAIR_WHITE_HAIR] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_RAINBOW_COLOR_39] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_BLONDE_HAIR] = 24; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_RED_HAIR] = 0; - - // hair style - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_VOLUME] = 160; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_FRONT] = 153; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SIDES] = 153; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_BACK] = 170; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_BIG_FRONT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_BIG_TOP] = 117; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_BIG_BACK] = 170; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_FRONT_FRINGE] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_SIDE_FRINGE] = 142; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_BACK_FRINGE] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SIDES_FULL] = 146; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SWEEP] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SHEAR_FRONT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SHEAR_BACK] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_TAPER_FRONT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_TAPER_BACK] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_RUMPLED] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_PIGTAILS] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_PONYTAIL] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_SPIKED] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_TILT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_PART_MIDDLE] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_PART_RIGHT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_PART_LEFT] = 0; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_BANGS_PART_MIDDLE] = 155; - - //Eyebrows - VisualParams[(int)AvatarAppearance.VPElement.HAIR_EYEBROW_SIZE] = 20; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_EYEBROW_DENSITY] = 140; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_LOWER_EYEBROWS] = 200; // eyebrow height - VisualParams[(int)AvatarAppearance.VPElement.HAIR_ARCED_EYEBROWS] = 124; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_POINTY_EYEBROWS] = 65; - - //Facial hair - VisualParams[(int)AvatarAppearance.VPElement.HAIR_HAIR_THICKNESS] = 65; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_SIDEBURNS] = 235; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_MOUSTACHE] = 75; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_CHIN_CURTAINS] = 140; - VisualParams[(int)AvatarAppearance.VPElement.HAIR_SOULPATCH] = 0; - - AvAppearance.VisualParams = VisualParams; - - AvAppearance.SetAppearance(AvAppearance.Texture, (byte[])VisualParams.Clone()); - } - - /// - /// Test to ensure that the serialization format is the same and the underlying types don't change without notice - /// oldSerialization is just a json serialization of the OSDMap packed for the AgentCircuitData. - /// The idea is that if the current json serializer cannot parse the old serialization, then the underlying types - /// have changed and are incompatible. - /// - [Test] - public void HistoricalAgentCircuitDataOSDConversion() - { - string oldSerialization = "{\"agent_id\":\"522675bd-8214-40c1-b3ca-9c7f7fd170be\",\"base_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"caps_path\":\"http://www.opensimulator.org/Caps/Foo\",\"children_seeds\":[{\"handle\":\"18446744073709551615\",\"seed\":\"http://www.opensimulator.org/Caps/Foo2\"}],\"child\":false,\"circuit_code\":\"949030\",\"first_name\":\"CoolAvatarTest\",\"last_name\":\"test\",\"inventory_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"secure_session_id\":\"1e608e2b-0ddb-41f6-be0f-926f61cd3e0a\",\"session_id\":\"aa06f798-9d70-4bdb-9bbf-012a02ee2baf\",\"start_pos\":\"<5, 23, 125>\"}"; - AgentCircuitData Agent1Data = new AgentCircuitData(); - Agent1Data.AgentID = new UUID("522675bd-8214-40c1-b3ca-9c7f7fd170be"); - Agent1Data.Appearance = AvAppearance; - Agent1Data.BaseFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); - Agent1Data.CapsPath = CapsPath; - Agent1Data.child = false; - Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; - Agent1Data.circuitcode = circuitcode; - Agent1Data.firstname = firstname; - Agent1Data.InventoryFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); - Agent1Data.lastname = lastname; - Agent1Data.SecureSessionID = new UUID("1e608e2b-0ddb-41f6-be0f-926f61cd3e0a"); - Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf"); - Agent1Data.startpos = StartPos; - - - OSDMap map2; - try - { - map2 = (OSDMap) OSDParser.DeserializeJson(oldSerialization); - - - AgentCircuitData Agent2Data = new AgentCircuitData(); - Agent2Data.UnpackAgentCircuitData(map2); - - Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); - Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); - - Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); - Assert.That((Agent1Data.child == Agent2Data.child)); - Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); - Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); - Assert.That((Agent1Data.firstname == Agent2Data.firstname)); - Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); - Assert.That((Agent1Data.lastname == Agent2Data.lastname)); - Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); - Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); - Assert.That((Agent1Data.startpos == Agent2Data.startpos)); - } - catch (LitJson.JsonException) - { - //intermittant litjson errors :P - Assert.That(1 == 1); - } - /* - Enable this once VisualParams go in the packing method - for (int i=0;i<208;i++) - Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); - */ - } - - /// - /// Test to ensure that the packing and unpacking methods work. - /// - [Test] - public void TestAgentCircuitDataOSDConversion() - { - AgentCircuitData Agent1Data = new AgentCircuitData(); - Agent1Data.AgentID = AgentId; - Agent1Data.Appearance = AvAppearance; - Agent1Data.BaseFolder = BaseFolder; - Agent1Data.CapsPath = CapsPath; - Agent1Data.child = false; - Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; - Agent1Data.circuitcode = circuitcode; - Agent1Data.firstname = firstname; - Agent1Data.InventoryFolder = BaseFolder; - Agent1Data.lastname = lastname; - Agent1Data.SecureSessionID = SecureSessionId; - Agent1Data.SessionID = SessionId; - Agent1Data.startpos = StartPos; - - EntityTransferContext ctx = new EntityTransferContext(); - OSDMap map2; - OSDMap map = Agent1Data.PackAgentCircuitData(ctx); - try - { - string str = OSDParser.SerializeJsonString(map); - //System.Console.WriteLine(str); - map2 = (OSDMap) OSDParser.DeserializeJson(str); - } - catch (System.NullReferenceException) - { - //spurious litjson errors :P - map2 = map; - Assert.That(1==1); - return; - } - - AgentCircuitData Agent2Data = new AgentCircuitData(); - Agent2Data.UnpackAgentCircuitData(map2); - - Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); - Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); - - Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); - Assert.That((Agent1Data.child == Agent2Data.child)); - Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); - Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); - Assert.That((Agent1Data.firstname == Agent2Data.firstname)); - Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); - Assert.That((Agent1Data.lastname == Agent2Data.lastname)); - Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); - Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); - Assert.That((Agent1Data.startpos == Agent2Data.startpos)); - - /* - Enable this once VisualParams go in the packing method - for (int i = 0; i < 208; i++) - Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); - */ - - - } - } -} diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs deleted file mode 100644 index 2558f300385..00000000000 --- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using OpenMetaverse; -using NUnit.Framework; -using System; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class AgentCircuitManagerTests - { - private AgentCircuitData m_agentCircuitData1; - private AgentCircuitData m_agentCircuitData2; - private UUID AgentId1; - private UUID AgentId2; - private uint circuitcode1; - private uint circuitcode2; - - private UUID SessionId1; - private UUID SessionId2; - private Random rnd = new Random(Environment.TickCount); - - [SetUp] - public void setup() - { - - AgentId1 = UUID.Random(); - AgentId2 = UUID.Random(); - circuitcode1 = (uint) rnd.Next((int)uint.MinValue, int.MaxValue); - circuitcode2 = (uint) rnd.Next((int)uint.MinValue, int.MaxValue); - SessionId1 = UUID.Random(); - SessionId2 = UUID.Random(); - UUID BaseFolder = UUID.Random(); - string CapsPath = "http://www.opensimulator.org/Caps/Foo"; - Dictionary ChildrenCapsPaths = new Dictionary(); - ChildrenCapsPaths.Add(ulong.MaxValue, "http://www.opensimulator.org/Caps/Foo2"); - string firstname = "CoolAvatarTest"; - string lastname = "test"; - Vector3 StartPos = new Vector3(5, 23, 125); - - UUID SecureSessionId = UUID.Random(); - // TODO: unused: UUID SessionId = UUID.Random(); - - m_agentCircuitData1 = new AgentCircuitData(); - m_agentCircuitData1.AgentID = AgentId1; - m_agentCircuitData1.Appearance = new AvatarAppearance(); - m_agentCircuitData1.BaseFolder = BaseFolder; - m_agentCircuitData1.CapsPath = CapsPath; - m_agentCircuitData1.child = false; - m_agentCircuitData1.ChildrenCapSeeds = ChildrenCapsPaths; - m_agentCircuitData1.circuitcode = circuitcode1; - m_agentCircuitData1.firstname = firstname; - m_agentCircuitData1.InventoryFolder = BaseFolder; - m_agentCircuitData1.lastname = lastname; - m_agentCircuitData1.SecureSessionID = SecureSessionId; - m_agentCircuitData1.SessionID = SessionId1; - m_agentCircuitData1.startpos = StartPos; - - m_agentCircuitData2 = new AgentCircuitData(); - m_agentCircuitData2.AgentID = AgentId2; - m_agentCircuitData2.Appearance = new AvatarAppearance(); - m_agentCircuitData2.BaseFolder = BaseFolder; - m_agentCircuitData2.CapsPath = CapsPath; - m_agentCircuitData2.child = false; - m_agentCircuitData2.ChildrenCapSeeds = ChildrenCapsPaths; - m_agentCircuitData2.circuitcode = circuitcode2; - m_agentCircuitData2.firstname = firstname; - m_agentCircuitData2.InventoryFolder = BaseFolder; - m_agentCircuitData2.lastname = lastname; - m_agentCircuitData2.SecureSessionID = SecureSessionId; - m_agentCircuitData2.SessionID = SessionId2; - m_agentCircuitData2.startpos = StartPos; - } - - /// - /// Validate that adding the circuit works appropriately - /// - [Test] - public void AddAgentCircuitTest() - { - AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); - agentCircuitManager.AddNewCircuit(circuitcode1,m_agentCircuitData1); - agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); - AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(circuitcode1); - - Assert.That((m_agentCircuitData1.AgentID == agent.AgentID)); - Assert.That((m_agentCircuitData1.BaseFolder == agent.BaseFolder)); - - Assert.That((m_agentCircuitData1.CapsPath == agent.CapsPath)); - Assert.That((m_agentCircuitData1.child == agent.child)); - Assert.That((m_agentCircuitData1.ChildrenCapSeeds.Count == agent.ChildrenCapSeeds.Count)); - Assert.That((m_agentCircuitData1.circuitcode == agent.circuitcode)); - Assert.That((m_agentCircuitData1.firstname == agent.firstname)); - Assert.That((m_agentCircuitData1.InventoryFolder == agent.InventoryFolder)); - Assert.That((m_agentCircuitData1.lastname == agent.lastname)); - Assert.That((m_agentCircuitData1.SecureSessionID == agent.SecureSessionID)); - Assert.That((m_agentCircuitData1.SessionID == agent.SessionID)); - Assert.That((m_agentCircuitData1.startpos == agent.startpos)); - } - - /// - /// Validate that removing the circuit code removes it appropriately - /// - [Test] - public void RemoveAgentCircuitTest() - { - AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); - agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); - agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); - agentCircuitManager.RemoveCircuit(circuitcode2); - - AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(circuitcode2); - Assert.That(agent == null); - - } - - /// - /// Validate that changing the circuit code works - /// - [Test] - public void ChangeAgentCircuitCodeTest() - { - AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); - agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); - agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); - bool result = false; - - result = agentCircuitManager.TryChangeCircuitCode(circuitcode1, 393930); - - AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(393930); - AgentCircuitData agent2 = agentCircuitManager.GetAgentCircuitData(circuitcode1); - Assert.That(agent != null); - Assert.That(agent2 == null); - Assert.That(result); - - } - - /// - /// Validates that the login authentication scheme is working - /// First one should be authorized - /// Rest should not be authorized - /// - [Test] - public void ValidateLoginTest() - { - AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); - agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); - agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); - - // should be authorized - AuthenticateResponse resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode1); - Assert.That(resp.Authorised); - - - //should not be authorized - resp = agentCircuitManager.AuthenticateSession(SessionId1, UUID.Random(), circuitcode1); - Assert.That(!resp.Authorised); - - resp = agentCircuitManager.AuthenticateSession(UUID.Random(), AgentId1, circuitcode1); - Assert.That(!resp.Authorised); - - resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode2); - Assert.That(!resp.Authorised); - - resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId1, circuitcode2); - Assert.That(!resp.Authorised); - - agentCircuitManager.RemoveCircuit(circuitcode2); - - resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2); - Assert.That(!resp.Authorised); - } - } -} diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs deleted file mode 100644 index daf86118755..00000000000 --- a/OpenSim/Framework/Tests/AnimationTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Tests.Common; -using Animation = OpenSim.Framework.Animation; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class AnimationTests : OpenSimTestCase - { - private Animation anim1 = null; - private Animation anim2 = null; - private UUID animUUID1 = UUID.Zero; - private UUID objUUID1 = UUID.Zero; - private UUID animUUID2 = UUID.Zero; - private UUID objUUID2 = UUID.Zero; - - [SetUp] - public void Setup() - { - animUUID1 = UUID.Random(); - animUUID2 = UUID.Random(); - objUUID1 = UUID.Random(); - objUUID2 = UUID.Random(); - - anim1 = new Animation(animUUID1, 1, objUUID1); - anim2 = new Animation(animUUID2, 1, objUUID2); - } - - [Test] - public void AnimationOSDTest() - { - Assert.That(anim1.AnimID==animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum ==1, "The Animation Constructor didn't set the fields correctly"); - OSD updateMessage = anim1.PackUpdateMessage(); - Assert.That(updateMessage is OSDMap, "Packed UpdateMessage isn't an OSDMap"); - OSDMap updateMap = (OSDMap) updateMessage; - Assert.That(updateMap.ContainsKey("animation"), "Packed Message doesn't contain an animation element"); - Assert.That(updateMap.ContainsKey("object_id"), "Packed Message doesn't contain an object_id element"); - Assert.That(updateMap.ContainsKey("seq_num"), "Packed Message doesn't contain a seq_num element"); - Assert.That(updateMap["animation"].AsUUID() == animUUID1); - Assert.That(updateMap["object_id"].AsUUID() == objUUID1); - Assert.That(updateMap["seq_num"].AsInteger() == 1); - - Animation anim3 = new Animation(updateMap); - - Assert.That(anim3.ObjectID == anim1.ObjectID && anim3.AnimID == anim1.AnimID && anim3.SequenceNum == anim1.SequenceNum, "OSDMap Constructor failed to set the properties correctly."); - - anim3.UnpackUpdateMessage(anim2.PackUpdateMessage()); - - Assert.That(anim3.ObjectID == objUUID2 && anim3.AnimID == animUUID2 && anim3.SequenceNum == 1, "Animation.UnpackUpdateMessage failed to set the properties correctly."); - - Animation anim4 = new Animation(); - anim4.AnimID = anim2.AnimID; - anim4.ObjectID = anim2.ObjectID; - anim4.SequenceNum = anim2.SequenceNum; - - Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs deleted file mode 100644 index 1975a4df7e5..00000000000 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class AssetBaseTest : OpenSimTestCase - { - [Test] - public void TestContainsReferences() - { - CheckContainsReferences(AssetType.Bodypart, true); - CheckContainsReferences(AssetType.Clothing, true); - - CheckContainsReferences(AssetType.Animation, false); - CheckContainsReferences(AssetType.CallingCard, false); - CheckContainsReferences(AssetType.Folder , false); - CheckContainsReferences(AssetType.Gesture , false); - CheckContainsReferences(AssetType.ImageJPEG , false); - CheckContainsReferences(AssetType.ImageTGA , false); - CheckContainsReferences(AssetType.Landmark , false); - CheckContainsReferences(AssetType.LSLBytecode, false); - CheckContainsReferences(AssetType.LSLText, false); - CheckContainsReferences(AssetType.Notecard, false); - CheckContainsReferences(AssetType.Object, false); - CheckContainsReferences(AssetType.Simstate, false); - CheckContainsReferences(AssetType.Sound, false); - CheckContainsReferences(AssetType.SoundWAV, false); - CheckContainsReferences(AssetType.Texture, false); - CheckContainsReferences(AssetType.TextureTGA, false); - CheckContainsReferences(AssetType.Unknown, false); - } - - private void CheckContainsReferences(AssetType assetType, bool expected) - { - AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType, UUID.Zero.ToString()); - bool actual = asset.ContainsReferences; - Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); - } - } -} diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs deleted file mode 100644 index fc7df692b97..00000000000 --- a/OpenSim/Framework/Tests/CacheTests.cs +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenMetaverse; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class CacheTests : OpenSimTestCase - { - private Cache cache; - private UUID cacheItemUUID; - [SetUp] - public void Build() - { - cache = new Cache(); - cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate); - cacheItemUUID = UUID.Random(); - MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); - byte[] foo = new byte[1]; - foo[0] = 255; - cachedItem.Store(foo); - cache.Store(cacheItemUUID.ToString(), cachedItem); - } - [Test] - public void TestRetreive() - { - CacheItemBase citem = (CacheItemBase)cache.Get(cacheItemUUID.ToString()); - byte[] data = (byte[]) citem.Retrieve(); - Assert.That(data.Length == 1, "Cached Item should have one byte element"); - Assert.That(data[0] == 255, "Cached Item element should be 255"); - } - - [Test] - public void TestNotInCache() - { - UUID randomNotIn = UUID.Random(); - while (randomNotIn == cacheItemUUID) - { - randomNotIn = UUID.Random(); - } - object citem = cache.Get(randomNotIn.ToString()); - Assert.That(citem == null, "Item should not be in Cache"); - } - - - [Test] - public void ExpireItemManually() - { - UUID ImmediateExpiryUUID = UUID.Random(); - MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); - byte[] foo = new byte[1]; - foo[0] = 1; - cachedItem.Store(foo); - cache.Store(cacheItemUUID.ToString(), cachedItem); - cache.Invalidate(cacheItemUUID.ToString()); - cache.Get(cacheItemUUID.ToString()); - object citem = cache.Get(cacheItemUUID.ToString()); - Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); - } - - [Test] - public void ClearCacheTest() - { - UUID ImmediateExpiryUUID = UUID.Random(); - MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), DateTime.Now - TimeSpan.FromDays(1)); - byte[] foo = new byte[1]; - foo[0] = 1; - cachedItem.Store(foo); - cache.Store(cacheItemUUID.ToString(), cachedItem); - cache.Clear(); - - object citem = cache.Get(cacheItemUUID.ToString()); - Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); - } - - [Test] - public void CacheItemMundane() - { - UUID Random1 = UUID.Random(); - UUID Random2 = UUID.Random(); - byte[] data = Array.Empty(); - CacheItemBase cb1 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); - CacheItemBase cb2 = new CacheItemBase(Random2.ToString(), DateTime.Now + TimeSpan.FromDays(1)); - CacheItemBase cb3 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); - - cb1.Store(data); - - Assert.That(cb1.Equals(cb3), "cb1 should equal cb3, their uuids are the same"); - Assert.That(!cb2.Equals(cb1), "cb2 should not equal cb1, their uuids are NOT the same"); - Assert.That(cb1.IsLocked() == false, "CacheItemBase default is false"); - Assert.That(cb1.Retrieve() == null, "Virtual Retrieve method should return null"); - - - } - - } -} diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs deleted file mode 100644 index 5e84026708a..00000000000 --- a/OpenSim/Framework/Tests/LocationTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class LocationTest : OpenSimTestCase - { - [Test] - public void locationRegionHandleRegionHandle() - { - //1099511628032000 - // 256000 - // 256000 - Location TestLocation1 = new Location(1099511628032000); - Location TestLocation2 = new Location(1099511628032000); - Assert.That(TestLocation1 == TestLocation2); - - TestLocation1 = new Location(1099511628032001); - TestLocation2 = new Location(1099511628032000); - Assert.That(TestLocation1 != TestLocation2); - } - - [Test] - public void locationXYRegionHandle() - { - Location TestLocation1 = new Location(255000,256000); - Location TestLocation2 = new Location(1095216660736000); - Assert.That(TestLocation1 == TestLocation2); - - Assert.That(TestLocation1.X == 255000 && TestLocation1.Y == 256000, "Test xy location doesn't match position in the constructor"); - Assert.That(TestLocation2.X == 255000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided"); - - Assert.That(TestLocation2.RegionHandle == 1095216660736000, - "Location RegionHandle Property didn't match regionhandle provided in constructor"); - - ulong RegionHandle = TestLocation1.RegionHandle; - Assert.That(RegionHandle.Equals(1095216660736000), "Equals(regionhandle) failed to match the position in the constructor"); - - TestLocation2 = new Location(RegionHandle); - Assert.That(TestLocation2.Equals(255000, 256000), "Decoded regionhandle failed to match the original position in the constructor"); - - - TestLocation1 = new Location(255001, 256001); - TestLocation2 = new Location(1095216660736000); - Assert.That(TestLocation1 != TestLocation2); - - Assert.That(TestLocation1.Equals(255001, 256001), "Equals(x,y) failed to match the position in the constructor"); - - Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode"); - - Location TestLocation3; - object cln = TestLocation2.Clone(); - TestLocation3 = (Location) cln; - Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y, - "Cloned Location values do not match"); - - Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test"); - - } - - } -} diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs deleted file mode 100644 index 3d99c412246..00000000000 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenSim.Framework; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using System; -using System.Globalization; -using System.Threading; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class MundaneFrameworkTests : OpenSimTestCase - { - private bool m_RegionSettingsOnSaveEventFired; - - [Test] - public void ChildAgentDataUpdate01() - { - // code coverage - ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); - Assert.IsFalse(cadu.alwaysrun, "Default is false"); - } - - [Test] - public void AgentPositionTest01() - { - UUID AgentId1 = UUID.Random(); - UUID SessionId1 = UUID.Random(); - uint CircuitCode1 = uint.MinValue; - Vector3 Size1 = Vector3.UnitZ; - Vector3 Position1 = Vector3.UnitX; - Vector3 LeftAxis1 = Vector3.UnitY; - Vector3 UpAxis1 = Vector3.UnitZ; - Vector3 AtAxis1 = Vector3.UnitX; - - ulong RegionHandle1 = ulong.MinValue; - byte[] Throttles1 = new byte[] {0, 1, 0}; - - Vector3 Velocity1 = Vector3.Zero; - float Far1 = 256; - - bool ChangedGrid1 = false; - Vector3 Center1 = Vector3.Zero; - - AgentPosition position1 = new AgentPosition(); - position1.AgentID = AgentId1; - position1.SessionID = SessionId1; - position1.CircuitCode = CircuitCode1; - position1.Size = Size1; - position1.Position = Position1; - position1.LeftAxis = LeftAxis1; - position1.UpAxis = UpAxis1; - position1.AtAxis = AtAxis1; - position1.RegionHandle = RegionHandle1; - position1.Throttles = Throttles1; - position1.Velocity = Velocity1; - position1.Far = Far1; - position1.ChangedGrid = ChangedGrid1; - position1.Center = Center1; - - ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); - cadu.AgentID = AgentId1.Guid; - cadu.ActiveGroupID = UUID.Zero.Guid; - cadu.throttles = Throttles1; - cadu.drawdistance = Far1; - cadu.Position = Position1; - cadu.Velocity = Velocity1; - cadu.regionHandle = RegionHandle1; - cadu.cameraPosition = Center1; - cadu.AVHeight = Size1.Z; - - AgentPosition position2 = new AgentPosition(); - position2.CopyFrom(cadu, position1.SessionID); - - Assert.IsTrue( - position2.AgentID == position1.AgentID - && position2.Size == position1.Size - && position2.Position == position1.Position - && position2.Velocity == position1.Velocity - && position2.Center == position1.Center - && position2.RegionHandle == position1.RegionHandle - && position2.Far == position1.Far - - ,"Copy From ChildAgentDataUpdate failed"); - - position2 = new AgentPosition(); - - Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); - EntityTransferContext ctx = new EntityTransferContext(); - position2.Unpack(position1.Pack(ctx), null, ctx); - - Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); - Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); - Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed"); - Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed"); - Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed"); - Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed"); - Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed"); - Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed"); - Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed"); - Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed"); - Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed"); - Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); - - } - - [Test] - public void RegionSettingsTest01() - { - RegionSettings settings = new RegionSettings(); - settings.OnSave += RegionSaveFired; - settings.Save(); - settings.OnSave -= RegionSaveFired; - -// string str = settings.LoadedCreationDate; -// int dt = settings.LoadedCreationDateTime; -// string id = settings.LoadedCreationID; -// string time = settings.LoadedCreationTime; - - Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire"); - - } - public void RegionSaveFired(RegionSettings settings) - { - m_RegionSettingsOnSaveEventFired = true; - } - - [Test] - public void InventoryItemBaseConstructorTest01() - { - InventoryItemBase b1 = new InventoryItemBase(); - Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero"); - Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero"); - - UUID ItemID = UUID.Random(); - UUID OwnerID = UUID.Random(); - - InventoryItemBase b2 = new InventoryItemBase(ItemID); - Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID"); - Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero"); - - InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID); - Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID"); - Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID"); - - } - - [Test] - public void AssetMetaDataNonNullContentTypeTest01() - { - AssetMetadata assetMetadata = new AssetMetadata(); - assetMetadata.ContentType = "image/jp2"; - Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture"); - Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2"); - UUID rndID = UUID.Random(); - assetMetadata.ID = rndID.ToString(); - Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent"); - DateTime fixedTime = DateTime.Now; - assetMetadata.CreationDate = fixedTime; - } - - [Test] - public void EstateSettingsMundateTests() - { - EstateSettings es = new EstateSettings(); - es.AddBan(null); - UUID bannedUserId = UUID.Random(); - es.AddBan(new EstateBan() - { BannedHostAddress = string.Empty, - BannedHostIPMask = string.Empty, - BannedHostNameMask = string.Empty, - BannedUserID = bannedUserId} - ); - Assert.IsTrue(es.IsBanned(bannedUserId, 32), "User Should be banned but is not."); - Assert.IsFalse(es.IsBanned(UUID.Zero, 32), "User Should not be banned but is."); - - es.RemoveBan(bannedUserId); - - Assert.IsFalse(es.IsBanned(bannedUserId, 32), "User Should not be banned but is."); - - es.AddEstateManager(UUID.Zero); - - es.AddEstateManager(bannedUserId); - Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserId should be EstateManager but isn't."); - - es.RemoveEstateManager(bannedUserId); - Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserID is estateManager but shouldn't be"); - - Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); - - es.AddEstateUser(bannedUserId); - - Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); - es.RemoveEstateUser(bannedUserId); - - es.AddEstateManager(bannedUserId); - - Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); - - Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length"); - - es.AddEstateGroup(bannedUserId); - - Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length"); - - Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups"); - - } - - [Test] - public void InventoryFolderBaseConstructorTest01() - { - UUID uuid1 = UUID.Random(); - UUID uuid2 = UUID.Random(); - - InventoryFolderBase fld = new InventoryFolderBase(uuid1); - Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field."); - - fld = new InventoryFolderBase(uuid1, uuid2); - Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field."); - Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field."); - } - - [Test] - public void AsssetBaseConstructorTest01() - { - AssetBase abase = new AssetBase(); - Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't."); - UUID itemID = UUID.Random(); - UUID creatorID = UUID.Random(); - abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString()); - - Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't."); - Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property"); - Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID"); - - - abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString()); - Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't."); - Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again"); - - AssetMetadata metts = new AssetMetadata(); - metts.FullID = itemID; - metts.ID = string.Empty; - metts.Name = "test item"; - abase.Metadata = metts; - - Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()"); - Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property"); - } - - [Test] - public void CultureSetCultureTest01() - { - CultureInfo ci = new CultureInfo("en-US", false); - Culture.SetCurrentCulture(); - Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); - - } - } -} diff --git a/OpenSim/Framework/Tests/OpenSim.Framework.Tests.csproj b/OpenSim/Framework/Tests/OpenSim.Framework.Tests.csproj deleted file mode 100644 index 9a85b9f3921..00000000000 --- a/OpenSim/Framework/Tests/OpenSim.Framework.Tests.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - net48 - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - ..\..\..\bin\XMLRPC.dll - False - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs deleted file mode 100644 index cc30fb97d6a..00000000000 --- a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class PrimeNumberHelperTests : OpenSimTestCase - { - [Test] - public void TestGetPrime() - { - int prime1 = PrimeNumberHelper.GetPrime(7919); - Assert.That(prime1 == 8419, "Prime Number Get Prime Failed, 7919 is prime"); - Assert.That(PrimeNumberHelper.IsPrime(prime1),"Prime1 should be prime"); - Assert.That(PrimeNumberHelper.IsPrime(7919), "7919 is prime but is falsely failing the prime test"); - prime1 = PrimeNumberHelper.GetPrime(Int32.MaxValue - 1); - Assert.That(prime1 == -1, "prime1 should have been -1 since there are no primes between Int32.MaxValue-1 and Int32.MaxValue"); - - } - - [Test] - public void Test1000SmallPrimeNumbers() - { - int[] primes = { - 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, - 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191 - , 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, - 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, - 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, - 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, - 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, - 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, - 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, - 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, - 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, - 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, - 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, - 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, - 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, - 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, - 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, - 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, - 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, - 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, - 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, - 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, - 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, - 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, - 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, - 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, - 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, - 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, - 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, - 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, - 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, - 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, - 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, - 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, - 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, - 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, - 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, - 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, - 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, - 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, - 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, - 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, - 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, - 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, - 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, - 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, - 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, - 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, - 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, - 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, - 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, - 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, - 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, - 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, - 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, - 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, - 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, - 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, - 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, - 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, - 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, - 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, - 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, - 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, - 7877, 7879, 7883, 7901, 7907, 7919 - }; - for (int i = 0; i < primes.Length; i++) - { - Assert.That(PrimeNumberHelper.IsPrime(primes[i]),primes[i] + " is prime but is erroniously failing the prime test"); - } - - int[] nonprimes = { - 4, 6, 8, 10, 14, 16, 18, 22, 28, 30, 36, 40, 42, 46, 52, 58, 60, 66, 70, 72, 78, 82, 88, - 96, 366, 372, 378, 382, 388, 396, 400, 408, 418, 420, 430, 432, 438, 442, 448, 456, 460, 462, - 466, 478, 486, 490, 498, 502, 508, 856, 858, 862, 876, 880, 882, 886, 906, 910, 918, 928, 936, - 940, 946, 952, 966, 970, 976, 982, 990, 996, 1008, 1740, 1746, 1752, 1758, 4650, 4656, 4662, - 4672, 4678, 4690, 7740, 7752, 7756, 7758, 7788, 7792, 7816, 7822, 7828, 7840, 7852, 7866, 7872, - 7876, 7878, 7882, 7900, 7906, 7918 - }; - for (int i = 0; i < nonprimes.Length; i++) - { - Assert.That(!PrimeNumberHelper.IsPrime(nonprimes[i]), nonprimes[i] + " is not prime but is erroniously passing the prime test"); - } - - Assert.That(PrimeNumberHelper.IsPrime(3)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs deleted file mode 100644 index b3d79eec971..00000000000 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenMetaverse; -using OpenSim.Tests.Common; - -namespace OpenSim.Framework.Tests -{ - [TestFixture] - public class UtilTests : OpenSimTestCase - { - [Test] - public void VectorOperationTests() - { - Vector3 v1, v2; - double expectedDistance; - double expectedMagnitude; - double lowPrecisionTolerance = 0.001; - - //Lets test a simple case of <0,0,0> and <5,5,5> - { - v1 = new Vector3(0, 0, 0); - v2 = new Vector3(5, 5, 5); - expectedDistance = 8.66; - Assert.That(Util.GetDistanceTo(v1, v2), - new DoubleToleranceConstraint(expectedDistance, lowPrecisionTolerance), - "Calculated distance between two vectors was not within tolerances."); - - expectedMagnitude = 0; - Assert.That(Util.GetMagnitude(v1), Is.EqualTo(0), "Magnitude of null vector was not zero."); - - expectedMagnitude = 8.66; - Assert.That(Util.GetMagnitude(v2), - new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), - "Magnitude of vector was incorrect."); -/* - TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; - bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); - Assert.That(causesArgumentException, Is.True, - "Getting magnitude of null vector did not cause argument exception."); -*/ - Vector3 expectedNormalizedVector = new Vector3(.577f, .577f, .577f); - double expectedNormalizedMagnitude = 1; - Vector3 normalizedVector = Util.GetNormalizedVector(v2); - Assert.That(normalizedVector, - new VectorToleranceConstraint(expectedNormalizedVector, lowPrecisionTolerance), - "Normalized vector generated from vector was not what was expected."); - Assert.That(Util.GetMagnitude(normalizedVector), - new DoubleToleranceConstraint(expectedNormalizedMagnitude, lowPrecisionTolerance), - "Normalized vector generated from vector does not have magnitude of 1."); - } - - //Lets test a simple case of <0,0,0> and <0,0,0> - { - v1 = new Vector3(0, 0, 0); - v2 = new Vector3(0, 0, 0); - expectedDistance = 0; - Assert.That(Util.GetDistanceTo(v1, v2), - new DoubleToleranceConstraint(expectedDistance, lowPrecisionTolerance), - "Calculated distance between two vectors was not within tolerances."); - - expectedMagnitude = 0; - Assert.That(Util.GetMagnitude(v1), Is.EqualTo(0), "Magnitude of null vector was not zero."); - - expectedMagnitude = 0; - Assert.That(Util.GetMagnitude(v2), - new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), - "Magnitude of vector was incorrect."); -/* - TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; - bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); - Assert.That(causesArgumentException, Is.True, - "Getting magnitude of null vector did not cause argument exception."); - - d = delegate() { Util.GetNormalizedVector(v2); }; - causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); - Assert.That(causesArgumentException, Is.True, - "Getting magnitude of null vector did not cause argument exception."); -*/ - } - - //Lets test a simple case of <0,0,0> and <-5,-5,-5> - { - v1 = new Vector3(0, 0, 0); - v2 = new Vector3(-5, -5, -5); - expectedDistance = 8.66; - Assert.That(Util.GetDistanceTo(v1, v2), - new DoubleToleranceConstraint(expectedDistance, lowPrecisionTolerance), - "Calculated distance between two vectors was not within tolerances."); - - expectedMagnitude = 0; - Assert.That(Util.GetMagnitude(v1), Is.EqualTo(0), "Magnitude of null vector was not zero."); - - expectedMagnitude = 8.66; - Assert.That(Util.GetMagnitude(v2), - new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), - "Magnitude of vector was incorrect."); -/* - TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; - bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); - Assert.That(causesArgumentException, Is.True, - "Getting magnitude of null vector did not cause argument exception."); -*/ - Vector3 expectedNormalizedVector = new Vector3(-.577f, -.577f, -.577f); - double expectedNormalizedMagnitude = 1; - Vector3 normalizedVector = Util.GetNormalizedVector(v2); - Assert.That(normalizedVector, - new VectorToleranceConstraint(expectedNormalizedVector, lowPrecisionTolerance), - "Normalized vector generated from vector was not what was expected."); - Assert.That(Util.GetMagnitude(normalizedVector), - new DoubleToleranceConstraint(expectedNormalizedMagnitude, lowPrecisionTolerance), - "Normalized vector generated from vector does not have magnitude of 1."); - } - } - - [Test] - public void UUIDTests() - { - Assert.IsTrue(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf"), - "A correct UUID wasn't recognized."); - Assert.IsFalse(Util.isUUID("FOOBAR67-89ab-Cdef-0123-456789AbCdEf"), - "UUIDs with non-hex characters are recognized as correct UUIDs."); - Assert.IsFalse(Util.isUUID("01234567"), - "Too short UUIDs are recognized as correct UUIDs."); - Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf0"), - "Too long UUIDs are recognized as correct UUIDs."); - Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123+456789AbCdEf"), - "UUIDs with wrong format are recognized as correct UUIDs."); - } - - [Test] - public void GetHashGuidTests() - { - string string1 = "This is one string"; - string string2 = "This is another"; - - // Two consecutive runs should equal the same - Assert.AreEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret1")); - Assert.AreEqual(Util.GetHashGuid(string2, "secret1"), Util.GetHashGuid(string2, "secret1")); - - // Varying data should not eqal the same - Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string2, "secret1")); - - // Varying secrets should not eqal the same - Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); - } - - [Test] - public void SLUtilTypeConvertTests() - { - int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,10,11,12,13,17,18,19,20,21,22 - ,24,25}; - string[] contenttypes = new string[] - { - "application/octet-stream", - "image/x-j2c", - "audio/ogg", - "application/vnd.ll.callingcard", - "application/vnd.ll.landmark", - "application/vnd.ll.clothing", - "application/vnd.ll.primitive", - "application/vnd.ll.notecard", - "application/vnd.ll.folder", - "application/vnd.ll.lsltext", - "application/vnd.ll.lslbyte", - "image/tga", - "application/vnd.ll.bodypart", - "audio/x-wav", - "image/tga", - "image/jpeg", - "application/vnd.ll.animation", - "application/vnd.ll.gesture", - "application/x-metaverse-simstate", - "application/vnd.ll.link", - "application/vnd.ll.linkfolder", - }; - for (int i=0;i public class ThreadSafeRandom : Random { + private readonly object mainLock = new(); public ThreadSafeRandom() : base() {} public ThreadSafeRandom(int seed): base (seed) {} public override int Next() { - lock (this) + lock (mainLock) return base.Next(); } public override int Next(int maxValue) { - lock (this) + lock (mainLock) return base.Next(maxValue); } public override int Next(int minValue, int maxValue) { - lock (this) + lock (mainLock) return base.Next(minValue, maxValue); } public override void NextBytes(byte[] buffer) { - lock (this) + lock (mainLock) base.NextBytes(buffer); } public override double NextDouble() { - lock (this) + lock (mainLock) return base.NextDouble(); } } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index af8b4c18aac..aa5755661c8 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -55,8 +55,7 @@ using OpenMetaverse.StructuredData; using Amib.Threading; using System.Collections.Concurrent; -using System.Collections.Specialized; -using System.Web; +using System.Net.Http; namespace OpenSim.Framework { @@ -164,16 +163,29 @@ static Util() LogOverloads = true; TimeStampClockPeriod = 1.0D / (double)Stopwatch.Frequency; TimeStampClockPeriodMS = 1e3 * TimeStampClockPeriod; - m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS, 6, MidpointRounding.AwayFromZero)); + m_log.Info($"[UTIL] TimeStamp clock with period of {Math.Round(TimeStampClockPeriodMS, 6, MidpointRounding.AwayFromZero)}ms"); } private static uint nextXferID = 5000; - private static readonly Random randomClass = new ThreadSafeRandom(); // Get a list of invalid file characters (OS dependent) - private static readonly string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; - private static readonly string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; - private static readonly object XferLock = new object(); + private static readonly string regexInvalidFileChars = $"[{new String(Path.GetInvalidFileNameChars())}]"; + private static readonly string regexInvalidPathChars = $"[{new String(Path.GetInvalidPathChars())}]"; + private static readonly object XferLock = new(); + + public static readonly char[] SplitCommaArray = new char[] { ',' }; + public static readonly char[] SplitDotArray = new char[] { '.' }; + public static readonly char[] SplitColonArray = new char[] { ':' }; + public static readonly char[] SplitSemicolonArray = new char[] { ';' }; + public static readonly char[] SplitSlashArray = new char[] { '/' }; + + public static readonly XmlReaderSettings SharedXmlReaderSettings = new() + { + IgnoreWhitespace = true, + ConformanceLevel = ConformanceLevel.Fragment, + DtdProcessing = DtdProcessing.Ignore, + MaxCharactersInDocument = 10_000_000 + }; /// /// Thread pool used for Util.FireAndForget if FireAndForgetMethod.SmartThreadPool is used @@ -189,18 +201,15 @@ static Util() private static readonly string rawUUIDPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; - public static readonly Regex PermissiveUUIDPattern = new Regex(rawUUIDPattern); - public static readonly Regex UUIDPattern = new Regex(string.Format("^{0}$", rawUUIDPattern)); + public static readonly Regex PermissiveUUIDPattern = new(rawUUIDPattern); + public static readonly Regex UUIDPattern = new(string.Format("^{0}$", rawUUIDPattern)); public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; public static readonly string UUIDZeroString = UUID.Zero.ToString(); - public static bool IsPlatformMono - { - get { return Type.GetType("Mono.Runtime") != null; } - } + public const bool IsPlatformMono = false; /// /// Gets the name of the directory where the current running executable @@ -213,38 +222,16 @@ public static string ExecutingDirectory() return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - // next should be replaced using .net5 system numerics bitoperations log2 - // this is just log2 + 1 - private static byte[] nBitsLookup = - { - 01, 10, 02, 11, 14, 22, 03, 30, 12, 15, 17, 19, 23, 26, 04, 31, - 09, 13, 21, 29, 16, 18, 25, 08, 20, 28, 24, 07, 27, 06, 05, 32 - }; - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int NumberBits(uint n) { - n |= (n >> 1); - n |= (n >> 2); - n |= (n >> 4); - n |= (n >> 8); - n |= (n >> 16); - return nBitsLookup[(n * 0x07C4ACDDu) >> 27]; + return System.Numerics.BitOperations.Log2(n) + 1; } - private static byte[] intLog2Lookup = - { - 00, 09, 01, 10, 13, 21, 02, 29, 11, 14, 16, 18, 22, 25, 03, 30, - 08, 12, 20, 28, 15, 17, 24, 07, 19, 27, 23, 06, 26, 05, 04, 31 - }; - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int intLog2(uint n) { - n |= (n >> 1); - n |= (n >> 2); - n |= (n >> 4); - n |= (n >> 8); - n |= (n >> 16); - return intLog2Lookup[(n * 0x07C4ACDDu) >> 27]; + return System.Numerics.BitOperations.Log2(n); } /// @@ -297,7 +284,7 @@ public static byte[] UTF8NBGetbytes(string s) /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) /// - public static UUID BLANK_TEXTURE_UUID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); + public static UUID BLANK_TEXTURE_UUID = new("5748decc-f629-461c-9a36-a35a221fe21f"); #region Vector Equations @@ -342,7 +329,7 @@ public static double GetMagnitude(Vector3 a) public static Vector3 GetNormalizedVector(Vector3 a) { - Vector3 v = new Vector3(a.X, a.Y, a.Z); + Vector3 v = new(a.X, a.Y, a.Z); v.Normalize(); return v; } @@ -366,11 +353,11 @@ public static bool IsZeroVector(Vector3 v) public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) { float s; - float tr = (float)(fwd.X + left.Y + up.Z + 1.0); + float tr = (fwd.X + left.Y + up.Z + 1.0f); if (tr >= 1.0) { - s = (float)(0.5 / Math.Sqrt(tr)); + s = 0.5f / MathF.Sqrt(tr); return new Quaternion( (left.Z - up.Y) * s, (up.X - fwd.Z) * s, @@ -383,9 +370,9 @@ public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) if (max < fwd.X) { - s = (float)(Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0)); - float x = (float)(s * 0.5); - s = (float)(0.5 / s); + s = MathF.Sqrt(fwd.X - (left.Y + up.Z) + 1.0f); + float x = s * 0.5f; + s = 0.5f / s; return new Quaternion( x, (fwd.Y + left.X) * s, @@ -394,9 +381,9 @@ public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) } else if (max == left.Y) { - s = (float)(Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0)); - float y = (float)(s * 0.5); - s = (float)(0.5 / s); + s = MathF.Sqrt(left.Y - (up.Z + fwd.X) + 1.0f); + float y = s * 0.5f; + s = 0.5f / s; return new Quaternion( (fwd.Y + left.X) * s, y, @@ -405,9 +392,9 @@ public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) } else { - s = (float)(Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0)); - float z = (float)(s * 0.5); - s = (float)(0.5 / s); + s = MathF.Sqrt(up.Z - (fwd.X + left.Y) + 1.0f); + float z = s * 0.5f; + s = 0.5f / s; return new Quaternion( (up.X + fwd.Z) * s, (left.Z + up.Y) * s, @@ -417,9 +404,10 @@ public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) } } + // legacy, do not use public static Random RandomClass { - get { return randomClass; } + get { return Random.Shared;} } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -435,7 +423,7 @@ public static ulong UIntsToLong(uint X, uint Y) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong RegionWorldLocToHandle(uint X, uint Y) { - ulong handle = X & 0xffffff00; // make sure it matchs grid coord points. + ulong handle = X & 0xffffff00; // make sure it matches grid coord points. handle <<= 32; // to higher half handle |= (Y & 0xffffff00); return handle; @@ -525,17 +513,16 @@ public static bool CompareRegionHandles(ulong handle, Vector3 handleOffset, int public static bool checkServiceURI(string uristr, out string serviceURI, out string serviceHost, out string serviceIPstr) { - serviceURI = string.Empty; serviceHost = string.Empty; serviceIPstr = string.Empty; try { - Uri uri = new Uri(uristr); + Uri uri = new(uristr); serviceURI = uri.AbsoluteUri; if (uri.Port == 80) - serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) + ":80/"; + serviceURI = $"{serviceURI.Trim(new char[] { '/', ' ' })}:80/"; else if (uri.Port == 443) - serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) + ":443/"; + serviceURI = $"{serviceURI.Trim(new char[] { '/', ' ' })}:443/"; serviceHost = uri.Host; IPEndPoint ep = Util.getEndPoint(serviceHost, uri.Port); @@ -571,7 +558,7 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out string host; int port = 80; - string[] parts = inputName.Split(new char[] { ':' }); + string[] parts = inputName.Split(Util.SplitColonArray); int indx; if (parts.Length == 0) return false; @@ -579,12 +566,12 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out { indx = inputName.IndexOf('/'); if (indx < 0) - serverURI = "http://" + inputName + "/"; + serverURI = $"http://{inputName}/"; else { - serverURI = "http://" + inputName.Substring(0, indx + 1); + serverURI = $"http://{inputName[..(indx + 1)]}"; if (indx + 2 < inputName.Length) - regionName = inputName.Substring(indx + 1); + regionName = inputName[(indx + 1)..]; } } else @@ -605,9 +592,9 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out } else { - string portstr = parts[1].Substring(0, indx); + string portstr = parts[1][..indx]; if (indx + 2 < parts[1].Length) - regionName = parts[1].Substring(indx + 1); + regionName = parts[1][(indx + 1)..]; if (!int.TryParse(portstr, out port)) port = 80; } @@ -618,7 +605,7 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out regionName = parts[2]; } - serverURI = "http://" + host + ":" + port.ToString() + "/"; + serverURI = $"http://{host}:{port}/"; } } else @@ -627,7 +614,7 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out // http://grid.example.com "region name" // http://grid.example.com - string[] parts = inputName.Split(new char[] { ' ' }); + string[] parts = inputName.Split(); if (parts.Length == 0) return false; @@ -638,12 +625,12 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out if (indx > 10) { if (indx + 2 < inputName.Length) - regionName = inputName.Substring(indx + 1); - serverURI = inputName.Substring(0, indx + 1); + regionName = inputName[(indx + 1)..]; + serverURI = inputName[..(indx + 1)]; } else if (parts.Length >= 2) { - regionName = inputName.Substring(serverURI.Length); + regionName = inputName[serverURI.Length..]; } } @@ -662,9 +649,9 @@ public static bool buildHGRegionURI(string inputName, out string serverURI, out regionName = regionName.Trim(new char[] { '"', ' ' }); serverURI = uri.AbsoluteUri; if (uri.Port == 80) - serverURI = serverURI.Trim(new char[] { '/', ' ' }) + ":80/"; + serverURI = $"{serverURI.Trim(new char[] { '/', ' ' })}:80/"; else if (uri.Port == 443) - serverURI = serverURI.Trim(new char[] { '/', ' ' }) + ":443/"; + serverURI = $"{serverURI.Trim(new char[] { '/', ' ' })}:443/"; return true; } @@ -687,8 +674,8 @@ public static Vector3 ClampV(Vector3 x, float max) float lenSq = x.LengthSquared(); if (lenSq > (max * max)) { - lenSq = max / (float)Math.Sqrt(lenSq); - x = x * lenSq; + lenSq = max / MathF.Sqrt(lenSq); + x *= lenSq; } return x; } @@ -777,14 +764,14 @@ public static string GetFormattedXml(OSD osd) /// public static string GetFormattedXml(string rawXml) { - XmlDocument xd = new XmlDocument(); + XmlDocument xd = new(); xd.LoadXml(rawXml); - StringBuilder sb = new StringBuilder(); - StringWriter sw = new StringWriter(sb); + StringBuilder sb = new(); + StringWriter sw = new(sb); - XmlTextWriter xtw = new XmlTextWriter(sw) + XmlTextWriter xtw = new(sw) { Formatting = Formatting.Indented }; @@ -809,7 +796,7 @@ public static string GetFormattedXml(string rawXml) public static byte[] ResultFailureMessageEnd = osUTF8.GetASCIIBytes(""); public static byte[] ResultFailureMessage(string message) { - osUTF8 res = new osUTF8(ResultFailureMessageStart.Length + ResultFailureMessageEnd.Length + message.Length); + osUTF8 res = new(ResultFailureMessageStart.Length + ResultFailureMessageEnd.Length + message.Length); res.Append(ResultFailureMessageStart); res.Append(message); res.Append(ResultFailureMessageEnd); @@ -818,15 +805,13 @@ public static byte[] ResultFailureMessage(string message) public static byte[] DocToBytes(XmlDocument doc) { - using (MemoryStream ms = new MemoryStream()) - using (XmlTextWriter xw = new XmlTextWriter(ms, null)) - { - xw.Formatting = Formatting.Indented; - doc.WriteTo(xw); - xw.Flush(); + using MemoryStream ms = new(); + using XmlTextWriter xw = new(ms, null); + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); - return ms.ToArray(); - } + return ms.ToArray(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -932,7 +917,7 @@ public static List GetUUIDsOnString(ref string s, int indx, int len) continue; } ++indx; - retry = indx; + //retry = indx; next = indx + 12; for (; indx < next; ++indx) @@ -943,7 +928,7 @@ public static List GetUUIDsOnString(ref string s, int indx, int len) if (indx != next) continue; - if (UUID.TryParse(s.Substring(idbase, 36), out UUID u)) + if (UUID.TryParse(s.AsSpan(idbase, 36), out UUID u)) { ids.Add(u); } @@ -952,7 +937,33 @@ public static List GetUUIDsOnString(ref string s, int indx, int len) return ids; } + public static List GetUUIDsOnString(ReadOnlySpan s) + { + var ids = new List(); + if (s.Length < 36) + return ids; + int indx = 8; + while (indx < s.Length - 28) + { + if (s[indx] == '-') + { + if (UUID.TryParse(s.Slice(indx - 8, 36), out UUID id)) + { + if (id.IsNotZero()) + ids.Add(id); + indx += 37; + } + else + indx += 9; + } + else + indx++; + } + return ids; + } + + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] static bool IsHexa(byte c) { @@ -1056,7 +1067,7 @@ public static List GetUUIDsOnData(byte[] s, int indx, int len) continue; } ++indx; - retry = indx; + //retry = indx; next = indx + 12; for (; indx < next; ++indx) @@ -1076,6 +1087,7 @@ public static List GetUUIDsOnData(byte[] s, int indx, int len) return ids; } + */ /// /// Is the platform Windows? @@ -1111,12 +1123,11 @@ public static bool LoadArchSpecificWindowsDll(string libraryName, string path) else nativeLibraryPath = Path.Combine(Path.Combine(path, "lib32"), libraryName); - m_log.DebugFormat("[UTIL]: Loading native Windows library at {0}", nativeLibraryPath); + m_log.Debug($"[UTIL]: Loading native Windows library at {nativeLibraryPath}"); - if (Util.LoadLibrary(nativeLibraryPath) == IntPtr.Zero) + if (!NativeLibrary.TryLoad(nativeLibraryPath, out _)) { - m_log.ErrorFormat( - "[UTIL]: Couldn't find native Windows library at {0}", nativeLibraryPath); + m_log.Error($"[UTIL]: Couldn't find native Windows library at {nativeLibraryPath}"); return false; } return true; @@ -1124,29 +1135,11 @@ public static bool LoadArchSpecificWindowsDll(string libraryName, string path) public static bool IsEnvironmentSupported(ref string reason) { - // Must have .NET 2.0 (Generics / libsl) - if (Environment.Version.Major < 2) - { - reason = ".NET 1.0/1.1 lacks components that is used by OpenSim"; - return false; - } - - // Windows 95/98/ME are unsupported - if (Environment.OSVersion.Platform == PlatformID.Win32Windows && - Environment.OSVersion.Platform != PlatformID.Win32NT) - { - reason = "Windows 95/98/ME will not run OpenSim"; - return false; - } - - // Windows 2000 / Pre-SP2 XP - if (Environment.OSVersion.Version.Major == 5 && - Environment.OSVersion.Version.Minor == 0) + if (Environment.Version.Major < 6) { - reason = "Please update to Windows XP Service Pack 2 or Server2003"; + reason = "Dotnet 6.0 is required"; return false; } - return true; } @@ -1204,7 +1197,7 @@ public static string Md5Hash(string data) public static string Md5Hash(string data, Encoding encoding) { byte[] dataMd5 = ComputeMD5Hash(data, encoding); - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < dataMd5.Length; i++) sb.AppendFormat("{0:x2}", dataMd5[i]); return sb.ToString(); @@ -1213,8 +1206,22 @@ public static string Md5Hash(string data, Encoding encoding) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static byte[] ComputeMD5Hash(string data, Encoding encoding) { - using (MD5 md5 = MD5.Create()) - return md5.ComputeHash(encoding.GetBytes(data)); + using MD5 md5 = MD5.Create(); + return md5.ComputeHash(encoding.GetBytes(data)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static UUID ComputeASCIIMD5UUID(string data) + { + using MD5 md5 = MD5.Create(); + byte[] bytes = md5.ComputeHash(Encoding.ASCII.GetBytes(data)); + UUID uuid = new(bytes,2); + uuid.c &= 0x0fff; + uuid.c |= 0x3000; + uuid.d &= 0x3f; + uuid.d |= 0x80; + + return uuid; } /// @@ -1251,31 +1258,58 @@ public static char HighNibbleToHexByteCharHighcaps(byte b) return (char)(b > 9 ? b + 0x37 : b + '0'); } - public static string bytesToHexString(byte[] bytes, bool lowerCaps) + public static unsafe string bytesToHexString(byte[] bytes, bool lowerCaps) { if (bytes == null || bytes.Length == 0) return string.Empty; - char[] chars = new char[2 * bytes.Length]; - if (lowerCaps) + return string.Create(2 * bytes.Length, bytes, (chars, bytes) => { - for (int i = 0, j = 0; i < bytes.Length; ++i) + fixed (char* dstb = chars) + fixed (byte* srcb = bytes) { - byte b = bytes[i]; - chars[j++] = HighNibbleToHexByteCharLowcaps(b); - chars[j++] = LowNibbleToHexByteCharLowcaps(b); + char* dst = dstb; + if (lowerCaps) + { + for (int i = 0; i < bytes.Length; ++i) + { + byte b = srcb[i]; + *dst++ = HighNibbleToHexByteCharLowcaps(b); + *dst++ = LowNibbleToHexByteCharLowcaps(b); + } + } + else + { + for (int i = 0; i < bytes.Length; ++i) + { + byte b = srcb[i]; + *dst++ = HighNibbleToHexByteCharLowcaps(b); + *dst++ = LowNibbleToHexByteCharLowcaps(b); + } + } } - } - else + }); + } + + public static unsafe string bytesToLowcaseHexString(byte[] bytes) + { + if (bytes == null || bytes.Length == 0) + return string.Empty; + + return string.Create(2 * bytes.Length, bytes, (chars, bytes) => { - for (int i = 0, j = 0; i < bytes.Length; ++i) + fixed (char* dstb = chars) + fixed (byte* srcb = bytes) { - byte b = bytes[i]; - chars[j++] = HighNibbleToHexByteCharHighcaps(b); - chars[j++] = LowNibbleToHexByteCharHighcaps(b); + char* dst = dstb; + for (int i = 0; i < bytes.Length; ++i) + { + byte b = srcb[i]; + *dst++ = HighNibbleToHexByteCharLowcaps(b); + *dst++ = LowNibbleToHexByteCharLowcaps(b); + } } - } - return new string(chars); + }); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -1303,8 +1337,8 @@ public static string SHA1Hash(byte[] data) private static byte[] ComputeSHA1Hash(byte[] src) { - using (SHA1 sha = SHA1.Create()) - return sha.ComputeHash(src); + using SHA1 sha = SHA1.Create(); + return sha.ComputeHash(src); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -1313,12 +1347,137 @@ public static UUID ComputeSHA1UUID(string src) return ComputeSHA1UUID(Encoding.Default.GetBytes(src)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static UUID ComputeASCIISHA1UUID(string src) + { + return ComputeSHA1UUID(Encoding.ASCII.GetBytes(src)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static UUID ComputeSHA1UUID(byte[] src) { byte[] ret; using (SHA1 sha = SHA1.Create()) ret = sha.ComputeHash(src); - return new UUID(ret, 2); + UUID uuid = new(ret, 2); + uuid.c &= 0x0fff; + uuid.c |= 0x5000; + uuid.d &= 0x3f; + uuid.d |= 0x80; + return uuid; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string AESEncrypt(ReadOnlySpan secret, ReadOnlySpan plainText) + { + return AESEncryptString(secret, plainText, string.Empty); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string AESEncryptTo(ReadOnlySpan secret, ReadOnlySpan plainText, ReadOnlySpan ivString) + { + return AESEncryptString(secret, plainText, ivString); + } + /// + /// AES Encrypt a string using a password and a random or custom Initialization + /// Vector + /// + /// The secret encryption password or key. + /// The string or text to encrypt. + /// (optional) A string used to generate the Initialization Vector eg; an avatarID, a SecureSessionID, an object or script + /// ID... + /// A string composed by the Initialization Vector bytes and the + /// encrypted text bytes converted to lower case HexString and separated by " : " + private static string AESEncryptString(ReadOnlySpan secret, ReadOnlySpan plainText, ReadOnlySpan ivString) + { + if(secret.Length == 0 || plainText.Length == 0) + return string.Empty; + + byte[] iv = ivString.Length == 0 ? + MD5.Create().ComputeHash(UUID.Random().GetBytes()) : + MD5.Create().ComputeHash(Utils.StringToBytesNoTerm(ivString)); + byte[] aesKey = SHA256.Create().ComputeHash(Utils.StringToBytesNoTerm(secret)); + byte[] encryptedText; + + using (Aes aes = Aes.Create()) + { + aes.Key = aesKey; + aes.IV = iv; + aes.Mode = CipherMode.CBC; + aes.Padding = PaddingMode.PKCS7; + + ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); + using (MemoryStream memoryStream = new()) + { + using (CryptoStream cryptoStream = new(memoryStream, encryptor, CryptoStreamMode.Write)) + using (StreamWriter streamWriter = new(cryptoStream)) + streamWriter.Write(plainText); + encryptedText = memoryStream.ToArray(); + } + } + + return $"{Convert.ToHexString(iv)}:{Convert.ToHexString(encryptedText).ToLower()}"; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ReadOnlySpan AESDecrypt(ReadOnlySpan secret, ReadOnlySpan encryptedText) + { + return AESDecryptString(secret, encryptedText, new ReadOnlySpan()); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ReadOnlySpan AESDecryptFrom(ReadOnlySpan secret, ReadOnlySpan encryptedText, ReadOnlySpan ivString) + { + return AESDecryptString(secret, encryptedText, ivString); + } + + /// + /// AES Decrypt the string encrypted by AESEncryptString with the same password + /// and ivString used in the encryption. + /// + /// The secret decryption password or key. + /// The encrypted string or text. + /// The string used to generate the Initialization Vector + /// if used in the encription. eg; an avatarID, a SecureSessionID, an object or + /// script ID... + /// The decrypted string. + private static ReadOnlySpan AESDecryptString(ReadOnlySpan secret, ReadOnlySpan encryptedText, ReadOnlySpan ivString) + { + if(secret.Length == 0 || encryptedText.Length == 0) + return string.Empty; + + int sep = encryptedText.IndexOf(':'); + if(sep < 0) + return string.Empty; + + byte[] iv; + byte[] buffer; + try + { + iv = ivString.Length == 0 ? + Convert.FromHexString(encryptedText[..sep]): + MD5.Create().ComputeHash(Utils.StringToBytesNoTerm(ivString)); + buffer = Convert.FromHexString(encryptedText[(sep + 1)..]); + } + catch + { + return string.Empty; + } + + byte[] aesKey = SHA256.Create().ComputeHash(Utils.StringToBytesNoTerm(secret)); + + using Aes aes = Aes.Create(); + aes.Key = aesKey; + aes.IV = iv; + aes.Mode = CipherMode.CBC; + aes.Padding = PaddingMode.PKCS7; + + ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV); + using MemoryStream memoryStream = new(buffer); + using CryptoStream cryptoStream = new(memoryStream, decryptor, CryptoStreamMode.Read); + using StreamReader streamReader = new(cryptoStream); + + return streamReader.ReadToEnd(); } public static int fast_distance2d(int x, int y) @@ -1401,7 +1560,7 @@ public static string FieldToString(byte[] bytes, string fieldName) // Check for a common case if (bytes.Length == 0) return String.Empty; - StringBuilder output = new StringBuilder(); + StringBuilder output = new(); bool printable = true; for (int i = 0; i < bytes.Length; ++i) @@ -1440,7 +1599,7 @@ public static string FieldToString(byte[] bytes, string fieldName) for (int j = 0; j < 16; j++) { if ((i + j) < bytes.Length) - output.Append(String.Format("{0:X2} ", bytes[i + j])); + output.Append($"{bytes[i + j]:X2} "); else output.Append(" "); } @@ -1450,7 +1609,7 @@ public static string FieldToString(byte[] bytes, string fieldName) if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) output.Append((char)bytes[i + j]); else - output.Append("."); + output.Append('.'); } } } @@ -1458,7 +1617,7 @@ public static string FieldToString(byte[] bytes, string fieldName) return output.ToString(); } - private static ExpiringCacheOS dnscache = new ExpiringCacheOS(10000); + private static readonly ExpiringCacheOS dnscache = new(10000); /// /// Converts a URL to a IPAddress @@ -1484,7 +1643,6 @@ public static IPAddress GetHostFromDNS(string dnsAddress) if (dnscache.TryGetValue(dnsAddress, 300000, out IPAddress ia) && ia != null) return ia; - ia = null; // If it is already an IP, don't let GetHostEntry see it if (IPAddress.TryParse(dnsAddress, out ia) && ia != null) { @@ -1510,8 +1668,7 @@ public static IPAddress GetHostFromDNS(string dnsAddress) ia = null; foreach (IPAddress Adr in IPH.AddressList) { - if (ia == null) - ia = Adr; + ia ??= Adr; if (Adr.AddressFamily == AddressFamily.InterNetwork) { @@ -1529,7 +1686,7 @@ public static IPEndPoint getEndPoint(IPAddress ia, int port) if (ia == null) return null; - IPEndPoint newEP = null; + IPEndPoint newEP; try { newEP = new IPEndPoint(ia, port); @@ -1549,8 +1706,6 @@ public static IPEndPoint getEndPoint(string hostname, int port) if (dnscache.TryGetValue(hostname, 300000, out IPAddress ia) && ia != null) return getEndPoint(ia, port); - ia = null; - // If it is already an IP, don't let GetHostEntry see it if (IPAddress.TryParse(hostname, out ia) && ia != null) { @@ -1578,8 +1733,7 @@ public static IPEndPoint getEndPoint(string hostname, int port) ia = null; foreach (IPAddress Adr in IPH.AddressList) { - if (ia == null) - ia = Adr; + ia ??= Adr; if (Adr.AddressFamily == AddressFamily.InterNetwork) { @@ -1661,7 +1815,7 @@ public static int ParseForeignAssetID(string id, out string url, out string asse if (id[0] != 'h' && id[0] != 'H') { - if (UUID.TryParse(id, out UUID luuid)) + if (UUID.TryParse(id, out _)) { assetID = id; return 0; @@ -1669,7 +1823,7 @@ public static int ParseForeignAssetID(string id, out string url, out string asse return -1; } - OSHTTPURI uri = new OSHTTPURI(id, true); + OSHTTPURI uri = new(id, true); if (uri.IsResolvedHost) { url = uri.URL; @@ -1677,8 +1831,8 @@ public static int ParseForeignAssetID(string id, out string url, out string asse if (tmp.Length < 36) return -3; if (tmp[0] == '/') - tmp = tmp.Substring(1); - if (UUID.TryParse(tmp, out UUID uuid)) + tmp = tmp[1..]; + if (UUID.TryParse(tmp, out _)) { assetID = tmp; return 1; @@ -1751,9 +1905,9 @@ public static string logFile() { foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) { - if (appender is FileAppender && appender.Name == "LogFileAppender") + if (appender is FileAppender appender1 && appender1.Name == "LogFileAppender") { - return ((FileAppender)appender).File; + return appender1.File; } } @@ -1764,9 +1918,9 @@ public static string StatsLogFile() { foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) { - if (appender is FileAppender && appender.Name == "StatsLogFileAppender") + if (appender is FileAppender appender1 && appender1.Name == "StatsLogFileAppender") { - return ((FileAppender)appender).File; + return appender1.File; } } @@ -1787,11 +1941,11 @@ public static string GetUniqueFilename(string FileName) if (File.Exists(FileName)) { - FileInfo f = new FileInfo(FileName); + FileInfo f = new(FileName); if (!String.IsNullOrEmpty(f.Extension)) { - Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.')); + Name = f.FullName[..f.FullName.LastIndexOf('.')]; } else { @@ -1815,7 +1969,7 @@ public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileNa { // create new file } - XmlConfigSource config = new XmlConfigSource(fileName); + XmlConfigSource config = new(fileName); AddDataRowToConfig(config, row); config.Save(); @@ -1881,7 +2035,7 @@ public static T GetConfigVarFromSections(IConfigSource config, string varname /// public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections, object val) { - foreach (string section in sections) + foreach (string section in sections.AsSpan()) { IConfig cnf = config.Configs[section]; if (cnf == null) @@ -1898,7 +2052,6 @@ public static T GetConfigVarFromSections(IConfigSource config, string varname else m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); } - return (T)val; } @@ -1909,7 +2062,7 @@ public static void MergeEnvironmentToConfig(IConfigSource ConfigSource) if (enVars != null) { // load the values from the environment - EnvConfigSource envConfigSource = new EnvConfigSource(); + EnvConfigSource envConfigSource = new(); // add the requested keys string[] env_keys = enVars.GetKeys(); foreach (string key in env_keys) @@ -2006,7 +2159,7 @@ public static bool MergeConfigurationFile(IConfigSource config, string configFil IConfig cnf = config.Configs["Startup"]; if (cnf == null) { - m_log.WarnFormat("[UTILS]: Startup section doesn't exist"); + m_log.Warn("[UTILS]: Startup section doesn't exist"); return false; } @@ -2027,7 +2180,7 @@ public static bool MergeConfigurationFile(IConfigSource config, string configFil } catch (Exception e) { - m_log.WarnFormat("[UTILS]: Exception copying configuration file {0} to {1}: {2}", configFile, exampleConfigFile, e.Message); + m_log.Warn($"[UTILS]: Exception copying configuration file {configFile} to {exampleConfigFile}: {e.Message}"); return false; } } @@ -2061,7 +2214,7 @@ public static string CleanString(string input) for (int i = 0; i < input.Length; i++) { if (input[i] == '\0' || input[i] == '\r' || input[i] == '\n') - return input.Substring(0, i); + return input[..i]; } return input; } @@ -2075,12 +2228,11 @@ public static string ReadEtcIssue() { try { - StreamReader sr = new StreamReader("/etc/issue.net"); + using StreamReader sr = new("/etc/issue.net"); string issue = sr.ReadToEnd(); - sr.Close(); return issue; } - catch (Exception) + catch { return ""; } @@ -2089,69 +2241,41 @@ public static string ReadEtcIssue() public static void SerializeToFile(string filename, Object obj) { IFormatter formatter = new BinaryFormatter(); - Stream stream = null; - try { - stream = new FileStream( - filename, FileMode.Create, - FileAccess.Write, FileShare.None); - + using Stream stream = new FileStream(filename, FileMode.Create,FileAccess.Write, FileShare.None); formatter.Serialize(stream, obj); } catch (Exception e) { m_log.Error(e.ToString()); } - finally - { - if (stream != null) - { - stream.Close(); - } - } } public static Object DeserializeFromFile(string filename) { - IFormatter formatter = new BinaryFormatter(); - Stream stream = null; - Object ret = null; - try { - stream = new FileStream( - filename, FileMode.Open, - FileAccess.Read, FileShare.None); - - ret = formatter.Deserialize(stream); + using Stream stream = new FileStream(filename, FileMode.Open,FileAccess.Read, FileShare.None); + IFormatter formatter = new BinaryFormatter(); + return formatter.Deserialize(stream); } catch (Exception e) { m_log.Error(e.ToString()); } - finally - { - if (stream != null) - { - stream.Close(); - } - } - - return ret; + return null; } public static string Compress(string text) { + using MemoryStream memory = new(); + using GZipStream compressor = new(memory, CompressionMode.Compress, true); + byte[] buffer = Util.UTF8.GetBytes(text); - MemoryStream memory = new MemoryStream(); - using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true)) - { - compressor.Write(buffer, 0, buffer.Length); - } + compressor.Write(buffer, 0, buffer.Length); memory.Position = 0; - byte[] compressed = new byte[memory.Length]; memory.Read(compressed, 0, compressed.Length); @@ -2164,21 +2288,18 @@ public static string Compress(string text) public static string Decompress(string compressedText) { byte[] compressedBuffer = Convert.FromBase64String(compressedText); - using (MemoryStream memory = new MemoryStream()) - { - int msgLength = BitConverter.ToInt32(compressedBuffer, 0); - memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4); + int msgLength = BitConverter.ToInt32(compressedBuffer, 0); - byte[] buffer = new byte[msgLength]; + using MemoryStream memory = new(); + memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4); - memory.Position = 0; - using (GZipStream decompressor = new GZipStream(memory, CompressionMode.Decompress)) - { - decompressor.Read(buffer, 0, buffer.Length); - } + byte[] buffer = new byte[msgLength]; - return Util.UTF8.GetString(buffer); - } + memory.Position = 0; + using GZipStream decompressor = new(memory, CompressionMode.Decompress); + decompressor.Read(buffer, 0, buffer.Length); + + return Util.UTF8.GetString(buffer); } /// @@ -2197,7 +2318,8 @@ public static Stream Copy(Stream inputStream) const int readSize = 256; byte[] buffer = new byte[readSize]; - MemoryStream ms = new MemoryStream(); + + MemoryStream ms = new(); int count = inputStream.Read(buffer, 0, readSize); @@ -2213,6 +2335,7 @@ public static Stream Copy(Stream inputStream) return ms; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) { return SendXmlRpcCommand(url, methodName, args); @@ -2220,8 +2343,9 @@ public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params public static XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args) { - XmlRpcRequest client = new XmlRpcRequest(methodName, args); - return client.Send(url, 6000); + XmlRpcRequest xmlclient = new(methodName, args); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + return xmlclient.Send(url, hclient); } /// @@ -2230,14 +2354,16 @@ public static XmlRpcResponse SendXmlRpcCommand(string url, string methodName, ob /// XML string consisting of a error element containing individual error(s) public static XmlRpcResponse CreateUnknownUserErrorResponse() { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable() + Hashtable responseData = new() { ["error_type"] = "unknown_user", ["error_desc"] = "The user requested is not in the database" }; - response.Value = responseData; + XmlRpcResponse response = new() + { + Value = responseData + }; return response; } @@ -2318,46 +2444,36 @@ public static void FakeParcelIDToGlobalPosition(UUID parcelID, out uint x, out u /// public static string GetOperatingSystemInformation() { - string os = String.Empty; + return String.Empty; + //string os; + //if (Environment.OSVersion.Platform != PlatformID.Unix) + //{ + // os = Environment.OSVersion.ToString(); + //} + //else + //{ + // os = ReadEtcIssue(); + //} - // if (Environment.OSVersion.Platform != PlatformID.Unix) - // { - // os = Environment.OSVersion.ToString(); - // } - // else - // { - // os = ReadEtcIssue(); - // } - // - // if (os.Length > 45) - // { - // os = os.Substring(0, 45); - // } + //if (os.Length > 45) + //{ + // os = os.Substring(0, 45); + //} - return os; + //return os; } - public static string GetRuntimeInformation() - { - string ru = String.Empty; - - if (Environment.OSVersion.Platform == PlatformID.Unix) - { - ru = "Unix/Mono"; - } - else - if (Environment.OSVersion.Platform == PlatformID.MacOSX) - ru = "OSX/Mono"; - else + public static readonly string RuntimeInformationStr = RuntimeInformation.ProcessArchitecture.ToString() + "/" + Environment.OSVersion.Platform switch { - if (IsPlatformMono) - ru = "Win/Mono"; - else - ru = "Win/.NET"; - } + PlatformID.MacOSX or PlatformID.Unix => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "OSX/DotNet" : "Unix/DotNet", + _ => "Win/DotNet" + }; - return ru; - } + public static readonly string RuntimePlatformStr = Environment.OSVersion.Platform switch + { + PlatformID.MacOSX or PlatformID.Unix => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "OSX/DotNet" : "Unix/DotNet", + _ => "Win/DotNet" + }; /// /// Is the given string a UUID? @@ -2371,9 +2487,8 @@ public static bool isUUID(string s) public static string GetDisplayConnectionString(string connectionString) { - int passPosition = 0; - int passEndPosition = 0; - string displayConnectionString = null; + int passPosition; + int passEndPosition; // hide the password in the connection string passPosition = connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); @@ -2384,11 +2499,7 @@ public static string GetDisplayConnectionString(string connectionString) passPosition += 1; passEndPosition = connectionString.IndexOf(";", passPosition); - displayConnectionString = connectionString.Substring(0, passPosition); - displayConnectionString += "***"; - displayConnectionString += connectionString.Substring(passEndPosition, connectionString.Length - passEndPosition); - - return displayConnectionString; + return $"{connectionString[..passPosition]}***{connectionString[passEndPosition..]}"; } public static string Base64ToString(string str) @@ -2399,7 +2510,7 @@ public static string Base64ToString(string str) int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); - string result = new String(decoded_char); + string result = new(decoded_char); return result; } @@ -2446,11 +2557,7 @@ public static void ReadStream(Stream stream, byte[] data) public static Guid GetHashGuid(string data, string salt) { byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default); - - //string s = BitConverter.ToString(hash); - - Guid guid = new Guid(hash); - + Guid guid = new(hash); return guid; } @@ -2495,7 +2602,7 @@ public static OSDMap GetOSDMap(Stream stream, int length) byte[] data = new byte[length]; stream.Read(data, 0, length); string strdata = Util.UTF8.GetString(data); - OSDMap args = null; + OSDMap args; OSD buffer; buffer = OSDParser.DeserializeJson(strdata); if (buffer.Type == OSDType.Map) @@ -2508,7 +2615,7 @@ public static OSDMap GetOSDMap(Stream stream, int length) public static OSDMap GetOSDMap(string data) { - OSDMap args = null; + OSDMap args; try { OSD buffer; @@ -2522,13 +2629,13 @@ public static OSDMap GetOSDMap(string data) else { // uh? - m_log.Debug(("[UTILS]: Got OSD of unexpected type " + buffer.Type.ToString())); + m_log.Debug($"[UTILS]: Got OSD of unexpected type {buffer.Type}"); return null; } } catch (Exception ex) { - m_log.Debug("[UTILS]: exception on GetOSDMap " + ex.Message); + m_log.Debug($"[UTILS]: exception on GetOSDMap {ex.Message}"); return null; } } @@ -2558,8 +2665,8 @@ public static string[] Glob(string path) else path = new String(new char[] { Path.DirectorySeparatorChar }); - List paths = new List(); - List found = new List(); + List paths = new(); + List found = new(); paths.Add(path); int compIndex = -1; @@ -2567,7 +2674,7 @@ public static string[] Glob(string path) { compIndex++; - List addpaths = new List(); + List addpaths = new(); foreach (string p in paths) { string[] dirs = Directory.GetDirectories(p, c); @@ -2608,7 +2715,7 @@ public static string TrimEndSlash(string path) int len = path.Length; --len; if (len > 0 && path[len] == '/') - return path.Substring(0, len); + return path[..len]; return path; } @@ -2630,7 +2737,7 @@ public static string ServerURIasIP(string uri) try { - port1 = uri.Split(new char[] { ':' })[2]; + port1 = uri.Split(Util.SplitColonArray)[2]; } catch { } @@ -2649,12 +2756,13 @@ public static string ServerURIasIP(string uri) /// Arguments to substitute into the string via the {} mechanism. /// /// + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] StringToBytes256(string str, params object[] args) { return Utils.StringToBytes(string.Format(str, args), 255); } - + */ /// /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. /// @@ -2664,7 +2772,7 @@ public static byte[] StringToBytes256(string str, params object[] args) /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte[] StringToBytes256(string str) + public static byte[] StringToBytes256(ReadOnlySpan str) { return Utils.StringToBytes(str, 255); } @@ -2680,11 +2788,13 @@ public static byte[] StringToBytes256(string str) /// Arguments to substitute into the string via the {} mechanism. /// /// + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] StringToBytes1024(string str, params object[] args) { - return Utils.StringToBytes(string.Format(str, args), 1024); + return Utils.StringToBytes(string.Format(str, args).AsSpan(), 1024); } + */ /// /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 1024 bytes if necessary. @@ -2695,7 +2805,7 @@ public static byte[] StringToBytes1024(string str, params object[] args) /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte[] StringToBytes1024(string str) + public static byte[] StringToBytes1024(ReadOnlySpan str) { return Utils.StringToBytes(str, 1024); } @@ -2711,11 +2821,13 @@ public static byte[] StringToBytes1024(string str) /// Arguments to substitute into the string via the {} mechanism. /// /// + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte[] StringToBytes(string str, int MaxLength, params object[] args) { - return StringToBytes1024(string.Format(str, args), MaxLength); + return Utils.StringToBytes(string.Format(str, args).AsSpan(), MaxLength); } + */ /// /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to MaxLength bytes if necessary. @@ -2726,26 +2838,26 @@ public static byte[] StringToBytes(string str, int MaxLength, params object[] ar /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte[] StringToBytes(string str, int MaxLength) + public static byte[] StringToBytes(ReadOnlySpan str, int MaxLength) { return Utils.StringToBytes(str, MaxLength); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static byte[] StringToBytesNoTerm(string str, int MaxLength) + public static byte[] StringToBytesNoTerm(ReadOnlySpan str, int MaxLength) { return Utils.StringToBytesNoTerm(str, MaxLength); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int osUTF8Getbytes(string srcstr, byte[] dstarray, int maxdstlen, bool NullTerm = true) + public static int osUTF8Getbytes(ReadOnlySpan srcstr, byte[] dstarray, int maxdstlen, bool NullTerm = true) { return osUTF8Getbytes(srcstr, dstarray, 0, maxdstlen, NullTerm); } - public static unsafe int osUTF8Getbytes(string srcstr, byte* dstarray, int maxdstlen, bool NullTerm = true) + public static unsafe int osUTF8Getbytes(ReadOnlySpan srcstr, byte* dstarray, int maxdstlen, bool NullTerm = true) { - if (string.IsNullOrEmpty(srcstr)) + if (srcstr.Length == 0) return 0; fixed (char* srcbase = srcstr) @@ -2754,9 +2866,9 @@ public static unsafe int osUTF8Getbytes(string srcstr, byte* dstarray, int maxds } } - public static unsafe int osUTF8Getbytes(string srcstr, byte[] dstarray, int pos, int maxdstlen, bool NullTerm = true) + public static unsafe int osUTF8Getbytes(ReadOnlySpan srcstr, byte[] dstarray, int pos, int maxdstlen, bool NullTerm = true) { - if (string.IsNullOrEmpty(srcstr)) + if (srcstr.Length == 0) return 0; if (pos + maxdstlen > dstarray.Length) @@ -2861,13 +2973,13 @@ public static unsafe int osUTF8Getbytes(char* srcarray, int srclength, byte* dst /// public static string PrettyFormatToSingleLine(Hashtable ht) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); int i = 0; foreach (string key in ht.Keys) { - sb.AppendFormat("{0}:{1}", key, ht[key]); + sb.Append($"{key}:{ht[key]}"); if (++i < ht.Count) sb.AppendFormat(", "); @@ -2884,7 +2996,7 @@ public static bool TryParseHttpRange(string header, out int start, out int end) if (header.StartsWith("bytes=")) { - string[] rangeValues = header.Substring(6).Split('-'); + string[] rangeValues = header[6..].Split('-'); if (rangeValues.Length == 2) { @@ -2932,10 +3044,10 @@ public static bool TryParseHttpRange(string header, out int start, out int end) public static void InitThreadPool(int minThreads, int maxThreads) { if (maxThreads < 2) - throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2"); + throw new ArgumentOutOfRangeException(nameof(maxThreads), "maxThreads must be greater than 2"); if (minThreads > maxThreads || minThreads < 2) - throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads"); + throw new ArgumentOutOfRangeException(nameof(minThreads), "minThreads must be greater than 2 and less than or equal to maxThreads"); if (m_ThreadPool != null) { @@ -2943,7 +3055,7 @@ public static void InitThreadPool(int minThreads, int maxThreads) return; } - STPStartInfo startInfo = new STPStartInfo() + STPStartInfo startInfo = new() { ThreadPoolName = "Util", IdleTimeout = 20000, @@ -2963,15 +3075,14 @@ public static int FireAndForgetCount() switch (FireAndForgetMethod) { case FireAndForgetMethod.QueueUserWorkItem: - int workerThreads, iocpThreads; - ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); + ThreadPool.GetAvailableThreads(out int workerThreads, out _); return workerThreads; case FireAndForgetMethod.SmartThreadPool: return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads; case FireAndForgetMethod.Thread: { - using (Process p = System.Diagnostics.Process.GetCurrentProcess()) - return MAX_SYSTEM_THREADS - p.Threads.Count; + using Process p = System.Diagnostics.Process.GetCurrentProcess(); + return MAX_SYSTEM_THREADS - p.Threads.Count; } default: throw new NotImplementedException(); @@ -3062,7 +3173,7 @@ public string GetStackTrace() public static long TotalRunningFireAndForgetCalls { get { return numRunningThreadFuncs; } } // Maps (ThreadFunc number -> Thread) - private static ConcurrentDictionary activeThreads = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary activeThreads = new(); private static readonly int THREAD_TIMEOUT = 10 * 60 * 1000; // 10 minutes @@ -3076,10 +3187,9 @@ private static void ThreadPoolWatchdog(object state) ThreadInfo t = entry.Value; if (t.DoTimeout && t.Running && !t.Aborted && (t.Elapsed() >= THREAD_TIMEOUT)) { - m_log.WarnFormat("Timeout in threadfunc {0} ({1}) {2}", t.ThreadFuncNum, t.Thread.Name, t.GetStackTrace()); + m_log.Warn($"Timeout in threadfunc {t.ThreadFuncNum} ({t.Thread.Name}) {t.GetStackTrace()}"); t.Abort(); - - activeThreads.TryRemove(entry.Key, out ThreadInfo dummy); + activeThreads.TryRemove(entry.Key, out _); // It's possible that the thread won't abort. To make sure the thread pool isn't // depleted, increase the pool size. @@ -3095,14 +3205,14 @@ public static Dictionary GetFireAndForgetCallsMade() return new Dictionary(m_fireAndForgetCallsMade); } - private static readonly Dictionary m_fireAndForgetCallsMade = new Dictionary(); + private static readonly Dictionary m_fireAndForgetCallsMade = new(); public static Dictionary GetFireAndForgetCallsInProgress() { return new Dictionary(m_fireAndForgetCallsInProgress); } - private static readonly Dictionary m_fireAndForgetCallsInProgress = new Dictionary(); + private static readonly Dictionary m_fireAndForgetCallsInProgress = new(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void FireAndForget(System.Threading.WaitCallback callback) @@ -3124,7 +3234,7 @@ public static void FireAndForget(System.Threading.WaitCallback callback, object bool loggingEnabled = LogThreadPool > 0; long threadFuncNum = Interlocked.Increment(ref nextThreadFuncNum); - ThreadInfo threadInfo = new ThreadInfo(threadFuncNum, context, dotimeout); + ThreadInfo threadInfo = new(threadFuncNum, context, dotimeout); if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) { @@ -3161,14 +3271,14 @@ public static void FireAndForget(System.Threading.WaitCallback callback, object } catch (Exception e) { - m_log.Error(string.Format("[UTIL]: Util STP threadfunc {0} terminated with error ", threadFuncNum), e); + m_log.Error($"[UTIL]: Util STP threadfunc {threadFuncNum} terminated with error {e.Message}"); } finally { Interlocked.Decrement(ref numRunningThreadFuncs); activeThreads.TryRemove(threadFuncNum, out ThreadInfo dummy); if (loggingEnabled && threadInfo.LogThread) - m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed())); + m_log.Debug($"Exit threadfunc {threadFuncNum} ({FormatDuration(threadInfo.Elapsed())}"); callback = null; o = null; threadInfo = null; @@ -3196,7 +3306,7 @@ public static void FireAndForget(System.Threading.WaitCallback callback, object threadInfo.WorkItem = m_ThreadPool.QueueWorkItem(realCallback, obj); break; case FireAndForgetMethod.Thread: - Thread thread = new Thread(delegate (object o) { realCallback(o); realCallback = null; }); + Thread thread = new(delegate (object o) { realCallback(o); realCallback = null; }); thread.Start(obj); break; default: @@ -3238,7 +3348,7 @@ private static void GetFireAndForgetStackTrace(out string full, out string parti string src = Environment.StackTrace; string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); - StringBuilder dest = new StringBuilder(src.Length); + StringBuilder dest = new(src.Length); bool started = false; bool first = true; @@ -3273,7 +3383,6 @@ private static void GetFireAndForgetStackTrace(out string full, out string parti full = dest.ToString(); } -#pragma warning disable 0618 /// /// Return the stack trace of a different thread. /// @@ -3291,7 +3400,6 @@ private static void GetFireAndForgetStackTrace(out string full, out string parti /// The stack trace, or null if failed to get it private static StackTrace GetStackTrace(Thread targetThread) { - return null; /* not only this does not work on mono but it is not longer recomended on windows. @@ -3361,7 +3469,6 @@ can cause deadlocks etc. } */ } -#pragma warning restore 0618 /// /// Get information about the current state of the smart thread pool. @@ -3458,8 +3565,8 @@ public static Int32 EnvironmentTickCountCompare(Int32 tcA, Int32 tcB) public static long GetPhysicalMemUse() { - using (Process p = System.Diagnostics.Process.GetCurrentProcess()) - return p.WorkingSet64; + using Process p = System.Diagnostics.Process.GetCurrentProcess(); + return p.WorkingSet64; } // returns a timestamp in seconds as double @@ -3503,7 +3610,7 @@ public static void AddToGatheredIds(Dictionary uuids, UUID id, sbyt /// public static string FormatDuration(int ms) { - TimeSpan span = new TimeSpan(ms * TimeSpan.TicksPerMillisecond); + TimeSpan span = new(ms * TimeSpan.TicksPerMillisecond); string str = ""; string suffix = null; @@ -3520,8 +3627,7 @@ public static string FormatDuration(int ms) if (str.Length > 0) str += ":"; str += span.Minutes.ToString(str.Length == 0 ? "0" : "00"); - if (suffix == null) - suffix = "min"; + suffix ??= "min"; } if ((hours > 0) || (span.Minutes > 0) || (span.Seconds > 0)) @@ -3529,12 +3635,10 @@ public static string FormatDuration(int ms) if (str.Length > 0) str += ":"; str += span.Seconds.ToString(str.Length == 0 ? "0" : "00"); - if (suffix == null) - suffix = "sec"; + suffix ??= "sec"; } - if (suffix == null) - suffix = "ms"; + suffix ??= "ms"; if (span.TotalMinutes < 1) { @@ -3563,14 +3667,14 @@ public static void PrintCallStack() public delegate void DebugPrinter(string msg, params Object[] parm); public static void PrintCallStack(DebugPrinter printer) { - StackTrace stackTrace = new StackTrace(true); // get call stack + StackTrace stackTrace = new(true); // get call stack StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) // write call stack method names foreach (StackFrame stackFrame in stackFrames) { MethodBase mb = stackFrame.GetMethod(); - printer("{0}.{1}:{2}", mb.DeclaringType, mb.Name, stackFrame.GetFileLineNumber()); // write method name + printer($"{mb.DeclaringType}.{mb.Name}:{stackFrame.GetFileLineNumber()}"); // write method name } } @@ -3584,7 +3688,7 @@ public static IPEndPoint GetClientIPFromXFF(string xff) if (xff.Length == 0) return null; - string[] parts = xff.Split(new char[] { ',' }); + string[] parts = xff.Split(Util.SplitCommaArray); if (parts.Length > 0) { try @@ -3593,7 +3697,7 @@ public static IPEndPoint GetClientIPFromXFF(string xff) } catch (Exception e) { - m_log.WarnFormat("[UTIL]: Exception parsing XFF header {0}: {1}", xff, e.Message); + m_log.Warn($"[UTIL]: Exception parsing XFF header {xff}: {e.Message}"); } } @@ -3612,7 +3716,7 @@ public static string GetCallerIP(Hashtable req) } catch (Exception e) { - m_log.WarnFormat("[UTIL]: exception in GetCallerIP: {0}", e.Message); + m_log.Warn($"[UTIL]: exception in GetCallerIP: {e.Message}"); } } return string.Empty; @@ -3632,20 +3736,17 @@ public static bool ReadBoolean(XmlReader reader) public static UUID ReadUUID(XmlReader reader, string name) { - string idStr; - reader.ReadStartElement(name); - - if (reader.Name == "Guid") - idStr = reader.ReadElementString("Guid"); - else if (reader.Name == "UUID") - idStr = reader.ReadElementString("UUID"); - else // no leading tag - idStr = reader.ReadContentAsString(); - - UUID.TryParse(idStr, out UUID id); + string idStr = reader.Name switch + { + "Guid" => reader.ReadElementString("Guid"), + "UUID" => reader.ReadElementString("UUID"), + // no leading tag + _ => reader.ReadContentAsString(), + }; reader.ReadEndElement(); + UUID.TryParse(idStr, out UUID id); return id; } @@ -3664,7 +3765,7 @@ public static Vector3 ReadVector(XmlReader reader, string name) public static Quaternion ReadQuaternion(XmlReader reader, string name) { - Quaternion quat = new Quaternion(); + Quaternion quat = new(); reader.ReadStartElement(name); while (reader.NodeType != XmlNodeType.EndElement) @@ -3695,10 +3796,10 @@ public static T ReadEnum(XmlReader reader, string name) { string value = reader.ReadElementContentAsString(name, String.Empty); // !!!!! to deal with flags without commas - if (value.Contains(" ") && !value.Contains(",")) + if (value.Contains(' ') && !value.Contains(',')) value = value.Replace(" ", ", "); - return (T)Enum.Parse(typeof(T), value); ; + return (T)Enum.Parse(typeof(T), value); } #endregion @@ -3734,7 +3835,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; firstname = string.Empty; @@ -3761,7 +3862,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); ++indxB; if (indxB >= value.Length) @@ -3772,14 +3873,14 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu } string n; if (nseps == 2) - n = value.Substring(indxB).Trim(); + n = value[indxB..].Trim(); else { indxA = seps[2]; - n = value.Substring(indxB, indxA - indxB); + n = value[indxB..indxA]; ++indxA; if (indxA < value.Length) - secret = value.Substring(indxA); + secret = value[indxA..]; } string[] name = n.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); @@ -3809,7 +3910,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; firstname = string.Empty; @@ -3836,7 +3937,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); ++indxB; if (indxB >= value.Length) @@ -3847,14 +3948,14 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI } string n; if (nseps == 2) - n = value.Substring(indxB).Trim(); + n = value[indxB..].Trim(); else { indxA = seps[2]; - n = value.Substring(indxB, indxA - indxB); + n = value[indxB..indxA]; ++indxA; if (indxA < value.Length) - secret = value.Substring(indxA); + secret = value[indxA..]; } string[] name = n.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); @@ -3890,7 +3991,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; firstname = string.Empty; @@ -3916,7 +4017,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); ++indxB; if (indxB >= value.Length) @@ -3927,9 +4028,9 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu } string n; if (nseps == 2) - n = value.Substring(indxB); + n = value[indxB..]; else - n = value.Substring(indxB, seps[2] - indxB); + n = value[indxB..seps[2]]; string[] name = n.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (name.Length == 0) @@ -3956,7 +4057,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; firstname = string.Empty; @@ -3982,7 +4083,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); ++indxB; if (indxB >= value.Length) @@ -3993,9 +4094,9 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI } string n; if (nseps == 2) - n = value.Substring(indxB); + n = value[indxB..]; else - n = value.Substring(indxB, seps[2] - indxB); + n = value[indxB..seps[2]]; string[] name = n.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (name.Length == 0) @@ -4020,7 +4121,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; return false; @@ -4043,7 +4144,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); indxA = seps[1] + 3; indxB = nseps > 2 ? seps[2] : value.Length; @@ -4060,7 +4161,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu return false; } - if (!UUID.TryParse(value.Substring(0, 36), out uuid)) + if (!UUID.TryParse(value[..36], out uuid)) { url = string.Empty; return false; @@ -4083,7 +4184,7 @@ public static unsafe bool ParseUniversalUserIdentifier(string value, out UUID uu int indxA = seps[0] + 1; int indxB = seps[1]; - url = value.Substring(indxA, indxB - indxA).Trim().ToLower(); + url = value[indxA..indxB].Trim().ToLower(); return true; } @@ -4109,7 +4210,7 @@ public static unsafe bool ParseFullUniversalUserIdentifier(string value, out UUI return false; } - if (!UUID.TryParse(value.Substring(0, seps[0]), out uuid)) + if (!UUID.TryParse(value[..seps[0]], out uuid)) return false; int indxA = seps[1] + 3; @@ -4125,7 +4226,7 @@ public static bool ParseUniversalUserIdentifier(string value, out UUID uuid) uuid = UUID.Zero; return false; } - return (value.Length == 36) ? UUID.TryParse(value, out uuid) : UUID.TryParse(value.Substring(0, 36), out uuid); + return (value.Length == 36) ? UUID.TryParse(value, out uuid) : UUID.TryParse(value[..36], out uuid); } public static unsafe string RemoveUniversalUserIdentifierSecret(string value) @@ -4141,7 +4242,7 @@ public static unsafe string RemoveUniversalUserIdentifierSecret(string value) } if (nseps < 3) return value; - return value.Substring(0, seps[3]); + return value[..seps[3]]; } /// @@ -4152,7 +4253,7 @@ public static bool ParseForeignAvatarName(string firstname, string lastname, { realFirstName = realLastName = serverURI = string.Empty; - if (!lastname.Contains("@")) + if (!lastname.Contains('@')) return false; string[] parts = firstname.Split('.'); @@ -4162,7 +4263,7 @@ public static bool ParseForeignAvatarName(string firstname, string lastname, realFirstName = parts[0].Trim(); realLastName = parts[1].Trim(); lastname = lastname.Trim(); - serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); + serverURI = new Uri($"http://{lastname.Replace("@", "")}").ToString(); return true; } @@ -4202,7 +4303,7 @@ public static int ParseAvatarName(string name, out string FirstName, out string ++i; } - FirstName = name.Substring(start, i - start); + FirstName = name[start..i]; if (i >= name.Length - 1) return 1; @@ -4232,19 +4333,19 @@ public static int ParseAvatarName(string name, out string FirstName, out string if (j <= start) return 0; - LastName = name.Substring(start, j - start); + LastName = name[start..j]; ++i; while (i < name.Length && name[i] == ' ') ++i; if (i > name.Length - 3) return 0; - serverURI = name.Substring(i).TrimEnd(); + serverURI = name[i..].TrimEnd(); return serverURI.Length == 0 ? 2 : 3; } ++i; } - LastName = name.Substring(start).TrimEnd(); + LastName = name[start..].TrimEnd(); return LastName.Length == 0 ? 1 : 2; } @@ -4272,14 +4373,14 @@ public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) public static string UniversalIdentifier(UUID id, String firstName, String lastName, String homeURI) { string agentsURI = homeURI; - if (!agentsURI.EndsWith("/")) + if (!agentsURI.EndsWith('/')) agentsURI += "/"; // This is ugly, but there's no other way, given that the name is changed // in the agent circuit data for foreigners - if (lastName.Contains("@")) + if (lastName.Contains('@')) { - string[] parts = firstName.Split(new char[] { '.' }); + string[] parts = firstName.Split(Util.SplitDotArray); if (parts.Length == 2) return CalcUniversalIdentifier(id, agentsURI, parts[0].Trim() + " " + parts[1].Trim()); } @@ -4301,16 +4402,16 @@ private static string CalcUniversalIdentifier(UUID id, string agentsURI, string /// string of the form first.last @foo.com or first last public static string UniversalName(String firstName, String lastName, String homeURI) { - Uri uri = null; + Uri uri; try { uri = new Uri(homeURI); } catch (UriFormatException) { - return firstName.Trim() + " " + lastName.Trim(); + return $"{firstName.Trim()} {lastName.Trim()}"; } - return firstName.Trim() + "." + lastName.Trim() + " " + "@" + uri.Authority; + return $"{firstName.Trim()}.{lastName.Trim()}@{uri.Authority}"; } #endregion @@ -4361,7 +4462,7 @@ public static void LogFailedXML(string message, string xml) { int length = xml.Length; if (length > 250) - xml = xml.Substring(0, 250) + "..."; + xml = xml[..250] + "..."; for (int i = 0; i < xml.Length; i++) { @@ -4372,7 +4473,7 @@ public static void LogFailedXML(string message, string xml) } } - m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml); + m_log.Error($"{message} Failed XML ({length} bytes) = {xml}"); } /// @@ -4384,9 +4485,9 @@ public static void LogFailedXML(string message, string xml) /// Resized image public static Bitmap ResizeImageSolid(Image image, int width, int height) { - Bitmap result = new Bitmap(width, height, PixelFormat.Format24bppRgb); + Bitmap result = new(width, height, PixelFormat.Format24bppRgb); - using (ImageAttributes atrib = new ImageAttributes()) + using (ImageAttributes atrib = new()) using (Graphics graphics = Graphics.FromImage(result)) { atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY); @@ -4410,174 +4511,23 @@ public static void SaveAssetToFile(string filename, byte[] data) Directory.CreateDirectory(assetPath); } FileStream fs = File.Create(Path.Combine(assetPath, filename)); - BinaryWriter bw = new BinaryWriter(fs); + BinaryWriter bw = new(fs); bw.Write(data); bw.Close(); fs.Close(); } - } - - /* don't like this code - public class DoubleQueue where T:class - { - private Queue m_lowQueue = new Queue(); - private Queue m_highQueue = new Queue(); - - private object m_syncRoot = new object(); - private Semaphore m_s = new Semaphore(0, 1); - - public DoubleQueue() - { - } - - public virtual int Count - { - get - { - lock (m_syncRoot) - return m_highQueue.Count + m_lowQueue.Count; - } - } - - public virtual void Enqueue(T data) - { - Enqueue(m_lowQueue, data); - } - - public virtual void EnqueueLow(T data) - { - Enqueue(m_lowQueue, data); - } - public virtual void EnqueueHigh(T data) - { - Enqueue(m_highQueue, data); - } - - private void Enqueue(Queue q, T data) - { - lock (m_syncRoot) - { - q.Enqueue(data); - m_s.WaitOne(0); - m_s.Release(); - } - } - - public virtual T Dequeue() - { - return Dequeue(Timeout.Infinite); - } - - public virtual T Dequeue(int tmo) - { - return Dequeue(TimeSpan.FromMilliseconds(tmo)); - } - - public virtual T Dequeue(TimeSpan wait) - { - T res = null; - - if (!Dequeue(wait, ref res)) - return null; - - return res; - } - - public bool Dequeue(int timeout, ref T res) - { - return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res); - } - - public bool Dequeue(TimeSpan wait, ref T res) - { - if (!m_s.WaitOne(wait)) - return false; - - lock (m_syncRoot) - { - if (m_highQueue.Count > 0) - res = m_highQueue.Dequeue(); - else if (m_lowQueue.Count > 0) - res = m_lowQueue.Dequeue(); - - if (m_highQueue.Count == 0 && m_lowQueue.Count == 0) - return true; - - try - { - m_s.Release(); - } - catch - { - } - - return true; - } - } - - public virtual void Clear() - { - - lock (m_syncRoot) - { - // Make sure sem count is 0 - m_s.WaitOne(0); - - m_lowQueue.Clear(); - m_highQueue.Clear(); - } - } - } - */ - public class BetterRandom - { - private const int BufferSize = 1024; // must be a multiple of 4 - private byte[] RandomBuffer; - private int BufferOffset; - private RNGCryptoServiceProvider rng; - public BetterRandom() - { - RandomBuffer = new byte[BufferSize]; - rng = new RNGCryptoServiceProvider(); - BufferOffset = RandomBuffer.Length; - } - private void FillBuffer() - { - rng.GetBytes(RandomBuffer); - BufferOffset = 0; - } - public int Next() - { - if (BufferOffset >= RandomBuffer.Length) - { - FillBuffer(); - } - int val = BitConverter.ToInt32(RandomBuffer, BufferOffset) & 0x7fffffff; - BufferOffset += sizeof(int); - return val; - } - public int Next(int maxValue) - { - return Next() % maxValue; - } - public int Next(int minValue, int maxValue) - { - if (maxValue < minValue) - { - throw new ArgumentOutOfRangeException("maxValue must be greater than or equal to minValue"); - } - int range = maxValue - minValue; - return minValue + Next(range); - } - public double NextDouble() + //https://www.color.org/sRGB.pdf + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float LinearTosRGB(float linear) { - int val = Next(); - return (double)val / int.MaxValue; + return linear <= 0.0031308f ? (linear * 12.92f) : (1.055f * MathF.Pow(linear, 0.4166667f) - 0.055f); } - public void GetBytes(byte[] buff) + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float sRGBtoLinear(float rgb) { - rng.GetBytes(buff); + return (rgb < 0.04045f) ? rgb * 0.07739938f : MathF.Pow((rgb + 0.055f) / 1.055f, 2.4f); } } } diff --git a/OpenSim/Framework/VersionInfo.cs b/OpenSim/Framework/VersionInfo.cs index 4391af35837..ee4a4bbd09f 100644 --- a/OpenSim/Framework/VersionInfo.cs +++ b/OpenSim/Framework/VersionInfo.cs @@ -37,8 +37,8 @@ namespace OpenSim { public class VersionInfo { - public const string VersionNumber = "0.9.2.2"; - public const string AssemblyVersionNumber = "0.9.2.2"; + public const string VersionNumber = "0.9.3.0"; + public const string AssemblyVersionNumber = "0.9.3.0"; public const string Release = "8738"; public static string Version @@ -48,7 +48,7 @@ public static string Version public static string GetVersionString(string versionNumber, string release) { - string versionString = "OpenSim-NGC Tranquillity " + versionNumber + "." + release; + string versionString = $"OpenSim-NGC Tranquillity {versionNumber}.{release}"; return versionString.PadRight(VERSIONINFO_VERSION_LENGTH); } diff --git a/OpenSim/Framework/VersionInfo.tt b/OpenSim/Framework/VersionInfo.tt index b8a22e42b2c..fded930ac93 100644 --- a/OpenSim/Framework/VersionInfo.tt +++ b/OpenSim/Framework/VersionInfo.tt @@ -37,8 +37,8 @@ namespace OpenSim { public class VersionInfo { - public const string VersionNumber = "0.9.2.2"; - public const string AssemblyVersionNumber = "0.9.2.2"; + public const string VersionNumber = "0.9.3.0"; + public const string AssemblyVersionNumber = "0.9.3.0"; public const string Release = "<#= (int)DateTimeOffset.UtcNow.Subtract(new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero)).TotalDays #>"; public static string Version @@ -48,7 +48,7 @@ namespace OpenSim public static string GetVersionString(string versionNumber, string release) { - string versionString = "OpenSim-NGC Tranquillity " + versionNumber + "." + release; + string versionString = $"OpenSim-NGC Tranquillity {versionNumber}.{release}"; return versionString.PadRight(VERSIONINFO_VERSION_LENGTH); } diff --git a/OpenSim/Framework/ViewerEnvironment.cs b/OpenSim/Framework/ViewerEnvironment.cs index 7042c7ee778..65ca2482a83 100644 --- a/OpenSim/Framework/ViewerEnvironment.cs +++ b/OpenSim/Framework/ViewerEnvironment.cs @@ -36,38 +36,38 @@ namespace OpenSim.Framework // legacy lightshare public class RegionLightShareData { - public Vector3 waterColor = new Vector3(4.0f, 38.0f, 64.0f); + public Vector3 waterColor = new(4.0f, 38.0f, 64.0f); public float waterFogDensityExponent = 4.0f; public float underwaterFogModifier = 0.25f; - public Vector3 reflectionWaveletScale = new Vector3(2.0f, 2.0f, 2.0f); + public Vector3 reflectionWaveletScale = new(2.0f, 2.0f, 2.0f); public float fresnelScale = 0.40f; public float fresnelOffset = 0.50f; public float refractScaleAbove = 0.03f; public float refractScaleBelow = 0.20f; public float blurMultiplier = 0.040f; - public Vector2 bigWaveDirection = new Vector2(1.05f, -0.42f); - public Vector2 littleWaveDirection = new Vector2(1.11f, -1.16f); - public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); - public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f); + public Vector2 bigWaveDirection = new(1.05f, -0.42f); + public Vector2 littleWaveDirection = new(1.11f, -1.16f); + public UUID normalMapTexture = new("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); + public Vector4 horizon = new(0.25f, 0.25f, 0.32f, 0.32f); public float hazeHorizon = 0.19f; - public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f); + public Vector4 blueDensity = new(0.12f, 0.22f, 0.38f, 0.38f); public float hazeDensity = 0.70f; public float densityMultiplier = 0.18f; public float distanceMultiplier = 0.8f; public UInt16 maxAltitude = 1605; - public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f); + public Vector4 sunMoonColor = new(0.24f, 0.26f, 0.30f, 0.30f); public float sunMoonPosition = 0.317f; - public Vector4 ambient = new Vector4(0.35f, 0.35f, 0.35f, 0.35f); + public Vector4 ambient = new(0.35f, 0.35f, 0.35f, 0.35f); public float eastAngle = 0.0f; public float sunGlowFocus = 0.10f; public float sunGlowSize = 1.75f; public float sceneGamma = 1.0f; public float starBrightness = 0.0f; - public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f); - public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f); + public Vector4 cloudColor = new(0.41f, 0.41f, 0.41f, 0.41f); + public Vector3 cloudXYDensity = new(1.00f, 0.53f, 1.00f); public float cloudCoverage = 0.27f; public float cloudScale = 0.42f; - public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f); + public Vector3 cloudDetailXYDensity = new(1.00f, 0.53f, 0.12f); public float cloudScrollX = 0.20f; public bool cloudScrollXLock = false; public float cloudScrollY = 0.01f; @@ -77,7 +77,7 @@ public class RegionLightShareData public class ViewerEnvironment { - DayCycle Cycle = new DayCycle(); + DayCycle Cycle = new(); public int DayLength = 14400; public int DayOffset = 57600; public int Flags = 0; @@ -104,7 +104,7 @@ public void FromWLOSD(OSD osd) public OSD ToWLOSD(UUID message, UUID region) { - OSDArray array = new OSDArray(4) { null, null, null, null }; + OSDArray array = new() { null, null, null, null }; array[0] = new OSDMap { {"messageID", message }, { "regionID", region } }; Cycle.ToWLOSD(ref array); return array; @@ -115,23 +115,23 @@ private static Quaternion AzAlToRot(float az, float al) if (Utils.ApproxEqual(al, 0, 1e-3f) || Utils.ApproxEqual(Math.Abs(al), Utils.TWO_PI, 1e-3f)) { az *= 0.5f; - return new Quaternion(0, 0, (float)Math.Sin(az), (float)Math.Cos(az)); + return new Quaternion(0, 0, MathF.Sin(az), MathF.Cos(az)); } if (Utils.ApproxEqual(az, 0, 1e-3f) || Utils.ApproxEqual(Math.Abs(az), Utils.TWO_PI, 1e-3f)) { al *= 0.5f; - return new Quaternion(0, -(float)Math.Sin(al), 0, (float)Math.Cos(al)); + return new Quaternion(0, -MathF.Sin(al), 0, MathF.Cos(al)); } az *= 0.5f; - float sz = (float)Math.Sin(az); - float cz = (float)Math.Cos(az); + float sz = MathF.Sin(az); + float cz = MathF.Cos(az); al *= 0.5f; - float sl = (float)Math.Sin(al); - float cl = (float)Math.Cos(al); + float sl = MathF.Sin(al); + float cl = MathF.Cos(al); - Quaternion rot = new Quaternion(sl * sz, -sl * cz, cl * sz, cl * cz); + Quaternion rot = new(sl * sz, -sl * cz, cl * sz, cl * cz); rot.Normalize(); return rot; } @@ -142,7 +142,7 @@ public static void convertFromAngles(SkyData sky, float sun_angle, float east_an float al = sun_angle; sky.sun_rotation = AzAlToRot(az, al); - sky.moon_rotation = AzAlToRot(az, al + (float)Math.PI); + sky.moon_rotation = AzAlToRot(az, al + MathF.PI); } public static Vector3 Xrot(Quaternion rot) @@ -162,17 +162,16 @@ public static void convertToAngles(SkyData sky, out float sun_angle, out float e else if (v.Z > -0.12) { float m = v.Y * v.Y + v.Z * v.Z; - m = 1/(float)Math.Sqrt(m); + m = 1.0f / MathF.Sqrt(m); lightnorm = new Vector4(v.Y * m, 0, v.X * m, 1); } else lightnorm = new Vector4(-v.Y, -v.Z, -v.X, 1); - sun_angle = (float)Math.Asin(v.Z); - east_angle = -(float)Math.Atan2(v.Y, v.X); + sun_angle = MathF.Asin(v.Z); + east_angle = -MathF.Atan2(v.Y, v.X); - - if (Math.Abs(east_angle) < 1e-6) + if (MathF.Abs(east_angle) < 1e-6f) east_angle = 0; else if (east_angle < 0) east_angle = Utils.TWO_PI + east_angle; @@ -185,7 +184,7 @@ public static void convertToAngles(SkyData sky, out float sun_angle, out float e sun_angle = Utils.PI - sun_angle; } */ - if (Math.Abs(sun_angle) < 1e-6) + if (MathF.Abs(sun_angle) < 1e-6f) sun_angle = 0; else if (sun_angle < 0) sun_angle = Utils.TWO_PI + sun_angle; @@ -194,29 +193,30 @@ public static void convertToAngles(SkyData sky, out float sun_angle, out float e public void FromLightShare(RegionLightShareData ls) { - WaterData water = new WaterData(); - - water.waterFogColor = ls.waterColor / 256f; - water.waterFogDensity = (float)Math.Pow(2.0f, ls.waterFogDensityExponent); - //water.waterFogDensity = ls.waterFogDensityExponent; - water.underWaterFogMod = ls.underwaterFogModifier; - water.normScale = ls.reflectionWaveletScale; - water.fresnelScale = ls.fresnelScale; - water.fresnelOffset = ls.fresnelOffset; - water.scaleAbove = ls.refractScaleAbove; - water.scaleBelow = ls.refractScaleBelow; - water.blurMultiplier = ls.blurMultiplier; - water.wave1Dir = ls.littleWaveDirection; - water.wave2Dir = ls.bigWaveDirection; - water.normalMap = ls.normalMapTexture; - water.Name = "LightshareWater"; - - SkyData sky = new SkyData(); - convertFromAngles(sky, 2.0f * (float)Math.PI * ls.sunMoonPosition, 2.0f * (float)Math.PI * ls.eastAngle); + WaterData water = new() + { + waterFogColor = ls.waterColor / 256f, + waterFogDensity = MathF.Pow(2.0f, ls.waterFogDensityExponent), + //water.waterFogDensity = ls.waterFogDensityExponent; + underWaterFogMod = ls.underwaterFogModifier, + normScale = ls.reflectionWaveletScale, + fresnelScale = ls.fresnelScale, + fresnelOffset = ls.fresnelOffset, + scaleAbove = ls.refractScaleAbove, + scaleBelow = ls.refractScaleBelow, + blurMultiplier = ls.blurMultiplier, + wave1Dir = ls.littleWaveDirection, + wave2Dir = ls.bigWaveDirection, + normalMap = ls.normalMapTexture, + Name = "LightshareWater" + }; + + SkyData sky = new(); + convertFromAngles(sky, Utils.TWO_PI * ls.sunMoonPosition, Utils.TWO_PI * ls.eastAngle); sky.sunlight_color = ls.sunMoonColor * 3.0f; sky.ambient = new Vector3(ls.ambient.X * 3.0f, ls.ambient.Y * 3.0f, ls.ambient.Z * 3.0f); sky.blue_horizon = new Vector3(ls.horizon.X * 2.0f, ls.horizon.Y * 2.0f, ls.horizon.Z * 2.0f); - sky.blue_density = new Vector3(ls.blueDensity.X * 2.0f, ls.blueDensity.Y * 2.0f, ls.blueDensity.Z * 2.0f);; + sky.blue_density = new Vector3(ls.blueDensity.X * 2.0f, ls.blueDensity.Y * 2.0f, ls.blueDensity.Z * 2.0f); sky.haze_horizon = ls.hazeHorizon; sky.haze_density = ls.hazeDensity; sky.cloud_shadow = ls.cloudCoverage; @@ -237,14 +237,13 @@ public void FromLightShare(RegionLightShareData ls) sky.star_brightness = ls.starBrightness * 250f; sky.Name = "LightshareSky"; - Cycle = new DayCycle(); - Cycle.Name = "Lightshare"; + Cycle = new DayCycle { Name = "Lightshare" }; Cycle.waterframes.Add(water.Name, water); - DayCycle.TrackEntry track = new DayCycle.TrackEntry(-1, water.Name); + DayCycle.TrackEntry track = new(-1, water.Name); Cycle.waterTrack.Add(track); Cycle.skyframes.Add(sky.Name, sky); - track = new DayCycle.TrackEntry(-1, sky.Name); + track = new(-1, sky.Name); Cycle.skyTrack0.Add(track); InvalidateCaches(); @@ -252,7 +251,7 @@ public void FromLightShare(RegionLightShareData ls) public RegionLightShareData ToLightShare() { - RegionLightShareData ls = new RegionLightShareData(); + RegionLightShareData ls = new(); DayCycle.TrackEntry te; if (Cycle.waterTrack.Count > 0) @@ -261,7 +260,7 @@ public RegionLightShareData ToLightShare() if (Cycle.waterframes.TryGetValue(te.frameName, out WaterData water)) { ls.waterColor = water.waterFogColor * 256f; - ls.waterFogDensityExponent = (float)Math.Sqrt(water.waterFogDensity); + ls.waterFogDensityExponent = MathF.Sqrt(water.waterFogDensity); //ls.waterFogDensityExponent = water.waterFogDensity; ls.underwaterFogModifier = water.underWaterFogMod; ls.reflectionWaveletScale = water.normScale; @@ -281,10 +280,9 @@ public RegionLightShareData ToLightShare() te = Cycle.skyTrack0[0]; if (Cycle.skyframes.TryGetValue(te.frameName, out SkyData sky)) { - Vector4 lightnorm; - convertToAngles(sky, out ls.sunMoonPosition, out ls.eastAngle, out lightnorm); - ls.sunMoonPosition *= 0.5f / (float)Math.PI; - ls.eastAngle *= 0.5f / (float)Math.PI; + convertToAngles(sky, out ls.sunMoonPosition, out ls.eastAngle, out Vector4 _); + ls.sunMoonPosition *= 0.5f / MathF.PI; + ls.eastAngle *= 0.5f / MathF.PI; ls.sunMoonColor = sky.sunlight_color / 3f; ls.ambient = new Vector4(sky.ambient.X / 3.0f, sky.ambient.Y / 3.0f, sky.ambient.Z / 3.0f, 1); ls.horizon = new Vector4(sky.blue_horizon.X / 2.0f, sky.blue_horizon.Y / 2.0f, sky.blue_horizon.Z / 2.0f, 1); @@ -314,8 +312,7 @@ public RegionLightShareData ToLightShare() public void FromOSD(OSD osd) { - OSDMap map = osd as OSDMap; - if (map == null) + if (osd is not OSDMap map) return; OSD otmp; @@ -325,8 +322,8 @@ public void FromOSD(OSD osd) Cycle = new DayCycle(); Cycle.FromOSD(otmp as OSDMap); } - if (Cycle == null) - Cycle = new DayCycle(); + + Cycle ??= new DayCycle(); if (map.TryGetValue("day_length", out otmp)) DayLength = otmp; @@ -375,8 +372,7 @@ public void SortAltitudes() public bool CycleFromOSD(OSD osd) { - OSDMap map = osd as OSDMap; - if (map == null) + if (osd is not OSDMap map) return false; if (!map.TryGetValue("type", out OSD tmp)) return false; @@ -393,8 +389,7 @@ public bool CycleFromOSD(OSD osd) public bool FromAssetOSD(string name, OSD osd) { - OSDMap map = osd as OSDMap; - if (map == null) + if (osd is not OSDMap map) return false; if (!map.TryGetValue("type", out OSD tmp)) return false; @@ -403,8 +398,7 @@ public bool FromAssetOSD(string name, OSD osd) bool ok = false; if (type == "water") { - if (Cycle == null) - Cycle = new DayCycle(); + Cycle ??= new DayCycle(); ok = Cycle.replaceWaterFromOSD(name, map); } else @@ -417,8 +411,7 @@ public bool FromAssetOSD(string name, OSD osd) } else if(type == "sky") { - if (Cycle == null) - Cycle = new DayCycle(); + Cycle ??= new DayCycle(); ok = Cycle.replaceSkyFromOSD(name, map); } } @@ -431,22 +424,18 @@ public bool FromAssetOSD(string name, OSD osd) public OSD ToOSD() { - OSDMap env = new OSDMap(); - env["day_cycle"] = Cycle.ToOSD(); - env["day_length"] = DayLength; - env["day_offset"] = DayOffset; - env["flags"] = Flags; - env["env_version"] = version; - - OSDArray alt = new OSDArray(); - alt.Add(Altitudes[0]); - alt.Add(Altitudes[1]); - alt.Add(Altitudes[2]); - env["track_altitudes"] = alt; - return env; + return new OSDMap + { + ["day_cycle"] = Cycle.ToOSD(), + ["day_length"] = DayLength, + ["day_offset"] = DayOffset, + ["flags"] = Flags, + ["env_version"] = version, + ["track_altitudes"] = new OSDArray() { Altitudes[0], Altitudes[1], Altitudes[2] } + }; } - public readonly object m_cachedbytesLock = new object(); + public readonly object m_cachedbytesLock = new(); public byte[] m_cachedbytes = null; public byte[] m_cachedWLbytes = null; @@ -470,7 +459,7 @@ public byte[] ToCapBytes(UUID regionID, int parcelID) byte[] ret = m_cachedbytes; if (ret == null) { - OSDMap map = new OSDMap(); + OSDMap map = new(); OSDMap cenv = (OSDMap)ToOSD(); cenv["parcel_id"] = parcelID; cenv["region_id"] = regionID; @@ -509,7 +498,7 @@ public static ViewerEnvironment FromOSDString(string s) try { OSD eosd = OSDParser.Deserialize(s); - ViewerEnvironment VEnv = new ViewerEnvironment(); + ViewerEnvironment VEnv = new(); VEnv.FromOSD(eosd); return VEnv; } @@ -537,28 +526,29 @@ public ViewerEnvironment Clone() { // im lazy need to proper clone later OSD osd = ToOSD(); - ViewerEnvironment VEnv = new ViewerEnvironment(); + ViewerEnvironment VEnv = new(); VEnv.FromOSD(osd); return VEnv; } public static OSD DefaultToOSD(UUID regionID, int parcel) { - OSDMap top = new OSDMap(); - OSDMap env = new OSDMap(); - env["is_default"] = true; + OSDMap env = new() + { + ["is_default"] = true, + ["region_id"] = regionID, + ["track_altitudes"] = new OSDArray() { 1000f, 2000f, 3000f } + }; if (parcel >= 0) env["parcel_id"] = parcel; - env["region_id"] = regionID; - OSDArray alt = new OSDArray(); - alt.Add(1000f); - alt.Add(2000f); - alt.Add(3000f); - env["track_altitudes"] = alt; - top["environment"] = env; + + OSDMap top = new() + { + ["environment"] = env, + ["success"] = true + }; if (parcel >= 0) top["parcel_id"] = parcel; - top["success"] = true; return top; } @@ -667,13 +657,13 @@ public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out moonrot = Quaternion.Identity; List track = FindTrack(altitude); - if (track == null || track.Count == 0) + if (track is null || track.Count == 0) return false; if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2)) return false; - if (sky2 == null) + if (sky2 is null) { moonrot = sky1.moon_rotation; moondir = Xrot(moonrot); @@ -690,6 +680,92 @@ public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out return true; } + public bool getPositions_sundir(float altitude, float dayfrac, out Vector3 sundir) + { + sundir = Vector3.Zero; + + List track = FindTrack(altitude); + if (track is null || track.Count == 0) + return false; + + if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2)) + return false; + + if (sky2 is null) + { + sundir = Xrot(sky1.sun_rotation); + return true; + } + + Quaternion sunrot = Quaternion.Slerp(sky1.sun_rotation, sky2.sun_rotation, dayfrac); + sundir = Xrot(sunrot); + return true; + } + + public bool getPositions_sunrot(float altitude, float dayfrac, out Quaternion sunrot) + { + sunrot = Quaternion.Identity; + + List track = FindTrack(altitude); + if (track is null || track.Count == 0) + return false; + + if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2)) + return false; + + if (sky2 is null) + { + sunrot = sky1.sun_rotation; + return true; + } + + sunrot = Quaternion.Slerp(sky1.sun_rotation, sky2.sun_rotation, dayfrac); + return true; + } + + public bool getPositions_moondir(float altitude, float dayfrac, out Vector3 moondir) + { + moondir = Vector3.Zero; + + List track = FindTrack(altitude); + if (track is null || track.Count == 0) + return false; + + if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2)) + return false; + + if (sky2 is null) + { + moondir = Xrot(sky1.moon_rotation); + return true; + } + + Quaternion moonrot = Quaternion.Slerp(sky1.moon_rotation, sky2.moon_rotation, dayfrac); + moondir = Xrot(moonrot); + return true; + } + + public bool getPositions_moonrot(float altitude, float dayfrac, out Quaternion moonrot) + { + moonrot = Quaternion.Identity; + + List track = FindTrack(altitude); + if (track is null || track.Count == 0) + return false; + + if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2)) + return false; + + if (sky2 is null) + { + moonrot = sky1.moon_rotation; + return true; + } + + moonrot = Quaternion.Slerp(sky1.moon_rotation, sky2.moon_rotation, dayfrac); + return true; + } + /* not needed for wl viewers public bool getWLPositions(float altitude, float dayfrac, out Vector3 sundir) { @@ -718,8 +794,7 @@ public bool getWLPositions(float altitude, float dayfrac, out Vector3 sundir) public void GatherAssets(Dictionary uuids) { - if (Cycle != null) - Cycle.GatherAssets(uuids); + Cycle?.GatherAssets(uuids); } } } diff --git a/OpenSim/Framework/ViewerSky.cs b/OpenSim/Framework/ViewerSky.cs index 7ce7794e955..2fd412ab142 100644 --- a/OpenSim/Framework/ViewerSky.cs +++ b/OpenSim/Framework/ViewerSky.cs @@ -52,12 +52,14 @@ public AbsCoefData(float w, float expt, float exps, float lin, float cons) public OSDMap ToOSD() { - OSDMap map = new OSDMap(); - map["constant_term"] = constant_term; - map["exp_scale"] = exp_scale; - map["exp_term"] = exp_term; - map["linear_term"] = linear_term; - map["width"] = width; + OSDMap map = new() + { + ["constant_term"] = constant_term, + ["exp_scale"] = exp_scale, + ["exp_term"] = exp_term, + ["linear_term"] = linear_term, + ["width"] = width + }; return map; } @@ -92,13 +94,15 @@ public mCoefData(float w, float expt, float exps, float lin, float cons, float a public OSDMap ToOSD() { - OSDMap map = new OSDMap(); - map["anisotropy"] = anisotropy; - map["constant_term"] = constant_term; - map["exp_scale"] = exp_scale; - map["exp_term"] = exp_term; - map["linear_term"] = linear_term; - map["width"] = width; + OSDMap map = new() + { + ["anisotropy"] = anisotropy, + ["constant_term"] = constant_term, + ["exp_scale"] = exp_scale, + ["exp_term"] = exp_term, + ["linear_term"] = linear_term, + ["width"] = width + }; return map; } @@ -113,40 +117,40 @@ public void FromOSD(OSDMap map) } } //AbsCoefData(float w, float expt, float exps, float lin, float cons) - public AbsCoefData abscoefA = new AbsCoefData(25000f, 0, 0, 0, 0); - public AbsCoefData abscoefB = new AbsCoefData(0, 0, 0, -6.6666667e-5f, 1f); - public AbsCoefData rayleigh_config = new AbsCoefData(0, 1, -1.25e-4f, 0, 0); + public AbsCoefData abscoefA = new(25000f, 0, 0, 0, 0); + public AbsCoefData abscoefB = new(0, 0, 0, -6.6666667e-5f, 1f); + public AbsCoefData rayleigh_config = new(0, 1, -1.25e-4f, 0, 0); //mCoefData(float w, float expt, float exps, float lin, float cons, float ani) - public mCoefData mieconf = new mCoefData(0, 1f, -8.333333e-4f, 0, 0, 0.8f); + public mCoefData mieconf = new(0, 1f, -8.333333e-4f, 0, 0, 0.8f); - UUID bloom_id = new UUID("3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef"); - UUID cloud_id = new UUID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); - UUID halo_id = new UUID("12149143-f599-91a7-77ac-b52a3c0f59cd"); - UUID moon_id = new UUID("ec4b9f0b-d008-45c6-96a4-01dd947ac621"); - UUID rainbow_id = new UUID("11b4c57c-56b3-04ed-1f82-2004363882e4"); + UUID bloom_id = new("3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef"); + UUID cloud_id = new("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b"); + UUID halo_id = new("12149143-f599-91a7-77ac-b52a3c0f59cd"); + UUID moon_id = new("ec4b9f0b-d008-45c6-96a4-01dd947ac621"); + UUID rainbow_id = new("11b4c57c-56b3-04ed-1f82-2004363882e4"); UUID sun_id = UUID.Zero; - public Vector3 ambient = new Vector3(1.047f, 1.047f, 1.047f); //? - public Vector3 blue_density = new Vector3(0.2447f, 0.4487f, 0.76f); - public Vector3 blue_horizon = new Vector3(0.4954f, 0.4954f, 0.64f); - public Vector3 cloud_color = new Vector3(0.41f, 0.41f, 0.41f); - public Vector3 cloud_pos_density1 = new Vector3(1, 0.5260f, 1); - public Vector3 cloud_pos_density2 = new Vector3(1, 0.5260f, 0.12f); + public Vector3 ambient = new(1.047f, 1.047f, 1.047f); //? + public Vector3 blue_density = new(0.2447f, 0.4487f, 0.76f); + public Vector3 blue_horizon = new(0.4954f, 0.4954f, 0.64f); + public Vector3 cloud_color = new(0.41f, 0.41f, 0.41f); + public Vector3 cloud_pos_density1 = new(1, 0.5260f, 1); + public Vector3 cloud_pos_density2 = new(1, 0.5260f, 0.12f); public float cloud_scale = 0.42f; - public Vector2 cloud_scroll_rate = new Vector2(0.2f, 0.011f); + public Vector2 cloud_scroll_rate = new(0.2f, 0.011f); public float cloud_shadow = 0.27f; public float density_multiplier = 0.00018f; public float distance_multiplier = 0.8f; public float gamma = 1; - public Vector3 glow = new Vector3(5, 0.0010f, -0.48f); + public Vector3 glow = new(5, 0.0010f, -0.48f); public float haze_density = 0.7f; public float haze_horizon = 0.19f; public float max_y = 1605; public float star_brightness = 0f; //this is a vector3 now, but all viewers expect a vector4, so keeping like this for now - public Vector4 sunlight_color = new Vector4(0.7342f, 0.7815f, 0.9f, 0.3f); + public Vector4 sunlight_color = new(0.7342f, 0.7815f, 0.9f, 0.3f); public string Name = "DefaultSky"; public float cloud_variance = 0; @@ -154,6 +158,8 @@ public void FromOSD(OSDMap map) public float dome_radius = 15000f; public float droplet_radius = 800.0f; public float ice_level = 0f; + + public bool HasRefProbe = false; public float reflectionProbeAmbiance = 0f; public float moisture_level = 0; @@ -161,11 +167,11 @@ public void FromOSD(OSDMap map) public float sky_top_radius = 6420; public float sun_arc_radians = 0.00045f; - public Quaternion sun_rotation = new Quaternion(0, -0.3824995f, 0, 0.9239557f); + public Quaternion sun_rotation = new(0, -0.3824995f, 0, 0.9239557f); public float sun_scale = 1; public float moon_brightness = 0.5f; - public Quaternion moon_rotation = new Quaternion(0, 0.9239557f, 0, 0.3824995f); + public Quaternion moon_rotation = new(0, 0.9239557f, 0, 0.3824995f); public float moon_scale = 1; public float planet_radius = 6360f; @@ -218,24 +224,19 @@ public void FromWLOSD(string name, OSD osd) sunlight_color = map["sunlight_color"]; - reflectionProbeAmbiance = 0f; - ViewerEnvironment.convertFromAngles(this, map["sun_angle"], map["east_angle"]); Name = name; } public OSD ToWLOSD() { - OSDMap map = new OSDMap(); + OSDMap map = new(); - float sun_angle; - float east_angle; - Vector4 lightnorm; - ViewerEnvironment.convertToAngles(this, out sun_angle, out east_angle, out lightnorm); + ViewerEnvironment.convertToAngles(this, out float sun_angle, out float east_angle, out Vector4 lightnorm); map["ambient"] = new Vector4(ambient.X, ambient.Y, ambient.Z, 1); map["blue_density"] = new Vector4(blue_density.X, blue_density.Y, blue_density.Z, 1); map["blue_horizon"] = new Vector4(blue_horizon.X, blue_horizon.Y, blue_horizon.Z, 1); - map["cloud_color"] = new Vector4(cloud_color.X, cloud_color.Y, cloud_color.Z, 1);; + map["cloud_color"] = new Vector4(cloud_color.X, cloud_color.Y, cloud_color.Z, 1); map["cloud_pos_density1"] = new Vector4(cloud_pos_density1.X, cloud_pos_density1.Y, cloud_pos_density1.Z, 1); map["cloud_pos_density2"] = new Vector4(cloud_pos_density2.X, cloud_pos_density2.Y, cloud_pos_density2.Z, 1); map["cloud_scale"] = new Vector4(cloud_scale, 0, 0, 1); @@ -261,87 +262,78 @@ public OSD ToWLOSD() public OSD ToOSD() { - OSDMap map = new OSDMap(64); - - OSDArray abscfg = new OSDArray(2); - abscfg.Add(abscoefA.ToOSD()); - abscfg.Add(abscoefB.ToOSD()); - map["absorption_config"] = abscfg; - - map["bloom_id"] = bloom_id; - map["cloud_color"] = cloud_color; - map["cloud_id"] = cloud_id; - map["cloud_pos_density1"] = cloud_pos_density1; - map["cloud_pos_density2"] = cloud_pos_density2; - map["cloud_scale"] = cloud_scale; - map["cloud_scroll_rate"] = cloud_scroll_rate; - map["cloud_shadow"] = cloud_shadow; - map["cloud_variance"] = cloud_variance; - map["dome_offset"] = dome_offset; - map["dome_radius"] = dome_radius; - map["droplet_radius"] = droplet_radius; - map["gamma"] = gamma; - map["glow"] = glow; - map["halo_id"] = halo_id; - map["ice_level"] = ice_level; - - if (reflectionProbeAmbiance != 0f) + OSDMap map = new(64) + { + ["absorption_config"] = new OSDArray() { abscoefA.ToOSD(), abscoefB.ToOSD() }, + ["bloom_id"] = bloom_id, + ["cloud_color"] = cloud_color, + ["cloud_id"] = cloud_id, + ["cloud_pos_density1"] = cloud_pos_density1, + ["cloud_pos_density2"] = cloud_pos_density2, + ["cloud_scale"] = cloud_scale, + ["cloud_scroll_rate"] = cloud_scroll_rate, + ["cloud_shadow"] = cloud_shadow, + ["cloud_variance"] = cloud_variance, + ["dome_offset"] = dome_offset, + ["dome_radius"] = dome_radius, + ["droplet_radius"] = droplet_radius, + ["gamma"] = gamma, + ["glow"] = glow, + ["halo_id"] = halo_id, + ["ice_level"] = ice_level, + + ["legacy_haze"] = new OSDMap() + { + ["ambient"] = ambient, + ["blue_density"] = blue_density, + ["blue_horizon"] = blue_horizon, + ["density_multiplier"] = density_multiplier, + ["distance_multiplier"] = distance_multiplier, + ["haze_density"] = haze_density, + ["haze_horizon"] = haze_horizon + }, + + ["max_y"] = max_y, + ["moisture_level"] = moisture_level, + ["moon_brightness"] = moon_brightness, + ["moon_id"] = moon_id, + ["moon_rotation"] = moon_rotation, + ["moon_scale"] = moon_scale, + ["planet_radius"] = planet_radius, + ["rainbow_id"] = rainbow_id, + + ["sky_bottom_radius"] = sky_bottom_radius, + ["sky_top_radius"] = sky_top_radius, + ["star_brightness"] = star_brightness, + + ["sun_arc_radians"] = sun_arc_radians, + ["sun_id"] = sun_id, + ["sun_rotation"] = sun_rotation, + ["sun_scale"] = sun_scale, + ["sunlight_color"] = sunlight_color, + + ["mie_config"] = new OSDArray() { mieconf.ToOSD() }, + ["rayleigh_config"] = new OSDArray() { rayleigh_config.ToOSD() }, + + ["type"] = "sky" + }; + + if(HasRefProbe) map["reflection_probe_ambiance"] = reflectionProbeAmbiance; - OSDMap lhaze = new OSDMap(); - lhaze["ambient"] = ambient; - lhaze["blue_density"] = blue_density; - lhaze["blue_horizon"] = blue_horizon; - lhaze["density_multiplier"] = density_multiplier; - lhaze["distance_multiplier"] = distance_multiplier; - lhaze["haze_density"] = haze_density; - lhaze["haze_horizon"] = haze_horizon; - map["legacy_haze"] = lhaze; - - map["max_y"] = max_y; - - OSDArray miecfg = new OSDArray(); - miecfg.Add(mieconf.ToOSD()); - map["mie_config"] = miecfg; - - map["moisture_level"] = moisture_level; - map["moon_brightness"] = moon_brightness; - map["moon_id"] = moon_id; - map["moon_rotation"] = moon_rotation; - map["moon_scale"] = moon_scale; - map["planet_radius"] = planet_radius; - map["rainbow_id"] = rainbow_id; - - OSDArray rayl = new OSDArray(); - rayl.Add(rayleigh_config.ToOSD()); - map["rayleigh_config"] = rayl; - - map["sky_bottom_radius"] = sky_bottom_radius; - map["sky_top_radius"] = sky_top_radius; - map["star_brightness"] = star_brightness; - - map["sun_arc_radians"] = sun_arc_radians; - map["sun_id"] = sun_id; - map["sun_rotation"] = sun_rotation; - map["sun_scale"] = sun_scale; - map["sunlight_color"] = sunlight_color; - - map["type"] = "sky"; return map; } public void FromOSD(string name, OSDMap map) { - OSDArray tmpArray; OSD otmp; - if (map.TryGetValue("absorption_config",out otmp) && otmp is OSDArray) + if (map.TryGetValue("absorption_config", out otmp) && otmp is OSDArray absorptionArray) { - tmpArray = otmp as OSDArray; - if (tmpArray.Count > 0) + if (absorptionArray.Count > 0) { - abscoefA.FromOSD(tmpArray[0] as OSDMap); - if (tmpArray.Count > 1) - abscoefA.FromOSD(tmpArray[1] as OSDMap); + abscoefA.FromOSD(absorptionArray[0] as OSDMap); + if (absorptionArray.Count > 1) + abscoefA.FromOSD(absorptionArray[1] as OSDMap); } } if (map.TryGetValue("bloom_id", out otmp)) @@ -378,11 +370,13 @@ public void FromOSD(string name, OSDMap map) ice_level = otmp; if (map.TryGetValue("reflection_probe_ambiance", out otmp)) + { reflectionProbeAmbiance = otmp; + HasRefProbe = true; + } - if (map.TryGetValue("legacy_haze", out OSD tmp) && tmp is OSDMap) + if (map.TryGetValue("legacy_haze", out OSD tmp) && tmp is OSDMap lHaze) { - OSDMap lHaze = tmp as OSDMap; if (lHaze.TryGetValue("ambient", out otmp)) ambient = otmp; if (lHaze.TryGetValue("blue_density", out otmp)) @@ -402,11 +396,10 @@ public void FromOSD(string name, OSDMap map) if (map.TryGetValue("max_y", out otmp)) max_y = otmp; - if (map.TryGetValue("mie_config", out otmp) && otmp is OSDArray) + if (map.TryGetValue("mie_config", out otmp) && otmp is OSDArray mieArray) { - tmpArray = otmp as OSDArray; - if (tmpArray.Count > 0) - mieconf.FromOSD(tmpArray[0] as OSDMap); + if (mieArray.Count > 0) + mieconf.FromOSD(mieArray[0] as OSDMap); } if (map.TryGetValue("moisture_level", out otmp)) @@ -424,11 +417,10 @@ public void FromOSD(string name, OSDMap map) if (map.TryGetValue("rainbow_id", out otmp)) rainbow_id = otmp; - if (map.TryGetValue("rayleigh_config", out otmp) && otmp is OSDArray) + if (map.TryGetValue("rayleigh_config", out otmp) && otmp is OSDArray rayleighArray) { - tmpArray = otmp as OSDArray; - if (tmpArray.Count > 0) - rayleigh_config.FromOSD(tmpArray[0] as OSDMap); + if (rayleighArray.Count > 0) + rayleigh_config.FromOSD(rayleighArray[0] as OSDMap); } if (map.TryGetValue("sky_bottom_radius", out otmp)) @@ -447,10 +439,9 @@ public void FromOSD(string name, OSDMap map) if (map.TryGetValue("sun_scale", out otmp)) sun_scale = otmp; - if (map.TryGetValue("sunlight_color", out otmp) && otmp is OSDArray) + if (map.TryGetValue("sunlight_color", out otmp) && otmp is OSDArray sunlightArray) { - tmpArray = otmp as OSDArray; - if(tmpArray.Count == 4) + if(sunlightArray.Count == 4) sunlight_color = otmp; else { diff --git a/OpenSim/Framework/ViewerWater.cs b/OpenSim/Framework/ViewerWater.cs index 41383d2a050..e3a95738508 100644 --- a/OpenSim/Framework/ViewerWater.cs +++ b/OpenSim/Framework/ViewerWater.cs @@ -33,20 +33,20 @@ namespace OpenSim.Framework { public class WaterData { - public UUID normalMap = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); - public UUID transpTexture = new UUID("2bfd3884-7e27-69b9-ba3a-3e673f680004"); + public UUID normalMap = new("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); + public UUID transpTexture = new("2bfd3884-7e27-69b9-ba3a-3e673f680004"); public float blurMultiplier = 0.04f; public float fresnelOffset = 0.5f; public float fresnelScale = 0.4f; - public Vector3 normScale = new Vector3(2f, 2f, 2f); + public Vector3 normScale = new(2f, 2f, 2f); public float scaleAbove = 0.03f; public float scaleBelow = 0.2f; public float underWaterFogMod = 0.25f; - public Vector3 waterFogColor = new Vector3(0.0156f, 0.149f, 0.2509f); + public Vector3 waterFogColor = new(0.0156f, 0.149f, 0.2509f); public float waterFogDensity = 10; - public Vector2 wave1Dir = new Vector2(1.05f, -0.42f); - public Vector2 wave2Dir = new Vector2(1.11f, -1.16f); + public Vector2 wave1Dir = new(1.05f, -0.42f); + public Vector2 wave2Dir = new(1.11f, -1.16f); public string Name; public void FromWLOSD(string name, OSD osd) @@ -71,23 +71,22 @@ public void FromWLOSD(string name, OSD osd) public OSDMap ToWLOSD() { - OSDMap map = new OSDMap(); - - map["blurMultiplier"] = blurMultiplier; - map["fresnelOffset"] = fresnelOffset; - map["fresnelScale"] = fresnelScale; - map["normScale"] = normScale; - map["normalMap"] = normalMap; - map["scaleAbove"] = scaleAbove; - map["scaleBelow"] = scaleBelow; - map["underWaterFogMod"] = underWaterFogMod; - map["waterFogColor"] = new Vector4(waterFogColor.X, waterFogColor.Y, waterFogColor.Z, 1); - map["waterFogDensity"] = waterFogDensity; - //map["waterFogDensity"] = (float)Math.Pow(2.0f, waterFogDensity); - map["wave1Dir"] = wave1Dir; - map["wave2Dir"] = wave2Dir; - - return map; + return new OSDMap + { + ["blurMultiplier"] = blurMultiplier, + ["fresnelOffset"] = fresnelOffset, + ["fresnelScale"] = fresnelScale, + ["normScale"] = normScale, + ["normalMap"] = normalMap, + ["scaleAbove"] = scaleAbove, + ["scaleBelow"] = scaleBelow, + ["underWaterFogMod"] = underWaterFogMod, + ["waterFogColor"] = new Vector4(waterFogColor.X, waterFogColor.Y, waterFogColor.Z, 1), + ["waterFogDensity"] = waterFogDensity, + //["waterFogDensity"] = MathF.Pow(2.0f, waterFogDensity), + ["wave1Dir"] = wave1Dir, + ["wave2Dir"] = wave2Dir + }; } public void FromOSD(string name, OSDMap map) @@ -125,24 +124,23 @@ public void FromOSD(string name, OSDMap map) public OSDMap ToOSD() { - OSDMap map = new OSDMap(); - - map["blur_multiplier"] = blurMultiplier; - map["fresnel_offset"] = fresnelOffset; - map["fresnel_scale"] = fresnelScale; - map["normal_scale"] = normScale; - map["normal_map"] = normalMap; - map["scale_above"] = scaleAbove; - map["scale_below"] = scaleBelow; - map["underwater_fog_mod"] = underWaterFogMod; - map["water_fog_color"] = waterFogColor; - map["water_fog_density"] = waterFogDensity; - map["wave1_direction"] = wave1Dir; - map["wave2_direction"] = wave2Dir; - map["transparent_texture"] = transpTexture; - map["type"] ="water"; - - return map; + return new OSDMap + { + ["blur_multiplier"] = blurMultiplier, + ["fresnel_offset"] = fresnelOffset, + ["fresnel_scale"] = fresnelScale, + ["normal_scale"] = normScale, + ["normal_map"] = normalMap, + ["scale_above"] = scaleAbove, + ["scale_below"] = scaleBelow, + ["underwater_fog_mod"] = underWaterFogMod, + ["water_fog_color"] = waterFogColor, + ["water_fog_density"] = waterFogDensity, + ["wave1_direction"] = wave1Dir, + ["wave2_direction"] = wave2Dir, + ["transparent_texture"] = transpTexture, + ["type"] = "water" + }; } public void GatherAssets(Dictionary uuids) diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 2d48c2acb10..1a9d9cc1e51 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -27,7 +27,6 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.IO; @@ -44,8 +43,11 @@ using log4net; using Nwc.XmlRpc; using OpenMetaverse.StructuredData; -using OpenSim.Framework; using OpenSim.Framework.ServiceAuth; +using System.Net.Http; +using System.Security.Authentication; +using System.Runtime.CompilerServices; +using System.Threading; namespace OpenSim.Framework { @@ -58,7 +60,10 @@ public static class WebUtil { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public static ExpiringKey GlobalExpiringBadURLs = new ExpiringKey(30000); + public static SocketsHttpHandler SharedSocketsHttpHandlerNoRedir = null; + public static SocketsHttpHandler SharedSocketsHttpHandler = null; + + public static ExpiringKey GlobalExpiringBadURLs = new(30000); /// /// Control the printing of certain debug messages. /// @@ -102,41 +107,198 @@ public static bool ValidateServerCertificateNoChecks( { sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors; sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; - if (sslPolicyErrors == SslPolicyErrors.None) - return true; - return false; + return sslPolicyErrors == SslPolicyErrors.None; } #region JSONRequest + public static void SetupHTTPClients(bool NoVerifyCertChain, bool NoVerifyCertHostname, IWebProxy proxy, int MaxConnectionsPerServer ) + { + SocketsHttpHandler shh = new() + { + AllowAutoRedirect = false, + AutomaticDecompression = DecompressionMethods.None, + ConnectTimeout = TimeSpan.FromSeconds(120), + PreAuthenticate = false, + UseCookies = false, + MaxConnectionsPerServer = MaxConnectionsPerServer, + PooledConnectionIdleTimeout = TimeSpan.FromSeconds(31), + PooledConnectionLifetime = TimeSpan.FromMinutes(3) + }; + //shh.SslOptions.ClientCertificates = null, + shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + if (NoVerifyCertChain) + { + shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; + if (NoVerifyCertHostname) + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~(SslPolicyErrors.RemoteCertificateChainErrors | SslPolicyErrors.RemoteCertificateNameMismatch); + return errors == SslPolicyErrors.None; + }; + } + else + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~SslPolicyErrors.RemoteCertificateChainErrors; + return errors == SslPolicyErrors.None; + }; + } + } + else + { + shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; + if (NoVerifyCertHostname) + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; + return errors == SslPolicyErrors.None; + }; + } + else + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + return errors == SslPolicyErrors.None; + }; + } + } + + if (proxy is null) + shh.UseProxy = false; + else + { + shh.Proxy = proxy; + shh.UseProxy = true; + } + + SharedSocketsHttpHandlerNoRedir = shh; + + // **************** + + shh = new() + { + AllowAutoRedirect = true, + MaxAutomaticRedirections = 10, + AutomaticDecompression = DecompressionMethods.None, + ConnectTimeout = TimeSpan.FromSeconds(120), + PreAuthenticate = false, + UseCookies = false, + MaxConnectionsPerServer = MaxConnectionsPerServer, + PooledConnectionIdleTimeout = TimeSpan.FromSeconds(31), + PooledConnectionLifetime = TimeSpan.FromMinutes(3) + }; + //shh.SslOptions.ClientCertificates = null, + shh.SslOptions.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; + if (NoVerifyCertChain) + { + shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; + if (NoVerifyCertHostname) + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~(SslPolicyErrors.RemoteCertificateChainErrors | SslPolicyErrors.RemoteCertificateNameMismatch); + return errors == SslPolicyErrors.None; + }; + } + else + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~SslPolicyErrors.RemoteCertificateChainErrors; + return errors == SslPolicyErrors.None; + }; + } + } + else + { + shh.SslOptions.CertificateRevocationCheckMode = X509RevocationMode.NoCheck; + if (NoVerifyCertHostname) + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + errors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; + return errors == SslPolicyErrors.None; + }; + } + else + { + shh.SslOptions.RemoteCertificateValidationCallback = (message, cert, chain, errors) => + { + return errors == SslPolicyErrors.None; + }; + } + } + + if (proxy is null) + shh.UseProxy = false; + else + { + shh.Proxy = proxy; + shh.UseProxy = true; + } + SharedSocketsHttpHandler = shh; + } + + public static HttpClient GetNewGlobalHttpClient(int timeout) + { + var client = new HttpClient(SharedSocketsHttpHandler, false) + { + Timeout = TimeSpan.FromMilliseconds(timeout > 0 ? timeout : 30000), + MaxResponseContentBufferSize = 250 * 1024 * 1024, + }; + client.DefaultRequestHeaders.ExpectContinue = false; + return client; + } + + public static HttpClient GetGlobalNoRedirHttpClient(int timeout) + { + var client = new HttpClient(SharedSocketsHttpHandlerNoRedir, false) + { + Timeout = TimeSpan.FromMilliseconds(timeout > 0 ? timeout : 30000), + MaxResponseContentBufferSize = 250 * 1024 * 1024, + }; + client.DefaultRequestHeaders.ExpectContinue = false; + return client; + } + /// /// PUT JSON-encoded data to a web service that returns LLSD or /// JSON data /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap PutToServiceCompressed(string url, OSDMap data, int timeout) { return ServiceOSDRequest(url, data, "PUT", timeout, true, false); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap PutToService(string url, OSDMap data, int timeout) { return ServiceOSDRequest(url, data, "PUT", timeout, false, false); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap PostToService(string url, OSDMap data, int timeout, bool rpc) { return ServiceOSDRequest(url, data, "POST", timeout, false, rpc); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap PostToServiceCompressed(string url, OSDMap data, int timeout) { return ServiceOSDRequest(url, data, "POST", timeout, true, false); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap GetFromService(string url, int timeout) { return ServiceOSDRequest(url, null, "GET", timeout, false, false); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogOutgoingDetail(Stream outputStream) { LogOutgoingDetail("", outputStream); @@ -144,50 +306,52 @@ public static void LogOutgoingDetail(Stream outputStream) public static void LogOutgoingDetail(string context, Stream outputStream) { - using (Stream stream = Util.Copy(outputStream)) - using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) - { - string output; - - if (DebugLevel == 5) - { - char[] chars = new char[WebUtil.MaxRequestDiagLength + 1]; // +1 so we know to add "..." only if needed - int len = reader.Read(chars, 0, WebUtil.MaxRequestDiagLength + 1); - output = new string(chars, 0, len); - } - else - { - output = reader.ReadToEnd(); - } + using Stream stream = Util.Copy(outputStream); + using StreamReader reader = new(stream, Encoding.UTF8); + string output; - LogOutgoingDetail(context, output); + if (DebugLevel == 5) + { + char[] chars = new char[MaxRequestDiagLength + 1]; // +1 so we know to add "..." only if needed + int len = reader.Read(chars, 0, MaxRequestDiagLength + 1); + output = new string(chars, 0, len); } + else + { + output = reader.ReadToEnd(); + } + + LogOutgoingDetail(context, output); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogOutgoingDetail(string type, int reqnum, string output) { - LogOutgoingDetail(string.Format("{0} {1}: ", type, reqnum), output); + LogOutgoingDetail($"{type} {reqnum}: ", output); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogOutgoingDetail(string context, string output) { if (DebugLevel == 5) { if (output.Length > MaxRequestDiagLength) - output = output.Substring(0, MaxRequestDiagLength) + "..."; + output = output[..MaxRequestDiagLength] + "..."; } - m_log.DebugFormat("[LOGHTTP]: {0}{1}", context, Util.BinaryToASCII(output)); + m_log.DebugFormat($"[LOGHTTP]: {context}{Util.BinaryToASCII(output)}"); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogResponseDetail(int reqnum, Stream inputStream) { - LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), inputStream); + LogOutgoingDetail($"RESPONSE {reqnum}: ", inputStream); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void LogResponseDetail(int reqnum, string input) { - LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input); + LogOutgoingDetail($"RESPONSE {reqnum}: ", input); } public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc, bool keepalive = false) @@ -195,36 +359,22 @@ public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, i int reqnum = RequestNumber++; if (DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} JSON-RPC {1} to {2}", - reqnum, method, url); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} JSON-RPC {method} to {url}"); string errorMessage = "unknown error"; - int tickstart = Util.EnvironmentTickCount(); + int ticks = Util.EnvironmentTickCount(); + int sendlen = 0; int rcvlen = 0; - HttpWebRequest request = null; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - request = (HttpWebRequest)WebRequest.Create(url); - request.Method = method; - request.Timeout = timeout; - request.KeepAlive = keepalive; - request.MaximumAutomaticRedirections = 10; - request.ReadWriteTimeout = timeout / 2; - request.Headers[OSHeaderRequestID] = reqnum.ToString(); - request.AllowWriteStreamBuffering = false; - } - catch (Exception ex) - { - errorMessage = ex.Message; - m_log.Debug("[WEB UTIL]: SvcOSD error creating request " + ex.Message); - return ErrorResponseMap(errorMessage); - } + client = GetNewGlobalHttpClient(timeout); + request = new(new HttpMethod(method), url); - try - { - // If there is some input, write it into the request - if (data != null) + if (data is not null) { byte[] buffer; if (DebugLevel >= 5) @@ -236,72 +386,83 @@ public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, i else buffer = OSDParser.SerializeJsonToBytes(data); - request.ContentType = rpc ? "application/json-rpc" : "application/json"; - - if (compressed) + if (buffer.Length > 0) { - request.Headers["X-Content-Encoding"] = "gzip"; // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding - - using (MemoryStream ms = new MemoryStream()) + if (compressed) { - using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress, true)) + using MemoryStream ms = new(); + using (GZipStream comp = new(ms, CompressionMode.Compress, true)) { comp.Write(buffer, 0, buffer.Length); - } + } buffer = ms.ToArray(); + + request.Headers.TryAddWithoutValidation("X-Content-Encoding", "gzip"); // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding } + + sendlen = buffer.Length; + request.Content = new ByteArrayContent(buffer); + request.Content.Headers.TryAddWithoutValidation("Content-Type", + rpc ? "application/json-rpc" : "application/json"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); } + } - sendlen = buffer.Length; - request.ContentLength = buffer.Length; //Count bytes to send - using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(buffer, 0, buffer.Length); //Send it - buffer = null; + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; + if(keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; } + else + request.Headers.TryAddWithoutValidation("Connection", "close"); + + request.Headers.TryAddWithoutValidation(OSHeaderRequestID, reqnum.ToString()); - using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); + + Stream resStream = responseMessage.Content.ReadAsStream(); + if (resStream is not null) { - using (StreamReader reader = new StreamReader(response.GetResponseStream())) - { - string responseStr = reader.ReadToEnd(); - if (WebUtil.DebugLevel >= 5) - WebUtil.LogResponseDetail(reqnum, responseStr); - rcvlen = responseStr.Length; - return CanonicalizeResults(responseStr); - } + using StreamReader reader = new(resStream); + string responseStr = reader.ReadToEnd(); + if (WebUtil.DebugLevel >= 5) + WebUtil.LogResponseDetail(reqnum, responseStr); + rcvlen = responseStr.Length; + return CanonicalizeResults(responseStr); } } - catch (WebException we) + catch (HttpRequestException e) { - errorMessage = we.Message; - if (we.Status == WebExceptionStatus.ProtocolError) - { - using (HttpWebResponse webResponse = (HttpWebResponse)we.Response) - errorMessage = String.Format("[{0}] {1}", webResponse.StatusCode, webResponse.StatusDescription); - } + int Status = e.StatusCode is null ? 499 : (int)e.StatusCode; + errorMessage = $"[{Status}] {e.Message}"; } catch (Exception ex) { errorMessage = ex.Message; - m_log.Debug("[WEB UTIL]: Exception making request: " + ex.ToString()); + m_log.Debug($"[WEB UTIL]: Exception making request: {errorMessage}"); } finally { - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > LongCallTime) + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > LongCallTime) { - m_log.InfoFormat( - "[WEB UTIL]: SvcOSD {0} {1} {2} took {3}ms, {4}/{5}bytes", - reqnum, method, url, tickdiff, sendlen, rcvlen ); + m_log.Info($"[WEB UTIL]: SvcOSD {reqnum} {method} {url} took {ticks}ms, {sendlen}/{rcvlen}bytes"); } else if (DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); } } - m_log.DebugFormat("[LOGHTTP]: JSON request {0} {1} to {2} FAILED: {3}", reqnum, method, url, errorMessage); + m_log.Debug($"[LOGHTTP]: request {reqnum} {method} to {url} FAILED: {errorMessage}"); return ErrorResponseMap(errorMessage); } @@ -316,13 +477,14 @@ public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, i /// private static OSDMap CanonicalizeResults(string response) { - OSDMap result = new OSDMap(); - - // Default values - result["Success"] = OSD.FromBoolean(true); - result["success"] = OSD.FromBoolean(true); - result["_RawResult"] = OSD.FromString(response); - result["_Result"] = new OSDMap(); + OSDMap result = new() + { + // Default values + ["Success"] = OSD.FromBoolean(true), + ["success"] = OSD.FromBoolean(true), + ["_RawResult"] = OSD.FromString(response), + ["_Result"] = new OSDMap() + }; if (response.Equals("true", StringComparison.OrdinalIgnoreCase)) return result; @@ -346,7 +508,7 @@ private static OSDMap CanonicalizeResults(string response) catch { // don't need to treat this as an error... we're just guessing anyway -// m_log.DebugFormat("[WEB UTIL] couldn't decode <{0}>: {1}",response,e.Message); + //m_log.DebugFormat("[WEB UTIL] couldn't decode <{0}>: {1}",response,e.Message); } return result; @@ -360,6 +522,7 @@ private static OSDMap CanonicalizeResults(string response) /// POST URL-encoded form data to a web service that returns LLSD or /// JSON data /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static OSDMap PostToService(string url, NameValueCollection data) { return ServiceFormRequest(url,data, 30000); @@ -368,37 +531,40 @@ public static OSDMap PostToService(string url, NameValueCollection data) public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) { int reqnum = RequestNumber++; - string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; + string method = (data is not null && data["RequestMethod"] is not null) ? data["RequestMethod"] : "unknown"; if (DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} ServiceForm '{1}' to {2}", - reqnum, method, url); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} ServiceForm '{method}' to {url}"); string errorMessage = "unknown error"; - int tickstart = Util.EnvironmentTickCount(); + int ticks = Util.EnvironmentTickCount(); int sendlen = 0; int rcvlen = 0; - HttpWebRequest request = null; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - request = (HttpWebRequest)WebRequest.Create(url); - request.Method = "POST"; - request.Timeout = timeout; - request.KeepAlive = false; - request.MaximumAutomaticRedirections = 10; - request.ReadWriteTimeout = timeout / 2; - request.Headers[OSHeaderRequestID] = reqnum.ToString(); - request.AllowWriteStreamBuffering = false; - } - catch (Exception ex) - { - return ErrorResponseMap(ex.Message); - } + client = GetNewGlobalHttpClient(timeout); - try - { - if (data != null) + request = new(HttpMethod.Post, url); + + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; + + //if (keepalive) + //{ + // request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + // request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + // request.Headers.ConnectionClose = false; + //} + //else + request.Headers.TryAddWithoutValidation("Connection", "close"); + + request.Headers.TryAddWithoutValidation(OSHeaderRequestID, reqnum.ToString()); + + if (data is not null) { string queryString = BuildQueryString(data); @@ -408,37 +574,38 @@ public static OSDMap ServiceFormRequest(string url, NameValueCollection data, in byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); queryString = null; - request.ContentLength = buffer.Length; sendlen = buffer.Length; - request.ContentType = "application/x-www-form-urlencoded"; - using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(buffer, 0, buffer.Length); - buffer = null; - } - using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) + request.Content = new ByteArrayContent(buffer); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); buffer = null; + } + else { - using (StreamReader reader = new StreamReader(response.GetResponseStream())) - { - string responseStr = reader.ReadToEnd(); - rcvlen = responseStr.Length; - if (DebugLevel >= 5) - LogResponseDetail(reqnum, responseStr); - OSD responseOSD = OSDParser.Deserialize(responseStr); - - if (responseOSD.Type == OSDType.Map) - return (OSDMap)responseOSD; - } + request.Content = new ByteArrayContent(Array.Empty()); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", "0"); } + + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); + + using StreamReader reader = new(responseMessage.Content.ReadAsStream()); + string responseStr = reader.ReadToEnd(); + rcvlen = responseStr.Length; + if (DebugLevel >= 5) + LogResponseDetail(reqnum, responseStr); + OSD responseOSD = OSDParser.Deserialize(responseStr); + + if (responseOSD.Type == OSDType.Map) + return (OSDMap)responseOSD; } - catch (WebException we) + catch (HttpRequestException we) { - errorMessage = we.Message; - if (we.Status == WebExceptionStatus.ProtocolError) - { - using (HttpWebResponse webResponse = (HttpWebResponse)we.Response) - errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription); - } + if (we.StatusCode is HttpStatusCode status) + errorMessage = $"[{status}] {we.Message}"; + else + errorMessage = we.Message; } catch (Exception ex) { @@ -446,21 +613,23 @@ public static OSDMap ServiceFormRequest(string url, NameValueCollection data, in } finally { - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > LongCallTime) + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > LongCallTime) { - m_log.InfoFormat( - "[LOGHTTP]: Slow ServiceForm request {0} '{1}' to {2} took {3}ms, {4}/{5}bytes", - reqnum, method, url, tickdiff, sendlen, rcvlen); + m_log.Info( + $"[LOGHTTP]: Slow ServiceForm request {reqnum} '{method}' to {url} took {ticks}ms, {sendlen}/{rcvlen}bytes"); } else if (DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); } } - m_log.WarnFormat("[LOGHTTP]: ServiceForm request {0} '{1}' to {2} failed: {3}", reqnum, method, url, errorMessage); + m_log.Warn($"[LOGHTTP]: ServiceForm request {reqnum} '{method}' to {url} failed: {errorMessage}"); return ErrorResponseMap(errorMessage); } @@ -471,9 +640,11 @@ public static OSDMap ServiceFormRequest(string url, NameValueCollection data, in /// private static OSDMap ErrorResponseMap(string msg) { - OSDMap result = new OSDMap(); - result["Success"] = "False"; - result["Message"] = OSD.FromString("Service request failed: " + msg); + OSDMap result = new() + { + ["Success"] = "False", + ["Message"] = OSD.FromString("Service request failed: " + msg) + }; return result; } @@ -497,10 +668,10 @@ public static Uri Combine(this Uri uri, string fragment) string fragment1 = uri.Fragment; string fragment2 = fragment; - if (!fragment1.EndsWith("/")) - fragment1 = fragment1 + '/'; - if (fragment2.StartsWith("/")) - fragment2 = fragment2.Substring(1); + if (!fragment1.EndsWith('/')) + fragment1 += '/'; + if (fragment2.StartsWith('/')) + fragment2 = fragment2[1..]; return new Uri(uri, fragment1 + fragment2); } @@ -522,10 +693,10 @@ public static Uri Combine(this Uri uri, Uri fragment) string fragment1 = uri.Fragment; string fragment2 = fragment.ToString(); - if (!fragment1.EndsWith("/")) - fragment1 = fragment1 + '/'; - if (fragment2.StartsWith("/")) - fragment2 = fragment2.Substring(1); + if (!fragment1.EndsWith('/')) + fragment1 += '/'; + if (fragment2.StartsWith('/')) + fragment2 = fragment2[1..]; return new Uri(uri, fragment1 + fragment2); } @@ -541,18 +712,18 @@ public static Uri Combine(this Uri uri, Uri fragment) /// appended public static string AppendQuery(this Uri uri, string query) { - if (String.IsNullOrEmpty(query)) + if (string.IsNullOrEmpty(query)) return uri.ToString(); if (query[0] == '?' || query[0] == '&') - query = query.Substring(1); + query = query[1..]; string uriStr = uri.ToString(); - if (uriStr.Contains("?")) - return uriStr + '&' + query; + if (uriStr.Contains('?')) + return $"{uriStr}&{query}"; else - return uriStr + '?' + query; + return $"{uriStr}?{query}"; } #endregion Uri @@ -570,19 +741,19 @@ public static string BuildQueryString(NameValueCollection parameters) if (parameters.Count == 0) return string.Empty; - StringBuilder sb = new StringBuilder(4096); + StringBuilder sb = new(4096); foreach (string key in parameters.Keys) { string[] values = parameters.GetValues(key); - if (values != null) + if (values is not null) { foreach (string value in values) { sb.Append(key); - sb.Append("="); + sb.Append('='); if(!string.IsNullOrWhiteSpace(value)) sb.Append(HttpUtility.UrlEncode(value)); - sb.Append("&"); + sb.Append('&'); } } } @@ -602,7 +773,7 @@ public static string BuildQueryString(NameValueCollection parameters) public static string GetOne(this NameValueCollection collection, string key) { string[] values = collection.GetValues(key); - if (values != null && values.Length > 0) + if (values is not null && values.Length > 0) return values[0]; return null; @@ -659,14 +830,13 @@ public int Compare(Object x, Object y) return qy.CompareTo(qx); // descending order } - private float GetQ(Object o) + private static float GetQ(Object o) { // Example: image/png;q=0.9 - float qvalue = 1F; - if (o is String) + float qvalue = 1f; + if (o is String mime) { - string mime = (string)o; string[] parts = mime.Split(';'); if (parts.Length > 1) { @@ -692,22 +862,29 @@ private float GetQ(Object o) public static string[] GetPreferredImageTypes(string accept) { if (string.IsNullOrEmpty(accept)) - return new string[0]; + return Array.Empty(); - string[] types = accept.Split(new char[] { ',' }); + string[] types = accept.Split(Util.SplitCommaArray); if (types.Length > 0) { - List list = new List(types); - list.RemoveAll(delegate(string s) { return !s.ToLower().StartsWith("image"); }); - ArrayList tlist = new ArrayList(list); + ArrayList tlist = new(); + foreach(string s in types.AsSpan()) + { + if(s.StartsWith("image", StringComparison.InvariantCultureIgnoreCase)) + tlist.Add(s); + } + if(tlist.Count == 0) + return Array.Empty(); + tlist.Sort(new QBasedComparer()); string[] result = new string[tlist.Count]; + for (int i = 0; i < tlist.Count; i++) { string mime = (string)tlist[i]; - string[] parts = mime.Split(new char[] { ';' }); - string[] pair = parts[0].Split(new char[] { '/' }); + string[] parts = mime.Split(Util.SplitSemicolonArray); + string[] pair = parts[0].Split(Util.SplitSlashArray); if (pair.Length == 2) result[i] = pair[1].ToLower(); else // oops, we don't know what this is... @@ -717,7 +894,7 @@ public static string[] GetPreferredImageTypes(string accept) return result; } - return new string[0]; + return Array.Empty(); } } @@ -738,12 +915,14 @@ public static class AsynchronousRestObjectRequester /// network issue while posting the request. You'll want to make /// sure you deal with this as they're not uncommon // + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MakeRequest(string verb, string requestUrl, TRequest obj, Action action) { - MakeRequest(verb, requestUrl, obj, action, 0); + MakeRequest(verb, requestUrl, obj, action, 0, null); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void MakeRequest(string verb, string requestUrl, TRequest obj, Action action, int maxConnections) @@ -758,7 +937,7 @@ public static void MakeRequest(string verb, /// /// /// - /// Request timeout in seconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// Request timeout in seconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default timeout is used (100 seconds) /// /// /// @@ -772,8 +951,7 @@ public static void MakeRequest(string verb, int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} AsynchronousRequestObject {1} to {2}", - reqnum, verb, requestUrl); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} AsynchronousRequestObject {verb} to {requestUrl}"); int tickstart = Util.EnvironmentTickCount(); int tickdata = 0; @@ -791,7 +969,7 @@ public static void MakeRequest(string verb, if (maxConnections > 0 && request.ServicePoint.ConnectionLimit < maxConnections) request.ServicePoint.ConnectionLimit = maxConnections; - TResponse deserial = default(TResponse); + TResponse deserial = default; request.Method = verb; @@ -802,12 +980,14 @@ public static void MakeRequest(string verb, { request.ContentType = "text/xml"; - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; - using (MemoryStream buffer = new MemoryStream()) + XmlWriterSettings settings = new() + { + Encoding = Encoding.UTF8 + }; + using (MemoryStream buffer = new()) using (XmlWriter writer = XmlWriter.Create(buffer, settings)) { - XmlSerializer serializer = new XmlSerializer(type); + XmlSerializer serializer = new(type); serializer.Serialize(writer, obj); writer.Flush(); data = buffer.ToArray(); @@ -833,11 +1013,9 @@ public static void MakeRequest(string verb, { try { - using (Stream respStream = response.GetResponseStream()) - { - deserial = XMLResponseHelper.LogAndDeserialize( - reqnum, respStream, response.ContentLength); - } + using Stream respStream = response.GetResponseStream(); + deserial = XMLResponseHelper.LogAndDeserialize( + reqnum, respStream, response.ContentLength); } catch (System.InvalidOperationException) { @@ -857,15 +1035,20 @@ public static void MakeRequest(string verb, { // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't // documented in MSDN - using (WebResponse response = request.EndGetResponse(res2)) + using WebResponse response = request.EndGetResponse(res2); + try + { + using Stream respStream = response.GetResponseStream(); + deserial = XMLResponseHelper.LogAndDeserialize( + reqnum, respStream, response.ContentLength); + } + catch (System.InvalidOperationException) { try { - using (Stream respStream = response.GetResponseStream()) - { - deserial = XMLResponseHelper.LogAndDeserialize( - reqnum, respStream, response.ContentLength); - } + using Stream respStream = response.GetResponseStream(); + deserial = XMLResponseHelper.LogAndDeserialize( + reqnum, respStream, response.ContentLength); } catch (System.InvalidOperationException) { @@ -876,36 +1059,30 @@ public static void MakeRequest(string verb, { if (e.Status == WebExceptionStatus.ProtocolError) { - if (e.Response is HttpWebResponse) + if (e.Response is HttpWebResponse httpResponse) { - using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response) + if (httpResponse.StatusCode != HttpStatusCode.NotFound) { - if (httpResponse.StatusCode != HttpStatusCode.NotFound) - { - // We don't appear to be handling any other status codes, so log these feailures to that - // people don't spend unnecessary hours hunting phantom bugs. - m_log.DebugFormat( - "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", - verb, requestUrl, httpResponse.StatusCode); - } + // We don't appear to be handling any other status codes, so log these feailures to that + // people don't spend unnecessary hours hunting phantom bugs. + m_log.Debug( + $"[ASYNC REQUEST]: Request {verb} {requestUrl} failed with unexpected status code {httpResponse.StatusCode}"); } + httpResponse.Dispose(); } } else { - m_log.ErrorFormat( - "[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", - verb, requestUrl, e.Status, e.Message); + m_log.Error( + $"[ASYNC REQUEST]: Request {verb} {requestUrl} failed with status {e.Status} and message {e.Message}"); } } catch (Exception e) { - m_log.ErrorFormat( - "[ASYNC REQUEST]: Request {0} {1} failed with exception {2}{3}", - verb, requestUrl, e.Message, e.StackTrace); + m_log.Error($"[ASYNC REQUEST]: Request {verb} {requestUrl} failed with exception {e.Message}"); } - // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); + //m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); try { @@ -913,9 +1090,7 @@ public static void MakeRequest(string verb, } catch (Exception e) { - m_log.ErrorFormat( - "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}{3}", - verb, requestUrl, e.Message, e.StackTrace); + m_log.ErrorFormat($"[ASYNC REQUEST]: Request {verb} {requestUrl} callback failed with exception {e.Message}"); } }, null); @@ -940,9 +1115,7 @@ public static void MakeRequest(string verb, } else if (WebUtil.DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", - - reqnum, tickdiff, tickdata); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {tickdiff}ms, {tickdata}ms writing"); } } catch { } @@ -956,7 +1129,7 @@ public static class SynchronousRestFormsRequester /// /// Perform a synchronous REST request. /// - /// + /// /// /// /// @@ -964,91 +1137,86 @@ public static class SynchronousRestFormsRequester /// /// Thrown if we encounter a network issue while posting /// the request. You'll want to make sure you deal with this as they're not uncommon - public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs = -1, + public static string MakeRequest(string method, string requestUrl, string obj, int timeoutsecs = -1, IServiceAuth auth = null, bool keepalive = true) { int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestForms {1} to {2}", - reqnum, verb, requestUrl); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} SynchronousRestForms {method} to {requestUrl}"); - int tickstart = Util.EnvironmentTickCount(); - - HttpWebRequest request = null; + int ticks = Util.EnvironmentTickCount(); + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; + string respstring = String.Empty; + int sendlen = 0; + int rcvlen = 0; try { - request = (HttpWebRequest)WebRequest.Create(requestUrl); - request.Method = verb; - if (timeoutsecs > 0) - request.Timeout = timeoutsecs * 1000; - if(!keepalive) - request.KeepAlive = false; - if (auth != null) - auth.AddAuthorization(request.Headers); - - request.AllowWriteStreamBuffering = false; - request.ContentType = "application/x-www-form-urlencoded"; - } - catch (Exception e) - { - m_log.InfoFormat("[FORMS]: Error creating {0} request to : {1}. Request: {2}", verb, requestUrl, e.Message); - throw; - } + client = WebUtil.GetNewGlobalHttpClient(timeoutsecs * 1000); - int sendlen = 0; - if (obj.Length > 0 && (verb == "POST") || (verb == "PUT")) - { - byte[] data = Util.UTF8NBGetbytes(obj); - sendlen = data.Length; - request.ContentLength = sendlen; + request = new(new HttpMethod(method), requestUrl); - if (WebUtil.DebugLevel >= 5) - WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); + auth?.AddAuthorization(request.Headers); - try + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; if (timeoutsecs > 0) + + if (keepalive) { - using(Stream requestStream = request.GetRequestStream()) - requestStream.Write(data, 0, sendlen); - data = null; + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; } - catch (Exception e) + else + request.Headers.TryAddWithoutValidation("Connection", "close"); + + if (obj.Length > 0 && + (method.Equals("POST", StringComparison.OrdinalIgnoreCase) || + method.Equals("PUT", StringComparison.OrdinalIgnoreCase))) { - m_log.InfoFormat("[FORMS]: Error sending {0} request to: {1}. {2}", verb,requestUrl, e.Message); - throw; + byte[] data = Util.UTF8NBGetbytes(obj); + sendlen = data.Length; + + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); + + request.Content = new ByteArrayContent(data); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); } - } - int rcvlen = 0; - string respstring = String.Empty; - try - { - using (WebResponse resp = request.GetResponse()) + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); + + if ((responseMessage.Content.Headers.ContentLength is long contentLength) && contentLength != 0) { - if (resp.ContentLength != 0) - { - using (StreamReader reader = new StreamReader(resp.GetResponseStream())) - respstring = reader.ReadToEnd(); - rcvlen = respstring.Length; - } + using StreamReader reader = new(responseMessage.Content.ReadAsStream()); + respstring = reader.ReadToEnd(); + rcvlen = respstring.Length; } } catch (Exception e) { - m_log.InfoFormat("[FORMS]: Error receiving response from {0}: {1}.", requestUrl, e.Message); + m_log.Info($"[FORMS]: Error receiving response from {requestUrl}: {e.Message}"); throw; } + finally + { + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + } - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > WebUtil.LongCallTime) + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > WebUtil.LongCallTime) { - m_log.InfoFormat("[FORMS]: request {0} {1} {2} took {3}ms, {4}/{5}bytes", - reqnum, verb, requestUrl, tickdiff, sendlen, rcvlen); + m_log.Info($"[FORMS]: request {reqnum} {method} {requestUrl} took {ticks}ms, {sendlen}/{rcvlen}bytes"); } else if (WebUtil.DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); if (WebUtil.DebugLevel >= 5) WebUtil.LogResponseDetail(reqnum, respstring); } @@ -1056,7 +1224,7 @@ public static string MakeRequest(string verb, string requestUrl, string obj, int return respstring; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth) { return MakeRequest(verb, requestUrl, obj, -1, auth); @@ -1068,80 +1236,71 @@ public static string MakePostRequest(string requestUrl, string obj, int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SynchronousRestForms POST to {1}", - reqnum, requestUrl); - - int tickstart = Util.EnvironmentTickCount(); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} SynchronousRestForms POST to {requestUrl}"); - HttpWebRequest request = null; + int ticks = Util.EnvironmentTickCount(); + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; + string respstring = String.Empty; + int sendlen = 0; + int rcvlen = 0; try { - request = (HttpWebRequest)WebRequest.Create(requestUrl); - request.Method = "POST"; - if (timeoutsecs > 0) - request.Timeout = timeoutsecs * 1000; - if (!keepalive) - request.KeepAlive = false; - if (auth != null) - auth.AddAuthorization(request.Headers); - - request.AllowWriteStreamBuffering = false; - request.ContentType = "application/x-www-form-urlencoded"; - } - catch (Exception e) - { - m_log.InfoFormat("[FORMS]: Error creating POST request to {0}: {1}", requestUrl, e.Message); - throw; - } + client = WebUtil.GetNewGlobalHttpClient(timeoutsecs * 1000); + request = new(HttpMethod.Post, requestUrl); - byte[] data = Util.UTF8NBGetbytes(obj); - int sendlen = data.Length; - request.ContentLength = sendlen; + auth?.AddAuthorization(request.Headers); - if (WebUtil.DebugLevel >= 5) - WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; - try - { - using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(data, 0, sendlen); - data = null; - } - catch (Exception e) - { - m_log.InfoFormat("[FORMS]: Error sending POST request to {0}: {1}", requestUrl, e.Message); - throw; - } + if (keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; + } + else + request.Headers.TryAddWithoutValidation("Connection", "close"); - string respstring = String.Empty; - int rcvlen = 0; - try - { - using (WebResponse resp = request.GetResponse()) + byte[] data = Util.UTF8NBGetbytes(obj); + sendlen = data.Length; + request.Content = new ByteArrayContent(data); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); + + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); + + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + + if ((responseMessage.Content.Headers.ContentLength is long contentLength) && contentLength != 0) { - if (resp.ContentLength != 0) - { - using (StreamReader reader = new StreamReader(resp.GetResponseStream())) - respstring = reader.ReadToEnd(); - } + using StreamReader reader = new(responseMessage.Content.ReadAsStream()); + respstring = reader.ReadToEnd(); } } catch (Exception e) { - m_log.InfoFormat("[FORMS]: Error receiving response from {0}: {1}", requestUrl, e.Message); + m_log.Info($"[FORMS]: Error receiving response from {requestUrl}: {e.Message}"); throw; } + finally + { + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + } - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > WebUtil.LongCallTime) + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > WebUtil.LongCallTime) { - m_log.InfoFormat("[FORMS]: request {0} POST {1} took {2}ms {3}/{4}bytes", - reqnum, requestUrl, tickdiff, sendlen, rcvlen); + m_log.Info($"[FORMS]: request {reqnum} POST {requestUrl} took {ticks}ms {sendlen}/{rcvlen}bytes"); } else if (WebUtil.DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); if (WebUtil.DebugLevel >= 5) WebUtil.LogResponseDetail(reqnum, respstring); } @@ -1163,11 +1322,13 @@ public class SynchronousRestObjectRequester /// /// The response. If there was an internal exception, then the default(TResponse) is returned. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj) { return MakeRequest(verb, requestUrl, obj, 0, null); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, IServiceAuth auth) { return MakeRequest(verb, requestUrl, obj, 0, auth); @@ -1179,12 +1340,13 @@ public static TResponse MakeRequest(string verb, string req /// /// /// - /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default timeout is used (100 seconds) /// /// /// The response. If there was an internal exception or the request timed out, /// then the default(TResponse) is returned. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout) { return MakeRequest(verb, requestUrl, obj, pTimeout, null); @@ -1193,151 +1355,131 @@ public static TResponse MakeRequest(string verb, string req /// /// Perform a synchronous something request. /// - /// + /// /// /// /// - /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default timeout is used (100 seconds) /// /// /// The response. If there was an internal exception or the request timed out, /// then the default(TResponse) is returned. /// - public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, IServiceAuth auth) + public static TResponse MakeRequest(string method, string requestUrl, TRequest obj, int pTimeout, IServiceAuth auth) { int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SRestObjReq {1} {2}", - reqnum, verb, requestUrl); - - int tickstart = Util.EnvironmentTickCount(); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} SRestObjReq {method} {requestUrl}"); - TResponse deserial = default(TResponse); + int ticks = Util.EnvironmentTickCount(); + TResponse deserial = default; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; - HttpWebRequest request = null; try { - request = (HttpWebRequest)WebRequest.Create(requestUrl); + client = WebUtil.GetNewGlobalHttpClient(pTimeout); - if (auth != null) - auth.AddAuthorization(request.Headers); + request = new(new HttpMethod(method), requestUrl); - if (pTimeout != 0) - request.Timeout = pTimeout; + auth?.AddAuthorization(request.Headers); - request.Method = verb; - } - catch (Exception e) - { - m_log.DebugFormat("[SRestObjReq]: Exception in creating request {0} {1}: {2}{3}", - verb, requestUrl, e.Message, e.StackTrace); - return deserial; - } + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; - try - { - if ((verb == "POST") || (verb == "PUT")) + //if (keepalive) { - request.ContentType = "text/xml"; + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; + } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); + if (method.Equals("POST",StringComparison.OrdinalIgnoreCase) || method.Equals("PUT", StringComparison.OrdinalIgnoreCase)) + { byte[] data; - XmlWriterSettings settings = new XmlWriterSettings() { Encoding = Util.UTF8 }; - using (MemoryStream ms = new MemoryStream()) + XmlWriterSettings settings = new() { Encoding = Util.UTF8 }; + using (MemoryStream ms = new()) using (XmlWriter writer = XmlWriter.Create(ms, settings)) { - XmlSerializer serializer = new XmlSerializer(typeof(TRequest)); + XmlSerializer serializer = new(typeof(TRequest)); serializer.Serialize(writer, obj); writer.Flush(); data = ms.ToArray(); } int sendlen = data.Length; - request.ContentLength = sendlen; - if (WebUtil.DebugLevel >= 5) WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); - using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(data, 0, sendlen); - data = null; + request.Content = new ByteArrayContent(data); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "text/xml"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); } - } - catch (Exception e) - { - m_log.DebugFormat( - "[SRestObjReq]: Exception in making request {0} {1}: {2}{3}", - verb, requestUrl, e.Message, e.StackTrace); - return deserial; - } + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); - int rcvlen = 0; - try - { - using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) + int rcvlen = 0; + if ((responseMessage.Content.Headers.ContentLength is long contentLength) && contentLength != 0) { - if (resp.ContentLength != 0) - { - rcvlen = (int)resp.ContentLength; - using (Stream respStream = resp.GetResponseStream()) - { - deserial = XMLResponseHelper.LogAndDeserialize( - reqnum, respStream, resp.ContentLength); - } - } - else - { - m_log.DebugFormat("[SRestObjReq]: Oops! no content found in response stream from {0} {1}", - verb, requestUrl); - } + rcvlen = (int)contentLength; + using Stream respStream = responseMessage.Content.ReadAsStream(); + deserial = XMLResponseHelper.LogAndDeserialize( + reqnum, respStream, contentLength); + } + else + { + m_log.Debug($"[SRestObjReq]: Oops! no content found in response stream from {method} {requestUrl}"); + } + + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > WebUtil.LongCallTime) + { + m_log.Info($"[LOGHTTP]: Slow SRestObjReq {reqnum} {method} {requestUrl} took {ticks}ms, {rcvlen}bytes"); + } + else if (WebUtil.DebugLevel >= 4) + { + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); } } - catch (WebException e) + catch (HttpRequestException e) { - using (HttpWebResponse hwr = (HttpWebResponse)e.Response) + if (e.StatusCode is HttpStatusCode status) { - if (hwr != null) + if (status == HttpStatusCode.Unauthorized) { - if (hwr.StatusCode == HttpStatusCode.Unauthorized) - { - m_log.ErrorFormat("[SRestObjReq]: {0} requires authentication", - requestUrl); - } - else if (hwr.StatusCode != HttpStatusCode.NotFound) - { - m_log.WarnFormat("[SRestObjReq]: {0} returned error: {1}", - requestUrl, hwr.StatusCode); - } + m_log.Error($"[SRestObjReq]: GET {requestUrl} requires authentication"); + } + else if (status != HttpStatusCode.NotFound) + { + m_log.Warn($"[SRestObjReq]: GET {requestUrl} returned error: {status}"); } - else - m_log.ErrorFormat( - "[SRestObjReq]: WebException for {0} {1} {2} {3}", - verb, requestUrl, typeof(TResponse).ToString(), e.Message); } + else + m_log.ErrorFormat( + "[SRestObjReq]: WebException for {0} {1} {2} {3}", + method, requestUrl, typeof(TResponse).ToString(), e.Message); } catch (System.InvalidOperationException) { // This is what happens when there is invalid XML - m_log.DebugFormat("[SRestObjReq]: Invalid XML from {0} {1} {2}", - verb, requestUrl, typeof(TResponse).ToString()); + m_log.Debug($"[SRestObjReq]: Invalid XML from {method} {requestUrl} {typeof(TResponse)}"); } catch (Exception e) { - m_log.DebugFormat("[SRestObjReq]: Exception on response from {0} {1}: {2}", - verb, requestUrl, e.Message); - } - - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > WebUtil.LongCallTime) - { - m_log.InfoFormat("[LOGHTTP]: Slow SRestObjReq {0} {1} {2} took {3}ms, {4}bytes", - reqnum, verb, requestUrl, tickdiff, rcvlen); + m_log.Debug($"[SRestObjReq]: Exception on response from {method} {requestUrl}: {e.Message}"); } - else if (WebUtil.DebugLevel >= 4) + finally { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", reqnum, tickdiff); + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); } + return deserial; } @@ -1346,98 +1488,88 @@ public static TResponse MakeGetRequest(string requestUrl, int pTimeou int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} SRestObjReq GET {1}", reqnum, requestUrl); - int tickstart = Util.EnvironmentTickCount(); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} SRestObjReq GET {requestUrl}"); - TResponse deserial = default(TResponse); - HttpWebRequest request = null; + int ticks = Util.EnvironmentTickCount(); + TResponse deserial = default; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - request = (HttpWebRequest)WebRequest.Create(requestUrl); + client = WebUtil.GetNewGlobalHttpClient(pTimeout); + request = new(HttpMethod.Get, requestUrl); - if (auth != null) - auth.AddAuthorization(request.Headers); + auth?.AddAuthorization(request.Headers); - request.AllowWriteStreamBuffering = false; + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; - if (pTimeout != 0) - request.Timeout = pTimeout; + //if (keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; + } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); - request.Method = "GET"; - } - catch (Exception e) - { - m_log.DebugFormat("[SRestObjReq]: Exception in creating GET request {0}: {1}{2}", - requestUrl, e.Message, e.StackTrace); - return deserial; - } + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); - int rcvlen = 0; - try - { - using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) + int rcvlen = 0; + if ((responseMessage.Content.Headers.ContentLength is long contentLength) && contentLength != 0) { - if (resp.ContentLength != 0) - { - rcvlen = (int)resp.ContentLength; - using (Stream respStream = resp.GetResponseStream()) - { - deserial = XMLResponseHelper.LogAndDeserialize( - reqnum, respStream, resp.ContentLength); - } - } - else - { - m_log.DebugFormat("[SRestObjReq]: Oops! no content found in response stream from GET {0}", - requestUrl); - } + rcvlen = (int)contentLength; + using Stream respStream = responseMessage.Content.ReadAsStream(); + deserial = XMLResponseHelper.LogAndDeserialize( + reqnum, respStream, contentLength); + } + else + { + m_log.Debug($"[SRestObjReq]: Oops! no content found in response stream from GET {requestUrl}"); + } + + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > WebUtil.LongCallTime) + { + m_log.Info($"[LOGHTTP]: Slow SRestObjReq GET {reqnum} {requestUrl} took {ticks}ms, {rcvlen}bytes"); + } + else if (WebUtil.DebugLevel >= 4) + { + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {ticks}ms"); } } - catch (WebException e) + catch (HttpRequestException e) { - using (HttpWebResponse hwr = (HttpWebResponse)e.Response) + if(e.StatusCode is HttpStatusCode status) { - if (hwr != null) + if (status == HttpStatusCode.Unauthorized) { - if (hwr.StatusCode == HttpStatusCode.Unauthorized) - { - m_log.ErrorFormat("[SRestObjReq]: GET {0} requires authentication", - requestUrl); - } - else if (hwr.StatusCode != HttpStatusCode.NotFound) - { - m_log.WarnFormat("[SRestObjReq]: GET {0} returned error: {1}", - requestUrl, hwr.StatusCode); - } + m_log.Error($"[SRestObjReq]: GET {requestUrl} requires authentication"); + } + else if (status != HttpStatusCode.NotFound) + { + m_log.Warn($"[SRestObjReq]: GET {requestUrl} returned error: {status}"); } - else - m_log.ErrorFormat( - "[SRestObjReq]: WebException for GET {0} {1} {2}", - requestUrl, typeof(TResponse).ToString(), e.Message); } + else + m_log.Error($"[SRestObjReq]: WebException for GET {requestUrl} {typeof(TResponse)} {e.Message}"); } catch (System.InvalidOperationException) { // This is what happens when there is invalid XML - m_log.DebugFormat("[SRestObjReq]: Invalid XML from GET {0} {1}", - requestUrl, typeof(TResponse).ToString()); + m_log.Debug($"[SRestObjReq]: Invalid XML from GET {requestUrl} {typeof(TResponse)}"); } catch (Exception e) { - m_log.DebugFormat("[SRestObjReq]: Exception on response from GET {0}: {1}", - requestUrl, e.Message); - } - - int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - if (tickdiff > WebUtil.LongCallTime) - { - m_log.InfoFormat("[LOGHTTP]: Slow SRestObjReq GET {0} {1} took {2}ms, {3}bytes", - reqnum, requestUrl, tickdiff, rcvlen); + m_log.Debug($"[SRestObjReq]: Exception on response from GET {requestUrl}: {e.Message}"); } - else if (WebUtil.DebugLevel >= 4) + finally { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); } return deserial; } @@ -1447,43 +1579,41 @@ public static class XMLResponseHelper { public static TResponse LogAndDeserialize(int reqnum, Stream respStream, long contentLength) { - XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); + XmlSerializer deserializer = new (typeof(TResponse)); if (WebUtil.DebugLevel >= 5) { const int blockLength = 4096; byte[] dataBuffer = new byte[blockLength]; int curcount; - using (MemoryStream ms = new MemoryStream(4 * blockLength)) + using MemoryStream ms = new(4 * blockLength); + if (contentLength == -1) { - if(contentLength == -1) + while (true) { - while (true) - { - curcount = respStream.Read(dataBuffer, 0, blockLength); - if (curcount <= 0) - break; - ms.Write(dataBuffer, 0, curcount); - } + curcount = respStream.Read(dataBuffer, 0, blockLength); + if (curcount <= 0) + break; + ms.Write(dataBuffer, 0, curcount); } - else + } + else + { + int remaining = (int)contentLength; + while (remaining > 0) { - int remaining = (int)contentLength; - while (remaining > 0) - { - curcount = respStream.Read(dataBuffer, 0, remaining); - if (curcount <= 0) - throw new EndOfStreamException(String.Format("End of stream reached with {0} bytes left to read", remaining)); - ms.Write(dataBuffer, 0, curcount); - remaining -= curcount; - } + curcount = respStream.Read(dataBuffer, 0, remaining); + if (curcount <= 0) + throw new EndOfStreamException($"End of stream reached with {remaining} bytes left to read"); + ms.Write(dataBuffer, 0, curcount); + remaining -= curcount; } + } - dataBuffer = ms.ToArray(); - WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(dataBuffer)); + dataBuffer = ms.ToArray(); + WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(dataBuffer)); - ms.Position = 0; - return (TResponse)deserializer.Deserialize(ms); - } + ms.Position = 0; + return (TResponse)deserializer.Deserialize(ms); } else { @@ -1501,18 +1631,19 @@ public static Hashtable SendRequest(Hashtable ReqParams, string method, string u int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} XML-RPC '{1}' to {2}", - reqnum, method, url); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} XML-RPC '{method}' to {url}"); int tickstart = Util.EnvironmentTickCount(); string responseStr = null; - + HttpClient client = null; try { - ArrayList SendParams = new ArrayList(); - SendParams.Add(ReqParams); + ArrayList SendParams = new() + { + ReqParams + }; - XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); + XmlRpcRequest Req = new(method, SendParams); if (WebUtil.DebugLevel >= 5) { @@ -1521,7 +1652,8 @@ public static Hashtable SendRequest(Hashtable ReqParams, string method, string u WebUtil.LogOutgoingDetail("SEND", reqnum, str); } - XmlRpcResponse Resp = Req.Send(url, 30000); + client = WebUtil.GetNewGlobalHttpClient(-1); + XmlRpcResponse Resp = Req.Send(url, client); try { @@ -1534,14 +1666,13 @@ public static Hashtable SendRequest(Hashtable ReqParams, string method, string u } catch (Exception e) { - m_log.Error("Error parsing XML-RPC response", e); + m_log.Error($"[LOGHTTP]: Error parsing XML-RPC response: {e.Message}"); } if (Resp.IsFault) { - m_log.DebugFormat( - "[LOGHTTP]: XML-RPC request {0} '{1}' to {2} FAILED: FaultCode={3}, FaultMessage={4}", - reqnum, method, url, Resp.FaultCode, Resp.FaultString); + m_log.Debug( + $"[LOGHTTP]: XML-RPC request {reqnum} '{method}' to {url} FAILED: FaultCode={Resp.FaultCode}, {Resp.FaultString}"); return null; } @@ -1550,6 +1681,8 @@ public static Hashtable SendRequest(Hashtable ReqParams, string method, string u } finally { + client?.Dispose(); + int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > WebUtil.LongCallTime) { @@ -1562,7 +1695,7 @@ public static Hashtable SendRequest(Hashtable ReqParams, string method, string u } else if (WebUtil.DebugLevel >= 4) { - m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms", reqnum, tickdiff); + m_log.Debug($"[LOGHTTP]: HTTP OUT {reqnum} took {tickdiff}ms"); } } } diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 14fe7c0f5a4..cb46b02b6d8 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -73,6 +73,8 @@ public static void Main(string[] args) // First line, hook the appdomain to the crash reporter AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true); + Culture.SetCurrentCulture(); Culture.SetDefaultCurrentCulture(); @@ -89,7 +91,7 @@ public static void Main(string[] args) // Configure Log4Net configSource.AddSwitch("Startup", "logconfig"); string logConfigFile = configSource.Configs["Startup"].GetString("logconfig", String.Empty); - if (logConfigFile != String.Empty) + if (!string.IsNullOrEmpty(logConfigFile)) { XmlConfigurator.Configure(new System.IO.FileInfo(logConfigFile)); m_log.InfoFormat("[OPENSIM MAIN]: configured log4net using \"{0}\" as configuration file", @@ -97,10 +99,32 @@ public static void Main(string[] args) } else { - XmlConfigurator.Configure(); + XmlConfigurator.Configure(new System.IO.FileInfo("OpenSim.exe.config")); m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config"); } + // temporay set the platform dependent System.Drawing.Common.dll + string targetdll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), + "System.Drawing.Common.dll"); + string src = targetdll + (Util.IsWindows() ? ".win" : ".linux"); + try + { + if (!File.Exists(targetdll)) + File.Copy(src, targetdll); + else + { + FileInfo targetInfo = new(targetdll); + FileInfo srcInfo = new(src); + if(targetInfo.Length != srcInfo.Length) + File.Copy(src, targetdll, true); + } + } + catch (Exception e) + { + m_log.Error("Failed to copy System.Drawing.Common.dll for current platform" + e.Message); + throw; + } + m_log.InfoFormat( "[OPENSIM MAIN]: System Locale is {0}", System.Threading.Thread.CurrentThread.CurrentCulture); if(!Util.IsWindows()) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index ec26355b017..5f9573bb8b7 100755 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -185,9 +185,9 @@ protected override void StartupSpecific() MainServer.Instance.AddSimpleStreamHandler(new SimRobotsHandler()); MainServer.Instance.AddSimpleStreamHandler(new IndexPHPHandler(MainServer.Instance)); - if (managedStatsURI != String.Empty) + if (!string.IsNullOrEmpty(managedStatsURI)) { - string urlBase = String.Format("/{0}/", managedStatsURI); + string urlBase = $"/{managedStatsURI}/"; StatsManager.StatsPassword = managedStatsPassword; MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest); m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase); @@ -316,7 +316,7 @@ private void RegisterConsoleCommands() + "1: Rotation (around the incoming OARs region center)\n" + "2: Cropping (a bounding cube with origin and size)\n" + "3: Displacement (setting offset coordinates within the destination region)", - LoadOar); ; + LoadOar); m_console.Commands.AddCommand("Archiving", false, "save oar", //"save oar [-v|--version=] [-p|--profile=] []", @@ -614,7 +614,7 @@ private void HandleRotateScene(string module, string[] args) return; } - float angle = (float)(Convert.ToSingle(args[2]) / 180.0 * Math.PI); + float angle = Convert.ToSingle(args[2]) / 180.0f * MathF.PI; OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, angle); if (args.Length > 4) diff --git a/OpenSim/Region/Application/OpenSim.csproj b/OpenSim/Region/Application/OpenSim.csproj index ff2bce30e78..49ff4b1d754 100644 --- a/OpenSim/Region/Application/OpenSim.csproj +++ b/OpenSim/Region/Application/OpenSim.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe OpenSim http://opensimulator.org @@ -62,6 +62,7 @@ - + + \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 104aa9ff135..e18419a9336 100755 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -40,7 +40,7 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Monitoring; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; +//using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/Application/runtimeconfig.template.json b/OpenSim/Region/Application/runtimeconfig.template.json new file mode 100644 index 00000000000..772fa6058fd --- /dev/null +++ b/OpenSim/Region/Application/runtimeconfig.template.json @@ -0,0 +1,11 @@ +{ + "configProperties": { + "System.GC.Server": false, + "System.GC.HighMemoryPercent": 50, + "System.Drawing.EnableUnixSupport": true, + "System.Globalization.UseNls": true, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true, + "System.Runtime.TieredCompilation.QuickJit": false + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0c193a1bac4..516ea00ae3f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -34,9 +34,7 @@ using System.Net; using System.Threading; using System.Reflection; -using System.Security.Cryptography; using System.Text; -using System.Web; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -45,11 +43,9 @@ using OpenSim.Framework; using OpenSim.Framework.Capabilities; -using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; @@ -85,14 +81,14 @@ public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UU public partial class BunchOfCaps { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; private UUID m_AgentID; private UUID m_scopeID; private Caps m_HostCapsObj; private ModelCost m_ModelCost; + private BunchOfCapsConfigOptions ConfigOptions; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. @@ -103,30 +99,11 @@ public partial class BunchOfCaps public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; public GetClientDelegate GetClient = null; - - private bool m_persistBakedTextures = false; + private IAssetService m_assetService; private bool m_dumpAssetsToFile = false; private string m_regionName; - private int m_levelUpload = 0; - - private bool m_enableFreeTestUpload = false; // allows "TEST-" prefix hack - private bool m_ForceFreeTestUpload = false; // forces all uploads to be test - - private bool m_enableModelUploadTextureToInventory = true; // place uploaded textures also in inventory - // may not be visible till relog - - private bool m_RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!! - private UUID m_testAssetsCreatorID = UUID.Zero; - - private float m_PrimScaleMin = 0.001f; - - private bool m_AllowCapHomeLocation = true; - private bool m_AllowCapGroupMemberData = true; - private bool m_AllowCapLandResources = true; - private bool m_AllowCapAttachmentResources = true; - private IUserManagement m_UserManager; private IUserAccountService m_userAccountService; private IMoneyModule m_moneyModule; @@ -140,89 +117,26 @@ private enum FileAgentInventoryState : int } private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; - public BunchOfCaps(Scene scene, UUID agentID, Caps caps) + public BunchOfCaps(Scene scene, UUID agentID, Caps caps, BunchOfCapsConfigOptions configOptions) { m_Scene = scene; m_AgentID = agentID; m_HostCapsObj = caps; + ConfigOptions = configOptions; - // create a model upload cost provider - m_ModelCost = new ModelCost(scene); - - m_PrimScaleMin = m_ModelCost.PrimScaleMin; - - IConfigSource config = m_Scene.Config; - if (config != null) - { - IConfig sconfig = config.Configs["Startup"]; - if (sconfig != null) - { - m_levelUpload = sconfig.GetInt("LevelUpload", 0); - } - if (m_levelUpload == 0) - { - IConfig pconfig = config.Configs["Permissions"]; - if (pconfig != null) - { - m_levelUpload = pconfig.GetInt("LevelUpload", 0); - } - } - - IConfig appearanceConfig = config.Configs["Appearance"]; - if (appearanceConfig != null) - { - m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); - } - // economy for model upload - IConfig EconomyConfig = config.Configs["Economy"]; - if (EconomyConfig != null) - { - m_ModelCost.Econfig(EconomyConfig); - - m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory); - - m_RestrictFreeTestUploadPerms = EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms); - m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", m_enableFreeTestUpload); - m_ForceFreeTestUpload = EconomyConfig.GetBoolean("ForceFreeTestUpload", m_ForceFreeTestUpload); - string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", ""); - if (!string.IsNullOrEmpty(testcreator)) - { - if (UUID.TryParse(testcreator, out UUID id)) - m_testAssetsCreatorID = id; - } - } - - IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"]; - if (CapsConfig != null) - { - string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost"); - if(homeLocationUrl.Length == 0) - m_AllowCapHomeLocation = false; - - string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost"); - if(GroupMemberDataUrl.Length == 0) - m_AllowCapGroupMemberData = false; - - string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost"); - if (LandResourcesUrl.Length == 0) - m_AllowCapLandResources = false; - - string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost"); - if (AttachmentResourcesUrl.Length == 0) - m_AllowCapAttachmentResources = false; - } - } + //cache model upload cost provider + m_ModelCost = configOptions.ModelCost; m_assetService = m_Scene.AssetService; m_regionName = m_Scene.RegionInfo.RegionName; m_UserManager = m_Scene.RequestModuleInterface(); m_userAccountService = m_Scene.RequestModuleInterface(); m_moneyModule = m_Scene.RequestModuleInterface(); - if (m_UserManager == null) + if (m_UserManager is null) m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found"); - UserAccount account = m_userAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID); - if (account == null) // Hypergrid? + UserAccount account = m_userAccountService?.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID); + if (account is null) // Hypergrid? m_scopeID = m_Scene.RegionInfo.ScopeID; else m_scopeID = account.ScopeID; @@ -272,33 +186,36 @@ public void RegisterRegionServiceHandlers() m_HostCapsObj.RegisterSimpleHandler("ResourceCostSelected", new SimpleOSDMapHandler("POST", GetNewCapPath(), ResourceCostSelected)); - if(m_AllowCapHomeLocation) + if(ConfigOptions.AllowCapHomeLocation) { m_HostCapsObj.RegisterSimpleHandler("HomeLocation", new SimpleStreamHandler(GetNewCapPath(), HomeLocation)); } - if (m_AllowCapGroupMemberData) + if (ConfigOptions.AllowCapGroupMemberData) { m_HostCapsObj.RegisterSimpleHandler("GroupMemberData", new SimpleStreamHandler(GetNewCapPath(), GroupMemberData)); } - if (m_AllowCapLandResources) + if (ConfigOptions.AllowCapLandResources) { m_HostCapsObj.RegisterSimpleHandler("LandResources", new SimpleOSDMapHandler("POST", GetNewCapPath(), LandResources)); } - if (m_AllowCapAttachmentResources) + if (ConfigOptions.AllowCapAttachmentResources) { m_HostCapsObj.RegisterSimpleHandler("AttachmentResources", new SimpleStreamHandler(GetNewCapPath(), AttachmentResources)); } + + m_HostCapsObj.RegisterSimpleHandler("DispatchRegionInfo", + new SimpleOSDMapHandler("POST", GetNewCapPath(), DispatchRegionInfo), true); } catch (Exception e) { - m_log.Error("[CAPS]: " + e.ToString()); + m_log.Error("[CAPS]: Error " + e.Message); } } @@ -311,7 +228,7 @@ public void RegisterInventoryServiceHandlers() "POST", GetNewCapPath(), NewAgentInventoryRequest, "NewFileAgentInventory", null)); SimpleOSDMapHandler oreq; - if (ItemUpdatedCall != null) + if (ItemUpdatedCall is not null) { // first sets the http handler, others only register the cap, using it oreq = new SimpleOSDMapHandler("POST", GetNewCapPath(), UpdateNotecardItemAsset); @@ -339,7 +256,7 @@ public void RegisterInventoryServiceHandlers() m_HostCapsObj.RegisterSimpleHandler("UpdateGestureTaskInventory", oreq, false); } - if (TaskScriptUpdatedCall != null) + if (TaskScriptUpdatedCall is not null) { oreq = new SimpleOSDMapHandler("POST", GetNewCapPath(), UpdateScriptTaskInventory); m_HostCapsObj.RegisterSimpleHandler("UpdateScriptTask", oreq, true); @@ -365,7 +282,7 @@ public void RegisterOtherHandlers() { try { - if (m_UserManager != null) + if (m_UserManager is not null) { m_HostCapsObj.RegisterSimpleHandler("GetDisplayNames", new SimpleStreamHandler(GetNewCapPath(), GetDisplayNames)); @@ -373,7 +290,7 @@ public void RegisterOtherHandlers() } catch (Exception e) { - m_log.Error("[CAPS]: " + e.ToString()); + m_log.Error("[CAPS]: Error " + e.Message); } } /// @@ -387,9 +304,8 @@ public void RegisterOtherHandlers() /// public void SeedCapRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - UUID agentID = m_HostCapsObj.AgentID; - m_log.DebugFormat( - "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, agentID); + m_log.Debug( + $"[CAPS]: Received SEED caps request in {m_regionName} for agent {m_HostCapsObj.AgentID}"); if(httpRequest.HttpMethod != "POST" || httpRequest.ContentType != "application/llsd+xml") { @@ -404,11 +320,10 @@ public void SeedCapRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpRespo return; } - if (!m_Scene.CheckClient(agentID, httpRequest.RemoteIPEndPoint)) + if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) { m_log.WarnFormat( - "[CAPS]: Unauthorized CAPS client {0} from {1}", - agentID, httpRequest.RemoteIPEndPoint); + $"[CAPS]: Unauthorized CAPS client {m_HostCapsObj.AgentID} from {httpRequest.RemoteIPEndPoint}"); httpResponse.StatusCode = (int)HttpStatusCode.Forbidden; return; } @@ -424,24 +339,45 @@ public void SeedCapRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpRespo return; } - List validCaps = new List(); + HashSet validCaps = new(); foreach (OSD c in capsRequested) { string cstr = c.AsString(); - if (cstr.Equals("ObjectAnimation")) - m_HostCapsObj.Flags |= Caps.CapsFlags.ObjectAnim; - else if (cstr.Equals("EnvironmentSettings")) - m_HostCapsObj.Flags |= Caps.CapsFlags.WLEnv; - else if (cstr.Equals("ExtEnvironment")) - m_HostCapsObj.Flags |= Caps.CapsFlags.AdvEnv; + if (string.IsNullOrEmpty(cstr)) + continue; + switch (cstr) + { + case "SEED": + continue; + case "ViewerBenefits": // this may need a proper cap but not currently + m_HostCapsObj.Flags |= Caps.CapsFlags.ViewerBenefits; + continue; + case "ObjectAnimation": + m_HostCapsObj.Flags |= Caps.CapsFlags.ObjectAnim; + break; + case "EnvironmentSettings": + m_HostCapsObj.Flags |= Caps.CapsFlags.WLEnv; + break; + case "ExtEnvironment": + m_HostCapsObj.Flags |= Caps.CapsFlags.AdvEnv; + break; + case "ModifyMaterialParams": // will not work if a viewer has no edit features + m_HostCapsObj.Flags |= Caps.CapsFlags.PBR; + break; + default: + break; + } validCaps.Add(cstr); } + + osUTF8 sb = LLSDxmlEncode2.Start(); + LLSDxmlEncode2.AddMap(sb); + m_HostCapsObj.GetCapsDetailsLLSDxml(validCaps, sb); + LLSDxmlEncode2.AddEndMap(sb); - string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps)); - httpResponse.RawBuffer = Util.UTF8NBGetbytes(result); + httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(sb); httpResponse.StatusCode = (int)HttpStatusCode.OK; - //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); m_HostCapsObj.Flags |= Caps.CapsFlags.SentSeeds; } @@ -508,9 +444,9 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level - if (avatar != null) + if (avatar is not null) { - if (avatar.GodController.UserLevel < m_levelUpload) + if (avatar.GodController.UserLevel < ConfigOptions.levelUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = "Insufficient permissions to upload"; @@ -527,12 +463,12 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l } // check test upload and funds - if (client != null) + if (client is not null) { IMoneyModule mm = m_Scene.RequestModuleInterface(); int baseCost = 0; - if (mm != null) + if (mm is not null) baseCost = mm.UploadCharge; string warning = String.Empty; @@ -569,7 +505,7 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l { // check for test upload - if (m_ForceFreeTestUpload) // all are test + if (ConfigOptions.ForceFreeTestUpload) // all are test { if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it assetName = "TEST-" + assetName; @@ -577,7 +513,7 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l IsAtestUpload = true; } - else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" + else if (ConfigOptions.enableFreeTestUpload) // only if prefixed with "TEST-" { IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); @@ -605,7 +541,7 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l } } } - else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" + else if (ConfigOptions.enableFreeTestUpload) // only if prefixed with "TEST-" { IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); if(IsAtestUpload) @@ -624,7 +560,7 @@ public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest l string uploaderPath = GetNewCapPath(); UUID texturesFolder = UUID.Zero; - if(!IsAtestUpload && m_enableModelUploadTextureToInventory) + if(!IsAtestUpload && ConfigOptions.enableModelUploadTextureToInventory) texturesFolder = llsdRequest.texture_folder_id; AssetUploader uploader = @@ -693,12 +629,12 @@ public void UploadCompleteHandler(string assetName, string assetDescription, UUI UUID owner_id = m_HostCapsObj.AgentID; UUID creatorID; - bool istest = IsAtestUpload && m_enableFreeTestUpload; + bool istest = IsAtestUpload && ConfigOptions.enableFreeTestUpload; - bool restrictPerms = m_RestrictFreeTestUploadPerms && istest; + bool restrictPerms = ConfigOptions.RestrictFreeTestUploadPerms && istest; - if (istest && m_testAssetsCreatorID != UUID.Zero) - creatorID = m_testAssetsCreatorID; + if (istest && ConfigOptions.testAssetsCreatorID.IsNotZero()) + creatorID = ConfigOptions.testAssetsCreatorID; else creatorID = owner_id; @@ -784,7 +720,7 @@ public void UploadCompleteHandler(string assetName, string assetDescription, UUI SceneObjectGroup grp = null; // create and store texture assets - bool doTextInv = (!istest && m_enableModelUploadTextureToInventory && + bool doTextInv = (!istest && ConfigOptions.enableModelUploadTextureToInventory && texturesFolder != UUID.Zero); @@ -909,6 +845,7 @@ public void UploadCompleteHandler(string assetName, string assetDescription, UUI } int skipedMeshs = 0; + float primScaleMin = m_ModelCost.PrimScaleMin; // build prims from instances for (int i = 0; i < instance_list.Count; i++) { @@ -917,7 +854,7 @@ public void UploadCompleteHandler(string assetName, string assetDescription, UUI // skip prims that are 2 small Vector3 scale = inner_instance_list["scale"].AsVector3(); - if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) + if (scale.X < primScaleMin || scale.Y < primScaleMin || scale.Z < primScaleMin) { skipedMeshs++; continue; @@ -1558,12 +1495,8 @@ public void GetObjectCost(IOSHttpRequest httpRequest, IOSHttpResponse httpRespon if (grp != null) { haveone = true; - float linksetCost; - float linksetPhysCost; - float partCost; - float partPhysCost; - grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost); + grp.GetResourcesCosts(part, out float linksetCost, out float linksetPhysCost, out float partCost, out float partPhysCost); LLSDxmlEncode2.AddMap(uuid.ToString(), lsl); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs index 2b0598058c5..0098e95970a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs @@ -26,8 +26,6 @@ */ using System; -using System.Collections.Generic; -using System.Reflection; using log4net; using Nini.Config; @@ -44,14 +42,35 @@ [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.AssemblyVersionNumber)] namespace OpenSim.Region.ClientStack.Linden { + public class BunchOfCapsConfigOptions + { + public ModelCost ModelCost; + + public bool persistBakedTextures = false; + public bool enableModelUploadTextureToInventory = true; // place uploaded textures also in inventory + // may not be visible till relog + public bool enableFreeTestUpload = false; // allows "TEST-" prefix hack + public bool ForceFreeTestUpload = false; // forces all uploads to be test + + public bool RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!! + + public int levelUpload = 0; + + public bool AllowCapHomeLocation = true; + public bool AllowCapGroupMemberData = true; + public bool AllowCapLandResources = true; + public bool AllowCapAttachmentResources = true; + + public UUID testAssetsCreatorID = UUID.Zero; + } [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BunchOfCapsModule")] public class BunchOfCapsModule : INonSharedRegionModule { -// private static readonly ILog m_log = -// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; + private BunchOfCapsConfigOptions ConfigOptions = new(); #region INonSharedRegionModule @@ -68,7 +87,6 @@ public void Close() { } public void AddRegion(Scene scene) { m_Scene = scene; - m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps; } public void RemoveRegion(Scene scene) @@ -77,6 +95,70 @@ public void RemoveRegion(Scene scene) public void RegionLoaded(Scene scene) { + ConfigOptions.ModelCost = new ModelCost(m_Scene); + + IConfigSource config = m_Scene.Config; + if (config is not null) + { + IConfig sconfig = config.Configs["Startup"]; + if (sconfig is not null) + ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0); + + if (ConfigOptions.levelUpload == 0) + { + IConfig pconfig = config.Configs["Permissions"]; + if (pconfig is not null) + ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0); + } + + IConfig appearanceConfig = config.Configs["Appearance"]; + if (appearanceConfig is not null) + { + ConfigOptions.persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", ConfigOptions.persistBakedTextures); + } + // economy for model upload + IConfig EconomyConfig = config.Configs["Economy"]; + if (EconomyConfig is not null) + { + ConfigOptions.ModelCost.Econfig(EconomyConfig); + + ConfigOptions.enableModelUploadTextureToInventory = + EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", ConfigOptions.enableModelUploadTextureToInventory); + + ConfigOptions.RestrictFreeTestUploadPerms = + EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", ConfigOptions.RestrictFreeTestUploadPerms); + + ConfigOptions.enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", ConfigOptions.enableFreeTestUpload); + + ConfigOptions.ForceFreeTestUpload = + EconomyConfig.GetBoolean("ForceFreeTestUpload", ConfigOptions.ForceFreeTestUpload); + + string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", ""); + if (!string.IsNullOrEmpty(testcreator)) + { + if (UUID.TryParse(testcreator, out UUID id)) + ConfigOptions.testAssetsCreatorID = id; + } + } + + IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"]; + if (CapsConfig is not null) + { + string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost"); + ConfigOptions.AllowCapHomeLocation = !string.IsNullOrEmpty(homeLocationUrl); + + string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost"); + ConfigOptions.AllowCapGroupMemberData = !string.IsNullOrEmpty(GroupMemberDataUrl); + + string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost"); + ConfigOptions.AllowCapLandResources = !string.IsNullOrEmpty(LandResourcesUrl); + + string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost"); + ConfigOptions.AllowCapAttachmentResources = !string.IsNullOrEmpty(AttachmentResourcesUrl); + } + + m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps; + } } public void PostInitialise() { } @@ -84,7 +166,7 @@ public void PostInitialise() { } private void OnRegisterCaps(UUID agentID, Caps caps) { - new BunchOfCaps(m_Scene, agentID, caps); + _ = new BunchOfCaps(m_Scene, agentID, caps, ConfigOptions); } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs new file mode 100644 index 00000000000..3fdcdf085af --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections; + +using System.IO; +using System.Net; +using System.Text; +using System.Threading; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; + +namespace OpenSim.Region.ClientStack.Linden +{ + + public partial class BunchOfCaps +{ + public void DispatchRegionInfo(IOSHttpRequest request, IOSHttpResponse response, OSDMap map) + { + //m_log.Debug("[CAPS]: DispatchRegionInfo Request in region: " + m_regionName + "\n"); + + if (request.HttpMethod != "POST") + { + response.StatusCode = (int)HttpStatusCode.NotFound; + return; + } + + if(map == map.Count < 3) + { + response.StatusCode = (int)HttpStatusCode.BadRequest; + return; + } + + if (!m_Scene.TryGetScenePresence(m_AgentID, out ScenePresence _) || !m_Scene.Permissions.CanIssueEstateCommand(m_AgentID, false)) + { + response.StatusCode = (int)HttpStatusCode.Unauthorized; + return; + } + + IEstateModule estateModule = m_Scene.RequestModuleInterface(); + if (estateModule == null) + { + response.StatusCode = (int)HttpStatusCode.NotImplemented; + return; + } + + response.StatusCode = estateModule.SetRegionInfobyCap(map) ? (int)HttpStatusCode.OK : (int)HttpStatusCode.NotImplemented; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/UpdateItemAsset.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/UpdateItemAsset.cs index 9a2ab410c31..a57a3e71d90 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/UpdateItemAsset.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/UpdateItemAsset.cs @@ -335,7 +335,7 @@ public void process(IOSHttpRequest request, IOSHttpResponse response, byte[] dat if (m_dumpAssetToFile) { - Util.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); + Util.SaveAssetToFile("updateditem" + Random.Shared.Next(1, 1000) + ".dat", data); } response.StatusCode = (int)HttpStatusCode.OK; @@ -417,7 +417,7 @@ public void process(IOSHttpRequest request, IOSHttpResponse response, byte[] dat if (m_dumpAssetToFile) { - Util.SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); + Util.SaveAssetToFile("updatedtaskscript" + Random.Shared.Next(1, 1000) + ".dat", data); } // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs index caf7fb7e8ec..a77e3fec1d7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs @@ -144,8 +144,7 @@ public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUI return; } - ScenePresence avatar; - if (!m_scene.TryGetScenePresence(AgentId, out avatar) || m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null) + if (!m_scene.TryGetScenePresence(AgentId, out ScenePresence _) || m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null) { response.StatusCode = (int)HttpStatusCode.Gone; return; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs index 0c4c1326193..f2c6883a8bc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs @@ -26,10 +26,7 @@ */ using System; -using System.Collections; -using System.Collections.Generic; using System.Net; -using System.Text; using System.Reflection; using log4net; @@ -38,7 +35,6 @@ using OpenMetaverse.StructuredData; using Mono.Addins; -using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -144,8 +140,7 @@ public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUI return; } - ScenePresence avatar; - if (!m_scene.TryGetScenePresence(AgentId, out avatar) || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) + if (!m_scene.TryGetScenePresence(AgentId, out ScenePresence _) || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) { response.StatusCode = (int)HttpStatusCode.Unauthorized; return; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetHandlers.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetHandlers.cs index 8ca35f5abc4..131ce0d2dd9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetHandlers.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetHandlers.cs @@ -26,21 +26,12 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using Mono.Addins; using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; -using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using Caps=OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.ClientStack.Linden { @@ -84,8 +75,7 @@ public byte[] EndEventToBytes(osUTF8 sb) public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { if (DebugLevel > 0) - m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", - LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); + m_log.Debug($"{LogHeader} EnableSimulator. handle={handle}, endPoint={endPoint}, avatarID={avatarID}"); osUTF8 sb = StartEvent("EnableSimulator"); LLSDxmlEncode2.AddArrayAndMap("SimulatorInfo", sb); @@ -103,8 +93,7 @@ public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoi ulong regionHandle, int regionSizeX, int regionSizeY) { if (DebugLevel > 0) - m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", - LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); + m_log.Debug($"{LogHeader} EstablishAgentCommunication. handle={regionHandle}, endPoint={endPoint}, avatarID={avatarID}"); osUTF8 sb = StartEvent("EstablishAgentCommunication"); @@ -125,8 +114,7 @@ public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, UUID avatarID, int regionSizeX, int regionSizeY) { if (DebugLevel > 0) - m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", - LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); + m_log.Debug($"{LogHeader} TeleportFinishEvent. handle={regionHandle}, endPoint={regionExternalEndPoint}, avatarID={avatarID}"); // not sure why flags get overwritten here if ((flags & (uint)TeleportFlags.IsFlying) != 0) @@ -157,8 +145,7 @@ public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) { if (DebugLevel > 0) - m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", - LogHeader, handle, avatarID, regionSizeX, regionSizeY); + m_log.Debug($"{LogHeader} CrossRegion. handle={handle}, avatarID={avatarID}, regionSize={regionSizeX},{regionSizeY}>"); osUTF8 sb = StartEvent("CrossedRegion"); @@ -189,7 +176,7 @@ private static string InstantMessageBody(UUID fromAgent, string message, UUID to Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket, bool checkEstate, int godLevel, bool limitedToEstate) { - osUTF8 sb = new osUTF8(512); + osUTF8 sb = new(512); LLSDxmlEncode2.AddMap("instantmessage", sb); LLSDxmlEncode2.AddMap("message_params", sb); //messageParams LLSDxmlEncode2.AddElem("type", dialog, sb); @@ -350,7 +337,7 @@ public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data) public void PlacesQueryReply(UUID avatarID, UUID queryID, UUID transactionID, PlacesReplyData[] replyDataArray) { - osUTF8 sb = new osUTF8(256); + osUTF8 sb = new(256); LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("message", "PlacesReplyMessage", sb); LLSDxmlEncode2.AddMap("QueryData[]", sb); LLSDxmlEncode2.AddArray(sb); @@ -437,9 +424,8 @@ public void SendBulkUpdateInventoryItem(InventoryItemBase item, UUID avatarID, U LLSDxmlEncode2.AddEndMapAndArray(sb); LLSDxmlEncode2.AddRawElem("FolderDataFolderID00000000-0000-0000-0000-000000000000NameParentID00000000-0000-0000-0000-000000000000Type-1",sb); - - osUTF8 osName = new osUTF8(Utils.StringToBytesNoTerm(item.Name, 255)); - osUTF8 osDesc = new osUTF8(Utils.StringToBytesNoTerm(item.Description, 255)); + osUTF8 osName = new osUTF8(item.Name, 255); + osUTF8 osDesc = new osUTF8(item.Description, 255); LLSDxmlEncode2.AddArray("ItemData", sb); LLSDxmlEncode2.AddMap(sb); @@ -480,7 +466,7 @@ public void SendBulkUpdateInventoryItem(InventoryItemBase item, UUID avatarID, U public static string KeepAliveEvent() { - osUTF8 sb = new osUTF8(256); + osUTF8 sb = new(256); LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("message", "FAKEEVENT", sb); LLSDxmlEncode2.AddMap("body", sb); @@ -489,9 +475,63 @@ public static string KeepAliveEvent() return sb.ToString(); } + public void SendLargeGenericMessage(UUID avatarID, UUID? transationID, UUID? sessionID, + string method, UUID invoice, List message) + { + osUTF8 sb = StartEvent("LargeGenericMessage"); + LLSDxmlEncode2.AddArrayAndMap("AgentData", sb); + LLSDxmlEncode2.AddElem("AgentID", avatarID, sb); + if (transationID.HasValue) + LLSDxmlEncode2.AddElem("TransactionID", transationID.Value, sb); + if (sessionID.HasValue) + LLSDxmlEncode2.AddElem("SessionID", sessionID.Value, sb); + LLSDxmlEncode2.AddEndMapAndArray(sb); + + LLSDxmlEncode2.AddArrayAndMap("MethodData", sb); + LLSDxmlEncode2.AddElem("Method", method, sb); + LLSDxmlEncode2.AddElem("Invoice", invoice, sb); + LLSDxmlEncode2.AddEndMapAndArray(sb); + + LLSDxmlEncode2.AddArrayAndMap("ParamList", sb); + foreach (string s in message) + LLSDxmlEncode2.AddElem("Parameter", s, sb); + LLSDxmlEncode2.AddEndMapAndArray(sb); + + Enqueue(EndEventToBytes(sb), avatarID); + } + + public void SendLargeGenericMessage(UUID avatarID, UUID? transationID, UUID? sessionID, + string method, UUID invoice, List message) + { + osUTF8 sb = StartEvent("LargeGenericMessage"); + LLSDxmlEncode2.AddArrayAndMap("AgentData", sb); + LLSDxmlEncode2.AddElem("AgentID", avatarID, sb); + if (transationID.HasValue) + LLSDxmlEncode2.AddElem("TransactionID", transationID.Value, sb); + if (sessionID.HasValue) + LLSDxmlEncode2.AddElem("SessionID", sessionID.Value, sb); + LLSDxmlEncode2.AddEndMapAndArray(sb); + + LLSDxmlEncode2.AddArrayAndMap("MethodData", sb); + LLSDxmlEncode2.AddElem("Method", method, sb); + LLSDxmlEncode2.AddElem("Invoice", invoice, sb); + LLSDxmlEncode2.AddEndMapAndArray(sb); + + LLSDxmlEncode2.AddArrayAndMap("ParamList", sb); + foreach (byte[] b in message) + { + LLSDxmlEncode2.AddLLSD("Parameter", sb); + sb.Append(b); + LLSDxmlEncode2.AddLLSD("", sb); + } + LLSDxmlEncode2.AddEndMapAndArray(sb); + + Enqueue(EndEventToBytes(sb), avatarID); + } + public byte[] BuildEvent(string eventName, OSD eventBody) { - OSDMap llsdEvent = new OSDMap(2); + OSDMap llsdEvent = new(2); llsdEvent.Add("message", new OSDString(eventName)); llsdEvent.Add("body", eventBody); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 6ef07f3619f..3852296bbba 100755 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Net; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using log4net; using Nini.Config; @@ -50,11 +51,11 @@ public struct QueueItem public OSDMap body; } - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EventQueueGetModule")] + [Mono.Addins.Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EventQueueGetModule")] public partial class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static string LogHeader = "[EVENT QUEUE GET MODULE]"; + private static readonly string LogHeader = "[EVENT QUEUE GET MODULE]"; private const int KEEPALIVE = 60; // this could be larger now, but viewers expect it on opensim // we need to go back to close before viwers, or we may lose data @@ -67,10 +68,10 @@ public partial class EventQueueGetModule : IEventQueue, INonSharedRegionModule protected Scene m_scene; - private Dictionary m_ids = new Dictionary(); + private readonly Dictionary m_ids = new(); - private Dictionary> queues = new Dictionary>(); - private Dictionary m_AvatarQueueUUIDMapping = new Dictionary(); + private readonly Dictionary> queues = new(); + private readonly Dictionary m_AvatarQueueUUIDMapping = new(); #region INonSharedRegionModule methods public virtual void Initialise(IConfigSource config) @@ -147,20 +148,19 @@ protected void HandleDebugEq(string module, string[] args) else { DebugLevel = debugLevel; - MainConsole.Instance.Output( - "Set event queue debug level to {0} in {1}", DebugLevel, m_scene.RegionInfo.RegionName); + MainConsole.Instance.Output($"Set event queue debug level to {DebugLevel} in {m_scene.RegionInfo.RegionName}"); } } protected void HandleShowEq(string module, string[] args) { - MainConsole.Instance.Output("Events in Scene {0} agents queues :", m_scene.Name); + MainConsole.Instance.Output($"Events in Scene {m_scene.Name} agents queues :"); lock (queues) { foreach (KeyValuePair> kvp in queues) { - MainConsole.Instance.Output(" {0} {1}", kvp.Key, kvp.Value.Count); + MainConsole.Instance.Output($" {kvp.Key} {kvp.Value.Count}"); } } } @@ -221,14 +221,12 @@ public bool Enqueue(OSD data, UUID avatarID) } else { - m_log.WarnFormat( - "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {1}", - avatarID, m_scene.Name); + m_log.Warn($"[EVENTQUEUE]: (Enqueue) No queue found for agent {avatarID} in region {m_scene.Name}"); } } catch (NullReferenceException e) { - m_log.Error("[EVENTQUEUE] Caught exception: " + e); + m_log.Error($"[EVENTQUEUE] Caught exception: {e.Message}"); return false; } return true; @@ -341,9 +339,9 @@ private void ClientClosed(UUID agentID, Scene scene) /// Generate an Event Queue Get handler path for the given eqg uuid. /// /// - private string GenerateEqgCapPath(UUID eqgUuid) + private static string GenerateEqgCapPath(UUID eqgUuid) { - return string.Format("/CE/{0}", eqgUuid); + return $"/CE/{eqgUuid}"; } public void OnRegisterCaps(UUID agentID, Caps caps) @@ -351,16 +349,13 @@ public void OnRegisterCaps(UUID agentID, Caps caps) // Register an event queue for the client if (DebugLevel > 0) - m_log.DebugFormat( - "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", - agentID, caps, m_scene.RegionInfo.RegionName); + m_log.Debug( + $"[EVENTQUEUE]: OnRegisterCaps: agentID {agentID} caps {caps} region {m_scene.Name}"); UUID eventQueueGetUUID; - Queue queue = null; - lock (queues) { - queues.TryGetValue(agentID, out queue); + queues.TryGetValue(agentID, out Queue queue); if (queue == null) { @@ -377,8 +372,7 @@ public void OnRegisterCaps(UUID agentID, Caps caps) m_ids[agentID]++; else { - Random rnd = new Random(Environment.TickCount); - m_ids[agentID] = rnd.Next(30000000); + m_ids[agentID] = Random.Shared.Next(30000000); } } } @@ -391,21 +385,19 @@ public void OnRegisterCaps(UUID agentID, Caps caps) lock (m_AvatarQueueUUIDMapping) { // Its reuse caps path not queues those are been reused already - if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + if (m_AvatarQueueUUIDMapping.TryGetValue(agentID, out eventQueueGetUUID)) { m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); - eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; lock (m_ids) { // change to negative numbers so they are changed at end of sending first marker // old data on a queue may be sent on a response for a new caps // but at least will be sent with coerent IDs - if (m_ids.ContainsKey(agentID)) - m_ids[agentID] = -m_ids[agentID]; + if (m_ids.TryGetValue(agentID, out int previd)) + m_ids[agentID] = -previd; else { - Random rnd = new Random(Environment.TickCount); - m_ids[agentID] = -rnd.Next(30000000); + m_ids[agentID] = -Random.Shared.Next(30000000); } } } @@ -415,12 +407,11 @@ public void OnRegisterCaps(UUID agentID, Caps caps) m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID; lock (m_ids) { - if (m_ids.ContainsKey(agentID)) - m_ids[agentID]++; + if (m_ids.TryGetValue(agentID, out int previd)) + m_ids[agentID] = ++previd; else { - Random rnd = new Random(Environment.TickCount); - m_ids.Add(agentID, rnd.Next(30000000)); + m_ids.Add(agentID, Random.Shared.Next(30000000)); } } } @@ -433,7 +424,7 @@ public void OnRegisterCaps(UUID agentID, Caps caps) new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, VIEWERKEEPALIVE)); } - public bool HasEvents(UUID requestID, UUID agentID) + public bool HasEvents(UUID _, UUID agentID) { Queue queue = GetQueue(agentID); if (queue != null) @@ -454,12 +445,9 @@ public bool HasEvents(UUID requestID, UUID agentID) /// Element containing message private void LogOutboundDebugMessage(OSD element, UUID agentId) { - if (element is OSDMap) + if (element is OSDMap ev) { - OSDMap ev = (OSDMap)element; - m_log.DebugFormat( - "Eq OUT {0,-30} to {1,-20} {2,-20}", - ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.Name); + m_log.Debug($"Eq OUT {ev["message"],-30} to {m_scene.GetScenePresence(agentId).Name,-20} {m_scene.Name,-20}"); } } @@ -468,16 +456,16 @@ public void Drop(UUID requestID, UUID pAgentId) // do nothing, in last case http server will do it } - private readonly byte[] EventHeader = osUTF8.GetASCIIBytes("events"); + private static readonly byte[] EventHeader = osUTF8.GetASCIIBytes("events"); public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) - m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name); + m_log.Warn($"POLLED FOR EQ MESSAGES BY {pAgentId} in {m_scene.Name}"); Queue queue = GetQueue(pAgentId); - if (queue == null) - return NoAgent(requestID, pAgentId); + if (queue is null) + return NoAgent(); byte[] element = null; List elements; @@ -507,7 +495,7 @@ public Hashtable GetEvents(UUID requestID, UUID pAgentId) element = queue.Dequeue(); // add elements until a marker is found // so they get into a response - if (element == null) + if (element is null) break; if (DebugLevel > 0) @@ -520,10 +508,9 @@ public Hashtable GetEvents(UUID requestID, UUID pAgentId) lock (m_ids) { - if (element == null && negativeID) + if (element is null && negativeID) { - Random rnd = new Random(Environment.TickCount); - m_ids[pAgentId] = rnd.Next(30000000); + m_ids[pAgentId] = Random.Shared.Next(30000000); } else m_ids[pAgentId] = thisID + 1; @@ -542,7 +529,7 @@ public Hashtable GetEvents(UUID requestID, UUID pAgentId) elements.Add(element); totalSize += element.Length; - Hashtable responsedata = new Hashtable + Hashtable responsedata = new() { ["int_response_code"] = 200, ["content_type"] = "application/xml" @@ -564,26 +551,20 @@ public Hashtable GetEvents(UUID requestID, UUID pAgentId) return responsedata; } - public Hashtable NoEvents(UUID requestID, UUID agentID) + public Hashtable NoEvents(UUID _, UUID agentID) { - Hashtable responsedata = new Hashtable(); - Queue queue = GetQueue(agentID); - if (queue == null) + return new Hashtable() { - responsedata["int_response_code"] = (int)HttpStatusCode.NotFound; - return responsedata; - } - responsedata["int_response_code"] = (int)HttpStatusCode.BadGateway; - return responsedata; + ["int_response_code"] = GetQueue(agentID) == null ? (int)HttpStatusCode.NotFound : (int)HttpStatusCode.BadGateway + }; } - public Hashtable NoAgent(UUID requestID, UUID agentID) + public static Hashtable NoAgent() { - Hashtable responsedata = new Hashtable + return new Hashtable() { ["int_response_code"] = (int)HttpStatusCode.NotFound }; - return responsedata; } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs deleted file mode 100644 index 16b341a2dce..00000000000 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Text; -using log4net.Config; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Packets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.ClientStack.Linden; -using OpenSim.Region.CoreModules.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ClientStack.Linden.Tests -{ - [TestFixture] - public class EventQueueTests : OpenSimTestCase - { - private TestScene m_scene; - private EventQueueGetModule m_eqgMod; - private NPCModule m_npcMod; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - uint port = 9999; - - // This is an unfortunate bit of clean up we have to do because MainServer manages things through static - // variables and the VM is not restarted between tests. - MainServer.RemoveHttpServer(port); - - BaseHttpServer server = new BaseHttpServer(port, false, "","",""); - MainServer.AddHttpServer(server); - MainServer.Instance = server; - - IConfigSource config = new IniConfigSource(); - config.AddConfig("Startup"); - - CapabilitiesModule capsModule = new CapabilitiesModule(); - m_eqgMod = new EventQueueGetModule(); - - // For NPC test support - config.AddConfig("NPC"); - config.Configs["NPC"].Set("Enabled", "true"); - m_npcMod = new NPCModule(); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); - } - - [Test] - public void TestAddForClient() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - - // TODO: Add more assertions for the other aspects of event queues - Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(1)); - } - - [Test] - public void TestRemoveForClient() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID spId = TestHelpers.ParseTail(0x1); - - SceneHelpers.AddScenePresence(m_scene, spId); - m_scene.CloseAgent(spId, false); - - // TODO: Add more assertions for the other aspects of event queues - Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); - } - - [Test] - public void TestEnqueueMessage() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - - string messageName = "TestMessage"; - - m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID); - - Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); - - // initial queue as null events -// eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); - if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK) - { - eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); - if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK) - eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); - } - - Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); - -// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); - string data = String.Empty; - if(eventsResponse["bin_response_data"] != null) - data = Encoding.UTF8.GetString((byte[])eventsResponse["bin_response_data"]); - - OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml(data); - OSDArray eventsOsd = (OSDArray)rawOsd["events"]; - - bool foundUpdate = false; - foreach (OSD osd in eventsOsd) - { - OSDMap eventOsd = (OSDMap)osd; - - if (eventOsd["message"] == messageName) - foundUpdate = true; - } - - Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName)); - } - - /// - /// Test an attempt to put a message on the queue of a user that is not in the region. - /// - [Test] - public void TestEnqueueMessageNoUser() - { - TestHelpers.InMethod(); - TestHelpers.EnableLogging(); - - string messageName = "TestMessage"; - - m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1)); - - Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1)); - - Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.NotFound)); - } - - /// - /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour. - /// - [Test] - public void TestEnqueueMessageToNpc() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID npcId - = m_npcMod.CreateNPC( - "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); - - ScenePresence npc = m_scene.GetScenePresence(npcId); - - string messageName = "TestMessage"; - - m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID); - - Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID); - - Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.NotFound)); - } - } -} diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchLibDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchLibDescModule.cs index bfa90c8f626..7bb39e4c6c6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/FetchLibDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchLibDescModule.cs @@ -59,7 +59,7 @@ class APollRequest public OSHttpRequest request; } - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Control whether requests will be processed asynchronously. @@ -190,13 +190,13 @@ public PollServiceInventoryEventArgs(FetchLibDescModule module, string url, UUID { m_module = module; - HasEvents = (requestID, y) => + HasEvents = delegate (UUID requestID, UUID _) { lock (responses) return responses.ContainsKey(requestID); }; - Drop = (requestID, y) => + Drop = delegate (UUID requestID, UUID _) { lock (responses) { @@ -206,7 +206,7 @@ public PollServiceInventoryEventArgs(FetchLibDescModule module, string url, UUID } }; - GetEvents = (requestID, y) => + GetEvents = delegate (UUID requestID, UUID _) { lock (responses) { @@ -221,7 +221,7 @@ public PollServiceInventoryEventArgs(FetchLibDescModule module, string url, UUID } }; - Request = (requestID, request) => + Request = delegate(UUID requestID, OSHttpRequest request) { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; @@ -231,7 +231,7 @@ public PollServiceInventoryEventArgs(FetchLibDescModule module, string url, UUID return null; }; - NoEvents = (x, y) => + NoEvents = delegate (UUID _, UUID _) { Hashtable response = new Hashtable(); response["int_response_code"] = 500; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetAssetsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetAssetsModule.cs index 7a0915d0403..8996b37693d 100755 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetAssetsModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetAssetsModule.cs @@ -199,7 +199,7 @@ public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAss m_scene = scene; m_hgassets = HGAssetSVC; - HasEvents = (requestID, agentID) => + HasEvents = delegate(UUID requestID, UUID _) { lock (responses) { @@ -207,7 +207,7 @@ public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAss } }; - Drop = (requestID, y) => + Drop = delegate(UUID requestID, UUID _) { lock (responses) { @@ -217,47 +217,48 @@ public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAss } }; - GetEvents = (requestID, y) => + GetEvents = delegate(UUID requestID, UUID _) { lock (responses) { - try + if(responses.Remove(requestID, out APollResponse apr)) { - OSHttpResponse response = responses[requestID].osresponse; + OSHttpResponse response = apr.osresponse; if (response.Priority < 0) response.Priority = 0; - Hashtable lixo = new Hashtable(1); - lixo["h"] = response; + Hashtable lixo = new() + { + ["h"] = response + }; return lixo; } - finally - { - responses.Remove(requestID); - } } + return new Hashtable(); }; - // x is request id, y is request data hashtable - Request = (requestID, request) => + + Request = delegate (UUID requestID, OSHttpRequest request) { - APollRequest reqinfo = new APollRequest(); - reqinfo.thepoll = this; - reqinfo.reqID = requestID; - reqinfo.request = request; + APollRequest reqinfo = new() + { + thepoll = this, + reqID = requestID, + request = request + }; m_workerpool.Enqueue(reqinfo); return null; }; // this should never happen except possible on shutdown - NoEvents = (x, y) => + NoEvents = delegate (UUID _, UUID _) { /* - lock (requests) - { - Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); - requests.Remove(request); - } + lock (requests) + { + Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); + requests.Remove(request); + } */ Hashtable response = new Hashtable(); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index e10db8d5dfa..b9128797110 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs @@ -334,8 +334,6 @@ public void ProcessAdd(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, obj.InvalidateDeepEffectivePerms(); - m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); - httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.RawBuffer = Util.UTF8NBGetbytes(String.Format("local_id{0}", ConvertUintToBytes(obj.LocalId))); } @@ -348,7 +346,7 @@ private uint ReadUIntVal(OSD obj) return Utils.BytesToUInt(tmp); } - private string ConvertUintToBytes(uint val) + private static string ConvertUintToBytes(uint val) { byte[] resultbytes = Utils.UIntToBytes(val); if (BitConverter.IsLittleEndian) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index d3fe7537422..a0ebeadfbf3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs @@ -26,27 +26,20 @@ */ using System; -using System.Collections; using System.Net; using System.Reflection; -using System.IO; -using System.Web; using Mono.Addins; using log4net; using Nini.Config; using OpenMetaverse; -using OpenMetaverse.StructuredData; using OpenMetaverse.Messages.Linden; using OpenSim.Framework; -using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using OSD = OpenMetaverse.StructuredData.OSD; using OSDMap = OpenMetaverse.StructuredData.OSDMap; -using OpenSim.Framework.Capabilities; using ExtraParamType = OpenMetaverse.ExtraParamType; namespace OpenSim.Region.ClientStack.Linden @@ -145,7 +138,7 @@ public void ProcessAdd(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, try { - Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); + Vector3 pos = avatar.AbsolutePosition + Vector3.UnitXRotated(avatar.Rotation); Quaternion rot = Quaternion.Identity; Vector3 rootpos = Vector3.Zero; @@ -300,7 +293,7 @@ public void ProcessAdd(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, rootGroup.LinkToGroup(allparts[j]); } - rootGroup.ScheduleGroupForFullAnimUpdate(); + rootGroup.ScheduleGroupForUpdate(PrimUpdateFlags.FullUpdatewithAnimMatOvr); httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.RawBuffer = Util.UTF8NBGetbytes(String.Format("local_id{0}", ConvertUintToBytes(allparts[0].LocalId))); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.Tests.csproj b/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.Tests.csproj index 8ccdcf9dee7..9a394b5b3df 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.Tests.csproj +++ b/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.Tests.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 diff --git a/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.csproj b/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.csproj index a1e6764f6bc..522ab5cac3e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.csproj +++ b/OpenSim/Region/ClientStack/Linden/Caps/OpenSim.Region.ClientStack.LindenCaps.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.ClientStack.LindenCaps http://opensimulator.org OpenSim @@ -46,5 +46,6 @@ + \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs index 4a92ae98ecb..56e840b0e00 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs @@ -113,14 +113,10 @@ public void Close() { } public void RegisterCaps(UUID agentID, Caps caps) { string capPath = "/" + UUID.Random(); - caps.RegisterSimpleHandler("ServerReleaseNotes", - new SimpleStreamHandler(capPath, delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - ProcessServerReleaseNotes(httpResponse); - })); + caps.RegisterSimpleHandler("ServerReleaseNotes", new SimpleStreamHandler(capPath, ProcessServerReleaseNotes)); } - private void ProcessServerReleaseNotes(IOSHttpResponse httpResponse) + public void ProcessServerReleaseNotes(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.Redirect(m_ServerReleaseNotesURL); } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index fa0c9bfac3d..65c24798632 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -60,8 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] public class SimulatorFeaturesModule : INonSharedRegionModule, ISimulatorFeaturesModule { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; @@ -70,13 +69,13 @@ public class SimulatorFeaturesModule : INonSharedRegionModule, ISimulatorFeature /// /// Simulator features /// - private OSDMap m_features = new OSDMap(); + private readonly OSDMap m_features = new(); private bool m_ExportSupported = false; - private bool m_doScriptSyntax; + private bool m_doScriptSyntax = true; - static private object m_scriptSyntaxLock = new object(); + static private readonly object m_scriptSyntaxLock = new(); static private UUID m_scriptSyntaxID = UUID.Zero; static private byte[] m_scriptSyntaxXML = null; @@ -85,7 +84,6 @@ public class SimulatorFeaturesModule : INonSharedRegionModule, ISimulatorFeature public void Initialise(IConfigSource source) { IConfig config = source.Configs["SimulatorFeatures"]; - m_doScriptSyntax = true; if (config != null) { m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported); @@ -135,39 +133,48 @@ private void AddDefaultFeatures() { lock (m_features) { - m_features["MeshRezEnabled"] = true; - m_features["MeshUploadEnabled"] = true; - m_features["MeshXferEnabled"] = true; + m_features["AnimatedObjects"] = new OSDMap() + { + ["AnimatedObjectMaxTris"] = OSD.FromInteger(150000), + ["MaxAgentAnimatedObjectAttachments"] = OSD.FromInteger(2) + }; m_features["BakesOnMeshEnabled"] = true; - m_features["PhysicsMaterialsEnabled"] = true; - OSDMap typesMap = new OSDMap(); - typesMap["convex"] = true; - typesMap["none"] = true; - typesMap["prim"] = true; - m_features["PhysicsShapeTypes"] = typesMap; - if(m_doScriptSyntax && !m_scriptSyntaxID.IsZero()) m_features["LSLSyntaxId"] = OSD.FromUUID(m_scriptSyntaxID); - OSDMap meshAnim = new OSDMap(); - meshAnim["AnimatedObjectMaxTris"] = OSD.FromInteger(150000); - meshAnim["MaxAgentAnimatedObjectAttachments"] = OSD.FromInteger(2); - m_features["AnimatedObjects"] = meshAnim; - m_features["MaxAgentAttachments"] = OSD.FromInteger(Constants.MaxAgentAttachments); + m_features["MaxAgentGroups"] = OSD.FromInteger(Constants.MaxAgentGroups); m_features["MaxAgentGroupsBasic"] = OSD.FromInteger(Constants.MaxAgentGroups); m_features["MaxAgentGroupsPremium"] = OSD.FromInteger(Constants.MaxAgentGroups); - // Extra information for viewers that want to use it - OSDMap extrasMap; - if(m_features.TryGetValue("OpenSimExtras", out OSD oe)) + m_features["MaxEstateAccessIds"] = OSD.FromInteger(Constants.MaxEstateAccessIds); + m_features["MaxEstateManagers"] = OSD.FromInteger(Constants.MaxEstateManagers); + + m_features["MaxTextureResolution"] = OSD.FromInteger(Constants.MaxTextureResolution); + + m_features["MeshRezEnabled"] = true; + m_features["MeshUploadEnabled"] = true; + m_features["MeshXferEnabled"] = true; + + /* + m_features["MirrorsEnabled"] = false; + m_features["PBRMaterialSwatchEnabled"] = false; + m_features["PBRTerrainEnabled"] = false; + */ + + m_features["PhysicsMaterialsEnabled"] = true; + + m_features["PhysicsShapeTypes"] = new OSDMap() { - extrasMap = oe as OSDMap; - } - else - extrasMap = new OSDMap(); + ["convex"] = true, + ["none"] = true, + ["prim"] = true + }; + + // Extra information for viewers that want to use it + OSDMap extrasMap = m_features.TryGetValue("OpenSimExtras", out OSD oe) ? oe as OSDMap : new OSDMap(); extrasMap["AvatarSkeleton"] = true; extrasMap["AnimationSet"] = true; @@ -215,9 +222,9 @@ public void AddOpenSimExtraFeature(string name, OSD value) else { extrasMap = new OSDMap(); + m_features["OpenSimExtras"] = extrasMap; } extrasMap[name] = value; - m_features["OpenSimExtras"] = extrasMap; } } @@ -238,12 +245,19 @@ public bool TryGetOpenSimExtraFeature(string name, out OSD value) value = null; lock (m_features) { - if (!m_features.TryGetValue("OpenSimExtras", out OSD extra)) - return false; - if(!(extra is OSDMap)) - return false; - return (extra as OSDMap).TryGetValue(name, out value); + if (m_features.TryGetValue("OpenSimExtras", out OSD extra) && extra is OSDMap exm) + return exm.TryGetValue(name, out value); } + return false; + } + public bool OpenSimExtraFeatureContains(string name) + { + lock (m_features) + { + if (m_features.TryGetValue("OpenSimExtras", out OSD extra) && extra is OSDMap exm) + return exm.ContainsKey(name); + } + return false; } public OSDMap GetFeatures() @@ -378,7 +392,7 @@ private void GetGridExtraFeatures(Scene scene) default: if (key == "ExportSupported") { - bool.TryParse(val, out m_ExportSupported); + _ = bool.TryParse(val, out m_ExportSupported); extrasMap[key] = m_ExportSupported; } else @@ -412,20 +426,18 @@ private void ReadScriptSyntax() { using (StreamReader sr = File.OpenText("ScriptSyntax.xml")) { - StringBuilder sb = new StringBuilder(400*1024); - - string s=""; + StringBuilder sb = new(400*1024); char[] trimc = new char[] {' ','\t', '\n', '\r'}; - s = sr.ReadLine(); - if(s == null) + string s = sr.ReadLine(); + if(s is null) return; s = s.Trim(trimc); - UUID id; - if(!UUID.TryParse(s,out id)) + + if(!UUID.TryParse(s, out UUID id)) return; - while ((s = sr.ReadLine()) != null) + while ((s = sr.ReadLine()) is not null) { s = s.Trim(trimc); if (String.IsNullOrEmpty(s) || s.StartsWith(" {2},{3}", posmap.Key.Key, posmap.Key.Value, posmap.Value.Key, posmap.Value.Value); - int nl = posmap.Value.Key + line - posmap.Key.Key; // New, translated LSL line and column. - int nc = posmap.Value.Value + col - posmap.Key.Value; - // Keep going until we find the first point passed line,col. - if (posmap.Key.Key > line) - { - //m_log.DebugFormat("[Compiler]: Line is larger than requested {0},{1}, returning {2},{3}", line, col, l, c); - if (pl < line) - { - //m_log.DebugFormat("[Compiler]: Previous line ({0}) is less than requested line ({1}), setting column to 1.", pl, line); - c = 1; - } - break; - } - if (posmap.Key.Key == line && posmap.Key.Value > col) - { - // Never move l,c backwards. - if (nl > l || (nl == l && nc > c)) - { - //m_log.DebugFormat("[Compiler]: Using offset relative to this: {0} + {1} - {2}, {3} + {4} - {5} = {6}, {7}", - // posmap.Value.Key, line, posmap.Key.Key, posmap.Value.Value, col, posmap.Key.Value, nl, nc); - l = nl; - c = nc; - } - //m_log.DebugFormat("[Compiler]: Column is larger than requested {0},{1}, returning {2},{3}", line, col, l, c); - break; - } - pl = posmap.Key.Key; - l = posmap.Value.Key; - c = posmap.Value.Value; - } - return new KeyValuePair(l, c); - } - - string ReplaceTypes(string message) - { - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString", - "string"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger", - "integer"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat", - "float"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.list", - "list"); - - return message; - } - - private static void WriteMapFile(string filename, Dictionary, KeyValuePair> linemap) - { - StringBuilder mapbuilder = new StringBuilder(1024); - - foreach (KeyValuePair, KeyValuePair> kvp in linemap) - { - KeyValuePair k = kvp.Key; - KeyValuePair v = kvp.Value; - mapbuilder.Append(String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value)); - } - - Byte[] mapbytes = Encoding.ASCII.GetBytes(mapbuilder.ToString()); - - using (FileStream mfs = File.Create(filename)) - mfs.Write(mapbytes, 0, mapbytes.Length); - } - - private static Dictionary, KeyValuePair> ReadMapFile(string filename) - { - Dictionary, KeyValuePair> linemap; - try - { - using (StreamReader r = File.OpenText(filename)) - { - linemap = new Dictionary, KeyValuePair>(); - - string line; - while ((line = r.ReadLine()) != null) - { - String[] parts = line.Split(new Char[] { ',' }); - int kk = System.Convert.ToInt32(parts[0]); - int kv = System.Convert.ToInt32(parts[1]); - int vk = System.Convert.ToInt32(parts[2]); - int vv = System.Convert.ToInt32(parts[3]); - - KeyValuePair k = new KeyValuePair(kk, kv); - KeyValuePair v = new KeyValuePair(vk, vv); - - linemap[k] = v; - } - } - } - catch - { - linemap = new Dictionary, KeyValuePair>(); - } - - return linemap; - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs deleted file mode 100644 index 076caad2611..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/ICodeConverter.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* 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. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSimulator Project 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 DEVELOPERS 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 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; - -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools -{ - public interface ICodeConverter - { - string Convert(string script); - void Convert(string script, StringBuilder sb); - string[] GetWarnings(); - void Clear(); - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs deleted file mode 100644 index 0585f8b05e7..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using log4net; -using Tools; - -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools -{ - public class LSL2CSCodeTransformer - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private SYMBOL m_astRoot = null; - private static Dictionary m_datatypeLSL2OpenSim = null; - - /// - /// Pass the new CodeTranformer an abstract syntax tree. - /// - /// The root node of the AST. - public LSL2CSCodeTransformer(SYMBOL astRoot) - { - m_astRoot = astRoot; - - // let's populate the dictionary - if (null == m_datatypeLSL2OpenSim) - { - m_datatypeLSL2OpenSim = new Dictionary(); - m_datatypeLSL2OpenSim.Add("integer", "LSL_Types.LSLInteger"); - m_datatypeLSL2OpenSim.Add("float", "LSL_Types.LSLFloat"); - //m_datatypeLSL2OpenSim.Add("key", "LSL_Types.key"); // key doesn't seem to be used - m_datatypeLSL2OpenSim.Add("key", "LSL_Types.LSLString"); - m_datatypeLSL2OpenSim.Add("string", "LSL_Types.LSLString"); - m_datatypeLSL2OpenSim.Add("vector", "LSL_Types.Vector3"); - m_datatypeLSL2OpenSim.Add("rotation", "LSL_Types.Quaternion"); - m_datatypeLSL2OpenSim.Add("list", "LSL_Types.list"); - } - } - - /// - /// Transform the code in the AST we have. - /// - /// The root node of the transformed AST - public SYMBOL Transform() - { - foreach (SYMBOL s in m_astRoot.kids) - TransformNode(s); - - return m_astRoot; - } - - /// - /// Recursively called to transform each type of node. Will transform this - /// node, then all it's children. - /// - /// The current node to transform. - private void TransformNode(SYMBOL s) - { -// m_log.DebugFormat("[LSL2CSCODETRANSFORMER]: Tranforming node {0}", s); - - // make sure to put type lower in the inheritance hierarchy first - // ie: since IdentConstant and StringConstant inherit from Constant, - // put IdentConstant and StringConstant before Constant - if (s is Declaration) - ((Declaration) s).Datatype = m_datatypeLSL2OpenSim[((Declaration) s).Datatype]; - else if (s is Constant) - ((Constant) s).Type = m_datatypeLSL2OpenSim[((Constant) s).Type]; - else if (s is TypecastExpression) - ((TypecastExpression) s).TypecastType = m_datatypeLSL2OpenSim[((TypecastExpression) s).TypecastType]; - else if (s is GlobalFunctionDefinition && "void" != ((GlobalFunctionDefinition) s).ReturnType) // we don't need to translate "void" - ((GlobalFunctionDefinition) s).ReturnType = m_datatypeLSL2OpenSim[((GlobalFunctionDefinition) s).ReturnType]; - - for (int i = 0; i < s.kids.Count; i++) - { - // It's possible that a child is null, for instance when the - // assignment part in a for-loop is left out, ie: - // - // for (; i < 10; i++) - // { - // ... - // } - // - // We need to check for that here. - if (null != s.kids[i]) - { -// m_log.Debug("[LSL2CSCODETRANSFORMER]: Moving down level"); - - if (!(s is Assignment || s is ArgumentDeclarationList) && s.kids[i] is Declaration) - AddImplicitInitialization(s, i); - - TransformNode((SYMBOL) s.kids[i]); - -// m_log.Debug("[LSL2CSCODETRANSFORMER]: Moving up level"); - } - } - } - - /// - /// Replaces an instance of the node at s.kids[didx] with an assignment - /// node. The assignment node has the Declaration node on the left hand - /// side and a default initializer on the right hand side. - /// - /// - /// The node containing the Declaration node that needs replacing. - /// - /// Index of the Declaration node to replace. - private void AddImplicitInitialization(SYMBOL s, int didx) - { - // We take the kids for a while to play with them. - int sKidSize = s.kids.Count; - object [] sKids = new object[sKidSize]; - for (int i = 0; i < sKidSize; i++) - sKids[i] = s.kids.Pop(); - - // The child to be changed. - Declaration currentDeclaration = (Declaration) sKids[didx]; - - // We need an assignment node. - Assignment newAssignment = new Assignment(currentDeclaration.yyps, - currentDeclaration, - GetZeroConstant(currentDeclaration.yyps, currentDeclaration.Datatype), - "="); - sKids[didx] = newAssignment; - - // Put the kids back where they belong. - for (int i = 0; i < sKidSize; i++) - s.kids.Add(sKids[i]); - } - - /// - /// Generates the node structure required to generate a default - /// initialization. - /// - /// - /// Tools.Parser instance to use when instantiating nodes. - /// - /// String describing the datatype. - /// - /// A SYMBOL node conaining the appropriate structure for intializing a - /// constantType. - /// - private SYMBOL GetZeroConstant(Parser p, string constantType) - { - switch (constantType) - { - case "integer": - return new Constant(p, constantType, "0"); - case "float": - return new Constant(p, constantType, "0.0"); - case "string": - case "key": - return new Constant(p, constantType, ""); - case "list": - ArgumentList al = new ArgumentList(p); - return new ListConstant(p, al); - case "vector": - Constant vca = new Constant(p, "float", "0.0"); - Constant vcb = new Constant(p, "float", "0.0"); - Constant vcc = new Constant(p, "float", "0.0"); - ConstantExpression vcea = new ConstantExpression(p, vca); - ConstantExpression vceb = new ConstantExpression(p, vcb); - ConstantExpression vcec = new ConstantExpression(p, vcc); - return new VectorConstant(p, vcea, vceb, vcec); - case "rotation": - Constant rca = new Constant(p, "float", "0.0"); - Constant rcb = new Constant(p, "float", "0.0"); - Constant rcc = new Constant(p, "float", "0.0"); - Constant rcd = new Constant(p, "float", "1.0"); - ConstantExpression rcea = new ConstantExpression(p, rca); - ConstantExpression rceb = new ConstantExpression(p, rcb); - ConstantExpression rcec = new ConstantExpression(p, rcc); - ConstantExpression rced = new ConstantExpression(p, rcd); - return new RotationConstant(p, rcea, rceb, rcec, rced); - default: - return null; // this will probably break stuff - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/OpenSim.Region.ScriptEngine.Shared.CodeTools.csproj b/OpenSim/Region/ScriptEngine/Shared/CodeTools/OpenSim.Region.ScriptEngine.Shared.CodeTools.csproj index 46e51ec14e2..dc7b1851b3c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/OpenSim.Region.ScriptEngine.Shared.CodeTools.csproj +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/OpenSim.Region.ScriptEngine.Shared.CodeTools.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.ScriptEngine.Shared.CodeTools http://opensimulator.org OpenSim diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs deleted file mode 100644 index 304cd81a0e9..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +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("OpenSim.Region.ScriptEngine.Shared.CodeTools")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://opensimulator.org")] -[assembly: AssemblyProduct("OpenSim")] -[assembly: AssemblyCopyright("OpenSimulator developers")] -[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("fd446fb3-3a21-471b-951c-68b9eb6ef8e5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] - diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs deleted file mode 100644 index a9f3283cb62..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ /dev/null @@ -1,1809 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using System.Text.RegularExpressions; -using NUnit.Framework; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests -{ - /// - /// Tests the LSL compiler, both the code generation and transformation. - /// Each test has some LSL code as input and C# code as expected output. - /// The generated C# code is compared against the expected C# code. - /// - [TestFixture] - public class CSCodeGeneratorTest : OpenSimTestCase - { - [Test] - public void TestDefaultState() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - } -} -"; - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestCustomState() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - } -} - -state another_state -{ - no_sensor() - { - } -} -"; - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n }" + - "\n public void another_state_event_no_sensor()" + - "\n {" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestEventWithArguments() - { - TestHelpers.InMethod(); - - string input = @"default -{ - at_rot_target(integer tnum, rotation targetrot, rotation ourrot) - { - } -} -"; - string expected = - "\n public void default_event_at_rot_target(LSL_Types.LSLInteger tnum, LSL_Types.Quaternion targetrot, LSL_Types.Quaternion ourrot)" + - "\n {" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIntegerDeclaration() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - integer x; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestLoneIdent() - { - TestHelpers.InMethod(); - - // A lone ident should be removed completely as it's an error in C# - // (MONO at least). - string input = @"default -{ - touch_start(integer num_detected) - { - integer x; - x; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestAssignments() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - string y; - integer x = 14; - y = ""Hello""; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLString y = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14);" + - "\n y = new LSL_Types.LSLString(\"Hello\");" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestAdditionSubtractionOperator() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - integer y = -3; - integer x = 14 + 6; - y = 12 +45+20+x + 23 + 1 + x + y; - y = 12 + -45 + - 20 + x + 23 + -1 + x + y; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)\n" + - " {\n" + - " LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3);\n" + - " LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);\n" + - " y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x + new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1) + x + y;\n" + - " y = new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x + new LSL_Types.LSLInteger(23) + -new LSL_Types.LSLInteger(1) + x + y;\n" + - " }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestStrings() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - llOwnerSay(""Testing, 1, 2, 3""); - llSay(0, ""I can hear you!""); - some_custom_function(1, 2, 3 +x, 4, ""five"", ""arguments""); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n llOwnerSay(new LSL_Types.LSLString(\"Testing, 1, 2, 3\"));" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"I can hear you!\"));" + - "\n some_custom_function(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3) + x, new LSL_Types.LSLInteger(4), new LSL_Types.LSLString(\"five\"), new LSL_Types.LSLString(\"arguments\"));" + - "\n }" + - "\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestBinaryExpression() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - integer y; - integer x = 14 + 6; - y = 12 - 3; - y = 12 && 3; - y = 12 || 3; - y = 12 * 3; - y = 12 / 3; - y = 12 | 3; - y = 12 & 3; - y = 12 % 3; - y = 12 + 45 - 20 * x / 23 | 1 & x + y; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" + - "\n y = new LSL_Types.LSLInteger(12) - new LSL_Types.LSLInteger(3);" + - "\n y = ((bool)(new LSL_Types.LSLInteger(12))) & ((bool)(new LSL_Types.LSLInteger(3)));" + - "\n y = ((bool)(new LSL_Types.LSLInteger(12))) | ((bool)(new LSL_Types.LSLInteger(3)));" + - "\n y = new LSL_Types.LSLInteger(12) * new LSL_Types.LSLInteger(3);" + - "\n y = new LSL_Types.LSLInteger(12) / new LSL_Types.LSLInteger(3);" + - "\n y = new LSL_Types.LSLInteger(12) | new LSL_Types.LSLInteger(3);" + - "\n y = new LSL_Types.LSLInteger(12) & new LSL_Types.LSLInteger(3);" + - "\n y = new LSL_Types.LSLInteger(12) % new LSL_Types.LSLInteger(3);" + - "\n y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) - new LSL_Types.LSLInteger(20) * x / new LSL_Types.LSLInteger(23) | new LSL_Types.LSLInteger(1) & x + y;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestFloatConstants() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - float y = 1.1; - y = 1.123E3; - y = 1.123e3; - y = 1.123E+3; - y = 1.123e+3; - y = 1.123E-3; - y = 1.123e-3; - y = .4; - y = -1.123E3; - y = -1.123e3; - y = -1.123E+3; - y = -1.123e+3; - y = -1.123E-3; - y = -1.123e-3; - y = -.4; - y = 12.3 + -1.45E3 - 1.20e-2; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLFloat y = new LSL_Types.LSLFloat(1.1);" + - "\n y = new LSL_Types.LSLFloat(1.123E3);" + - "\n y = new LSL_Types.LSLFloat(1.123e3);" + - "\n y = new LSL_Types.LSLFloat(1.123E+3);" + - "\n y = new LSL_Types.LSLFloat(1.123e+3);" + - "\n y = new LSL_Types.LSLFloat(1.123E-3);" + - "\n y = new LSL_Types.LSLFloat(1.123e-3);" + - "\n y = new LSL_Types.LSLFloat(.4);" + - "\n y = -new LSL_Types.LSLFloat(1.123E3);" + - "\n y = -new LSL_Types.LSLFloat(1.123e3);" + - "\n y = -new LSL_Types.LSLFloat(1.123E+3);" + - "\n y = -new LSL_Types.LSLFloat(1.123e+3);" + - "\n y = -new LSL_Types.LSLFloat(1.123E-3);" + - "\n y = -new LSL_Types.LSLFloat(1.123e-3);" + - "\n y = -new LSL_Types.LSLFloat(.4);" + - "\n y = new LSL_Types.LSLFloat(12.3) + -new LSL_Types.LSLFloat(1.45E3) - new LSL_Types.LSLFloat(1.20e-2);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestComments() - { - TestHelpers.InMethod(); - - string input = @"// this test tests comments -default -{ - touch_start(integer num_detected) // this should be stripped - { - // fill in code here... - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestStringsWithEscapedQuotesAndComments() - { - TestHelpers.InMethod(); - - string input = @"// this test tests strings, with escaped quotes and comments in strings -default -{ - touch_start(integer num_detected) - { - string s1 = ""this is a string.""; - string s2 = ""this is a string ""+""with an escaped \"" inside it.""; - s1 = s2+"" and this ""+""is a string with // comments.""; - - string onemore = ""[\^@]""; - - string multiline = ""Good evening Sir, - my name is Steve. - I come from a rough area. - I used to be addicted to crack - but now I am off it and trying to stay clean. - That is why I am selling magazine subscriptions.""; // http://www.imdb.com/title/tt0151804/quotes - } -} -"; - - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLString s1 = new LSL_Types.LSLString(\"this is a string.\");" + - "\n LSL_Types.LSLString s2 = new LSL_Types.LSLString(\"this is a string \") + new LSL_Types.LSLString(\"with an escaped \\\" inside it.\");" + - "\n s1 = s2 + new LSL_Types.LSLString(\" and this \") + new LSL_Types.LSLString(\"is a string with // comments.\");" + - "\n LSL_Types.LSLString onemore = new LSL_Types.LSLString(\"[\\^@]\");" + - "\n LSL_Types.LSLString multiline = new LSL_Types.LSLString(\"Good evening Sir,\\n my name is Steve.\\n I come from a rough area.\\n I used to be addicted to crack\\n but now I am off it and trying to stay clean.\\n That is why I am selling magazine subscriptions.\");" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestCStyleComments() - { - TestHelpers.InMethod(); - - string input = @"/* this test tests comments - of the C variety -*/ -default -{ - touch_start(integer /* you can't see me! */ num_detected) /* this should be stripped */ - { - /* - * fill - * in - * code - * here... - */ - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestGlobalDefinedFunctions() - { - TestHelpers.InMethod(); - - string input = @"// this test tests custom defined functions - -string onefunc() -{ - return ""Hi from onefunc()!""; -} - -twofunc(string s) -{ - llSay(1000, s); -} - -default -{ - touch_start(integer num_detected) - { - llSay(2000, onefunc()); - twofunc(); - } -} -"; - string expected = - "\n LSL_Types.LSLString onefunc()" + - "\n {" + - "\n return new LSL_Types.LSLString(\"Hi from onefunc()!\");" + - "\n }" + - "\n void twofunc(LSL_Types.LSLString s)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(1000), s);" + - "\n }" + - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(2000), onefunc());" + - "\n twofunc();" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestGlobalDeclaredVariables() - { - TestHelpers.InMethod(); - - string input = @"// this test tests custom defined functions and global variables - -string globalString; -integer globalInt = 14; -integer anotherGlobal = 20 * globalInt; - -string onefunc() -{ - globalString = "" ...and the global!""; - return ""Hi "" + - ""from "" + - ""onefunc()!"" + globalString; -} - -twofunc(string s) -{ - llSay(1000, s); -} - -default -{ - touch_start(integer num_detected) - { - llSay(2000, onefunc()); - twofunc(); - } -} -"; - string expected = - "\n LSL_Types.LSLString globalString = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" + - "\n LSL_Types.LSLInteger anotherGlobal = new LSL_Types.LSLInteger(20) * globalInt;" + - "\n LSL_Types.LSLString onefunc()" + - "\n {" + - "\n globalString = new LSL_Types.LSLString(\" ...and the global!\");" + - "\n return new LSL_Types.LSLString(\"Hi \") + new LSL_Types.LSLString(\"from \") + new LSL_Types.LSLString(\"onefunc()!\") + globalString;" + - "\n }" + - "\n void twofunc(LSL_Types.LSLString s)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(1000), s);" + - "\n }" + - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(2000), onefunc());" + - "\n twofunc();" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestMoreAssignments() - { - TestHelpers.InMethod(); - - string input = @"// this test tests +=, -=, *=, /=, %= - -string globalString; -integer globalInt = 14; - -string onefunc(string addition) -{ - globalInt -= 2; - - globalString += addition; - return ""Hi "" + - ""from "" + - ""onefunc()! "" + globalString; -} - -default -{ - touch_start(integer num_detected) - { - llSay(2000, onefunc()); - - integer x = 2; - x *= 3; - x /= 14 + -2; - x %= 10; - } -} -"; - string expected = - "\n LSL_Types.LSLString globalString = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" + - "\n LSL_Types.LSLString onefunc(LSL_Types.LSLString addition)" + - "\n {" + - "\n globalInt -= new LSL_Types.LSLInteger(2);" + - "\n globalString += addition;" + - "\n return new LSL_Types.LSLString(\"Hi \") + new LSL_Types.LSLString(\"from \") + new LSL_Types.LSLString(\"onefunc()! \") + globalString;" + - "\n }" + - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(2000), onefunc());" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(2);" + - "\n x *= new LSL_Types.LSLInteger(3);" + - "\n x /= new LSL_Types.LSLInteger(14) + -new LSL_Types.LSLInteger(2);" + - "\n x %= new LSL_Types.LSLInteger(10);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestVectorConstantNotation() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - vector y = <1.2, llGetMeAFloat(), 4.4>; - rotation x = <0.1, 0.1, one + 2, 0.9>; - - y = <0.1, 0.1, 1.1 - three - two+eight*8>; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.Vector3 y = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.2), llGetMeAFloat(), new LSL_Types.LSLFloat(4.4));" + - "\n LSL_Types.Quaternion x = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.1), one + new LSL_Types.LSLInteger(2), new LSL_Types.LSLFloat(0.9));" + - "\n y = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(1.1) - three - two + eight * new LSL_Types.LSLInteger(8));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestVectorMemberAccess() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - vector y = <1.2, llGetMeAFloat(), 4.4>; - x = y.x + 1.1; - y.x = 1.1; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.Vector3 y = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.2), llGetMeAFloat(), new LSL_Types.LSLFloat(4.4));" + - "\n x = y.x + new LSL_Types.LSLFloat(1.1);" + - "\n y.x = new LSL_Types.LSLFloat(1.1);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestExpressionInParentheses() - { - TestHelpers.InMethod(); - - string input = @"default -{ - touch_start(integer num_detected) - { - integer y = -3; - integer x = 14 + 6; - y = 12 +45+20+x + (23 + 1) + x + y; - y = (12 + -45 + -20 + x + 23 )+ -1 + x + y; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" + - "\n y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + x + y;" + - "\n y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x + y;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIncrementDecrementOperator() - { - TestHelpers.InMethod(); - - string input = @"// here we'll test the ++ and -- operators - -default -{ - touch_start(integer num_detected) - { - integer y = -3; - integer x = 14 + 6; - y = 12 +45+20+x++ + (23 + 1) + ++x + -- y; - y = (12 + -45 + -20 + x-- + 23 )+ -1 + x -- + ++y; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" + - "\n y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x++ + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + ++x + --y;" + - "\n y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x-- + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x-- + ++y;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestLists() - { - TestHelpers.InMethod(); - - string input = @"// testing lists - -default -{ - touch_start(integer num_detected) - { - list l = []; - list m = [1, two, ""three"", <4.0, 4.0, 4.0>, 5 + 5]; - llCallSomeFunc(1, llAnotherFunc(), [1, 2, 3]); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.list l = new LSL_Types.list();" + - "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), two, new LSL_Types.LSLString(\"three\"), new LSL_Types.Vector3(new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0)), new LSL_Types.LSLInteger(5) + new LSL_Types.LSLInteger(5));" + - "\n llCallSomeFunc(new LSL_Types.LSLInteger(1), llAnotherFunc(), new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3)));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIfStatement() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string input = @"// let's test if statements - -default -{ - touch_start(integer num_detected) - { - integer x = 1; - - if (x) llSay(0, ""Hello""); - if (1) - { - llSay(0, ""Hi""); - integer r = 3; - return; - } - - if (f(x)) llSay(0, ""f(x) is true""); - else llSay(0, ""f(x) is false""); - - if (x + y) llSay(0, ""x + y is true""); - else if (y - x) llSay(0, ""y - x is true""); - else llSay(0, ""Who needs x and y anyway?""); - - if (x * y) llSay(0, ""x * y is true""); - else if (y / x) - { - llSay(0, ""uh-oh, y / x is true, exiting""); - return; - } - else llSay(0, ""Who needs x and y anyway?""); - - // and now for my last trick - if (x % y) llSay(0, ""x is true""); - else if (y & x) llSay(0, ""y is true""); - else if (z | x) llSay(0, ""z is true""); - else if (a * (b + x)) llSay(0, ""a is true""); - else if (b) llSay(0, ""b is true""); - else if (v) llSay(0, ""v is true""); - else llSay(0, ""Everything is lies!""); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n if (x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" + - "\n if (new LSL_Types.LSLInteger(1))" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" + - "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" + - "\n return ;" + - "\n }" + - "\n if (f(x))" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"f(x) is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"f(x) is false\"));" + - "\n if (x + y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x + y is true\"));" + - "\n else" + - "\n if (y - x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y - x is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" + - "\n if (x * y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x * y is true\"));" + - "\n else" + - "\n if (y / x)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"uh-oh, y / x is true, exiting\"));" + - "\n return ;" + - "\n }" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" + - "\n if (x % y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + - "\n else" + - "\n if (y & x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" + - "\n else" + - "\n if (z | x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" + - "\n else" + - "\n if (a * (b + x))" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" + - "\n else" + - "\n if (b)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"b is true\"));" + - "\n else" + - "\n if (v)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"v is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Everything is lies!\"));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIfElseStatement() - { - TestHelpers.InMethod(); - - string input = @"// let's test complex logical expressions - -default -{ - touch_start(integer num_detected) - { - integer x = 1; - integer y = 0; - - if (x && y) llSay(0, ""Hello""); - if (x || y) - { - llSay(0, ""Hi""); - integer r = 3; - return; - } - - if (x && y || z) llSay(0, ""x is true""); - else llSay(0, ""x is false""); - - if (x == y) llSay(0, ""x is true""); - else if (y < x) llSay(0, ""y is true""); - else llSay(0, ""Who needs x and y anyway?""); - - if (x > y) llSay(0, ""x is true""); - else if (y <= x) - { - llSay(0, ""uh-oh, y is true, exiting""); - return; - } - else llSay(0, ""Who needs x and y anyway?""); - - // and now for my last trick - if (x >= y) llSay(0, ""x is true""); - else if (y != x) llSay(0, ""y is true""); - else if (!z) llSay(0, ""z is true""); - else if (!(a && b)) llSay(0, ""a is true""); - else if (b) llSay(0, ""b is true""); - else if (v) llSay(0, ""v is true""); - else llSay(0, ""Everything is lies!""); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n if (((bool)(x)) & ((bool)(y)))" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" + - "\n if (((bool)(x)) | ((bool)(y)))" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" + - "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" + - "\n return ;" + - "\n }" + - "\n if (((bool)(((bool)(x)) & ((bool)(y)))) | ((bool)(z)))" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is false\"));" + - "\n if (x == y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + - "\n else" + - "\n if (y < x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" + - "\n if (x > y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + - "\n else" + - "\n if (y <= x)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"uh-oh, y is true, exiting\"));" + - "\n return ;" + - "\n }" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" + - "\n if (x >= y)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + - "\n else" + - "\n if (y != x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" + - "\n else" + - "\n if (!z)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" + - "\n else" + - "\n if (!(((bool)(a)) & ((bool)(b))))" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" + - "\n else" + - "\n if (b)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"b is true\"));" + - "\n else" + - "\n if (v)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"v is true\"));" + - "\n else" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Everything is lies!\"));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestWhileLoop() - { - TestHelpers.InMethod(); - - string input = @"// let's test while loops - -default -{ - touch_start(integer num_detected) - { - integer x = 1; - integer y = 0; - - while (x) llSay(0, ""To infinity, and beyond!""); - while (0 || (x && 0)) - { - llSay(0, ""Never say never.""); - return; - } - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n while (x)" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"To infinity, and beyond!\"));" + - "\n while (((bool)(new LSL_Types.LSLInteger(0))) | ((bool)((((bool)(x)) & ((bool)(new LSL_Types.LSLInteger(0)))))))" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Never say never.\"));" + - "\n return ;" + - "\n }" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestDoWhileLoop() - { - TestHelpers.InMethod(); - - string input = @"// let's test do-while loops - -default -{ - touch_start(integer num_detected) - { - integer x = 1; - integer y = 0; - - do llSay(0, ""And we're doing...""); - while (x); - - do - { - llSay(0, ""I like it here. I wish we could stay here forever.""); - y--; - } while (y); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n do" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"And we're doing...\"));" + - "\n while (x);" + - "\n do" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"I like it here. I wish we could stay here forever.\"));" + - "\n y--;" + - "\n }" + - "\n while (y);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestForLoop() - { - TestHelpers.InMethod(); - - string input = @"// let's test for loops - -default -{ - touch_start(integer num_detected) - { - integer x = 1; - integer y = 0; - - for (x = 10; x >= 0; x--) - { - llOwnerSay(""Launch in T minus "" + x); - IncreaseRocketPower(); - } - - for (x = 0, y = 6; y > 0 && x != y; x++, y--) llOwnerSay(""Hi "" + x + "", "" + y); - for (x = 0, y = 6; ! y; x++,y--) llOwnerSay(""Hi "" + x + "", "" + y); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n for (x = new LSL_Types.LSLInteger(10); x >= new LSL_Types.LSLInteger(0); x--)" + - "\n {" + - "\n llOwnerSay(new LSL_Types.LSLString(\"Launch in T minus \") + x);" + - "\n IncreaseRocketPower();" + - "\n }" + - "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); ((bool)(y > new LSL_Types.LSLInteger(0))) & ((bool)(x != y)); x++, y--)" + - "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" + - "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); !y; x++, y--)" + - "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestFloatsWithTrailingDecimal() - { - TestHelpers.InMethod(); - - string input = @"// a curious feature of LSL that allows floats to be defined with a trailing dot - -default -{ - touch_start(integer num_detected) - { - float y = 1.; - y = 1.E3; - y = 1.e3; - y = 1.E+3; - y = 1.e+3; - y = 1.E-3; - y = 1.e-3; - y = -1.E3; - y = -1.e3; - y = -1.E+3; - y = -1.e+3; - y = -1.E-3; - y = -1.e-3; - y = 12. + -1.E3 - 1.e-2; - vector v = <0.,0.,0.>; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLFloat y = new LSL_Types.LSLFloat(1.0);" + - "\n y = new LSL_Types.LSLFloat(1.0E3);" + - "\n y = new LSL_Types.LSLFloat(1.0e3);" + - "\n y = new LSL_Types.LSLFloat(1.0E+3);" + - "\n y = new LSL_Types.LSLFloat(1.0e+3);" + - "\n y = new LSL_Types.LSLFloat(1.0E-3);" + - "\n y = new LSL_Types.LSLFloat(1.0e-3);" + - "\n y = -new LSL_Types.LSLFloat(1.0E3);" + - "\n y = -new LSL_Types.LSLFloat(1.0e3);" + - "\n y = -new LSL_Types.LSLFloat(1.0E+3);" + - "\n y = -new LSL_Types.LSLFloat(1.0e+3);" + - "\n y = -new LSL_Types.LSLFloat(1.0E-3);" + - "\n y = -new LSL_Types.LSLFloat(1.0e-3);" + - "\n y = new LSL_Types.LSLFloat(12.0) + -new LSL_Types.LSLFloat(1.0E3) - new LSL_Types.LSLFloat(1.0e-2);" + - "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestUnaryAndBinaryOperators() - { - TestHelpers.InMethod(); - - string input = @"// let's test a few more operators - -default -{ - touch_start(integer num_detected) - { - integer x = 2; - integer y = 1; - integer z = x ^ y; - x = ~ z; - x = ~(y && z); - y = x >> z; - z = y << x; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(2);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(1);" + - "\n LSL_Types.LSLInteger z = x ^ y;" + - "\n x = ~z;" + - "\n x = ~(((bool)(y)) & ((bool)(z)));" + - "\n y = x >> z;" + - "\n z = y << x;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestTypecasts() - { - TestHelpers.InMethod(); - - string input = @"// let's test typecasts - -default -{ - touch_start(integer num_detected) - { - string s = """"; - integer x = 1; - - s = (string) x++; - s = (string) x; - s = (string) <0., 0., 0.>; - s = (string) <1., 1., 1., 1.>; - s = (integer) ""1""; - s = (string) llSomethingThatReturnsInteger(); - s = (string) 134; - s = (string) (x ^ y | (z && l)) + (string) (x + y - 13); - llOwnerSay(""s is: "" + s); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLString s = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + - "\n s = (LSL_Types.LSLString) (x++);" + - "\n s = (LSL_Types.LSLString) (x);" + - "\n s = (LSL_Types.LSLString) (new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0)));" + - "\n s = (LSL_Types.LSLString) (new LSL_Types.Quaternion(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(1.0)));" + - "\n s = (LSL_Types.LSLInteger) (new LSL_Types.LSLString(\"1\"));" + - "\n s = (LSL_Types.LSLString) (llSomethingThatReturnsInteger());" + - "\n s = (LSL_Types.LSLString) (new LSL_Types.LSLInteger(134));" + - "\n s = (LSL_Types.LSLString) (x ^ y | (((bool)(z)) & ((bool)(l)))) + (LSL_Types.LSLString) (x + y - new LSL_Types.LSLInteger(13));" + - "\n llOwnerSay(new LSL_Types.LSLString(\"s is: \") + s);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestStates() - { - TestHelpers.InMethod(); - - string input = @"// let's test states - -default -{ - touch_start(integer num_detected) - { - llSay(0, ""Going to state 'statetwo'""); - state statetwo; - } -} - -state statetwo -{ - state_entry() - { - llSay(0, ""Going to the default state""); - state default; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Going to state 'statetwo'\"));" + - "\n state(\"statetwo\");" + - "\n }" + - "\n public void statetwo_event_state_entry()" + - "\n {" + - "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Going to the default state\"));" + - "\n state(\"default\");" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestHexIntegerConstants() - { - TestHelpers.InMethod(); - - string input = @"// let's test hex integers - -default -{ - touch_start(integer num_detected) - { - integer x = 0x23; - integer x = 0x2f34B; - integer x = 0x2F34b; - integer x = 0x2F34B; - integer x = 0x2f34b; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0x23);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0x2f34B);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0x2F34b);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0x2F34B);" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0x2f34b);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestJumps() - { - TestHelpers.InMethod(); - - string input = @"// let's test jumps - -default -{ - touch_start(integer num_detected) - { - jump here; - llOwnerSay(""Uh oh, the jump didn't work""); - @here; - llOwnerSay(""After the jump""); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n goto here;" + - "\n llOwnerSay(new LSL_Types.LSLString(\"Uh oh, the jump didn't work\"));" + - "\n here: NoOp();" + - "\n llOwnerSay(new LSL_Types.LSLString(\"After the jump\"));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestImplicitVariableInitialization() - { - TestHelpers.InMethod(); - - string input = @"// let's test implicitly initializing variables - -default -{ - touch_start(integer num_detected) - { - integer i; integer j = 14; - float f; float g = 14.0; - string s; string t = ""Hi there""; - list l; list m = [1, 2, 3]; - vector v; vector w = <1.0, 0.1, 0.5>; - rotation r; rotation u = <0.8, 0.7, 0.6, llSomeFunc()>; - key k; key n = ""ping""; - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger i = new LSL_Types.LSLInteger(0);" + - "\n LSL_Types.LSLInteger j = new LSL_Types.LSLInteger(14);" + - "\n LSL_Types.LSLFloat f = new LSL_Types.LSLFloat(0.0);" + - "\n LSL_Types.LSLFloat g = new LSL_Types.LSLFloat(14.0);" + - "\n LSL_Types.LSLString s = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLString t = new LSL_Types.LSLString(\"Hi there\");" + - "\n LSL_Types.list l = new LSL_Types.list();" + - "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3));" + - "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" + - "\n LSL_Types.Vector3 w = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.5));" + - "\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(1.0));" + - "\n LSL_Types.Quaternion u = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.8), new LSL_Types.LSLFloat(0.7), new LSL_Types.LSLFloat(0.6), llSomeFunc());" + - "\n LSL_Types.LSLString k = new LSL_Types.LSLString(\"\");" + - "\n LSL_Types.LSLString n = new LSL_Types.LSLString(\"ping\");" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestMultipleEqualsExpression() - { - TestHelpers.InMethod(); - - string input = @"// let's test x = y = 5 type expressions - -default -{ - touch_start(integer num_detected) - { - integer x; - integer y; - x = y = 5; - x += y -= 5; - llOwnerSay(""x is: "" + (string) x + "", y is: "" + (string) y); - } -} -"; - string expected = - "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" + - "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + - "\n x = y = new LSL_Types.LSLInteger(5);" + - "\n x += y -= new LSL_Types.LSLInteger(5);" + - "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x) + new LSL_Types.LSLString(\", y is: \") + (LSL_Types.LSLString) (y));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestUnaryExpressionLastInVectorConstant() - { - TestHelpers.InMethod(); - - string input = @"// let's test unary expressions some more - -default -{ - state_entry() - { - vector v = ; - } -} -"; - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(x, y, -new LSL_Types.LSLFloat(0.5));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestVectorMemberPlusEquals() - { - TestHelpers.InMethod(); - - string input = @"// let's test unary expressions some more - -default -{ - state_entry() - { - vector v = llGetPos(); - v.z += 4; - v.z -= 4; - v.z *= 4; - v.z /= 4; - v.z %= 4; - } -} -"; - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.Vector3 v = llGetPos();" + - "\n v.z += new LSL_Types.LSLInteger(4);" + - "\n v.z -= new LSL_Types.LSLInteger(4);" + - "\n v.z *= new LSL_Types.LSLInteger(4);" + - "\n v.z /= new LSL_Types.LSLInteger(4);" + - "\n v.z %= new LSL_Types.LSLInteger(4);" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestWhileLoopWithNoBody() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - while (1<0); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n while (new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0))" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestDoWhileLoopWithNoBody() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - do; - while (1<0); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n do" + - "\n ;" + - "\n while (new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIfWithNoBody() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - if (1<0); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n if (new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0))" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestIfElseWithNoBody() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - if (1<0); - else; - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n if (new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0))" + - "\n ;" + - "\n else" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestForLoopWithNoBody() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - for (x = 4; 1<0; x += 2); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n for (x = new LSL_Types.LSLInteger(4); new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0); x += new LSL_Types.LSLInteger(2))" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestForLoopWithNoAssignment() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - integer x = 4; - for (; 1<0; x += 2); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(4);" + - "\n for (; new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0); x += new LSL_Types.LSLInteger(2))" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestForLoopWithOnlyIdentInAssignment() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - integer x = 4; - for (x; 1<0; x += 2); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(4);" + - "\n for (; new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0); x += new LSL_Types.LSLInteger(2))" + - "\n ;" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestAssignmentInIfWhileDoWhile() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - integer x; - - while (x = 14) llOwnerSay(""x is: "" + (string) x); - - if (x = 24) llOwnerSay(""x is: "" + (string) x); - - do - llOwnerSay(""x is: "" + (string) x); - while (x = 44); - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" + - "\n while (x = new LSL_Types.LSLInteger(14))" + - "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x));" + - "\n if (x = new LSL_Types.LSLInteger(24))" + - "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x));" + - "\n do" + - "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x));" + - "\n while (x = new LSL_Types.LSLInteger(44));" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestLSLListHack() - { - TestHelpers.InMethod(); - - string input = @"default -{ - state_entry() - { - list l = [""hello""]; - l = (l=[]) + l + ""world""; - } -}"; - - string expected = - "\n public void default_event_state_entry()" + - "\n {" + - "\n LSL_Types.list l = new LSL_Types.list(new LSL_Types.LSLString(\"hello\"));" + - "\n l = (l = new LSL_Types.list()) + l + new LSL_Types.LSLString(\"world\");" + - "\n }\n"; - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - Assert.AreEqual(expected, output); - } - - [Test] - public void TestSyntaxError() - { - TestHelpers.InMethod(); - - bool gotException = false; - - string input = @"default -{ - state_entry() - { - integer y - } -} -"; - try - { - CSCodeGenerator cg = new CSCodeGenerator(); - cg.Convert(input); - } - catch (System.Exception e) - { - // The syntax error is on line 5, char 4 (expected ';', found - // '}'). - Assert.AreEqual("(5,4) syntax error", e.Message); - gotException = true; - } - - Assert.That(gotException, Is.True); - } - - [Test] - public void TestSyntaxErrorDeclaringVariableInForLoop() - { - TestHelpers.InMethod(); - - bool gotException = false; - - string input = @"default -{ - state_entry() - { - for (integer x = 0; x < 10; x++) llOwnerSay(""x is: "" + (string) x); - } -} -"; - try - { - CSCodeGenerator cg = new CSCodeGenerator(); - cg.Convert(input); - } - catch (System.Exception e) - { - // The syntax error is on line 4, char 13 (Syntax error) - Assert.AreEqual("(4,13) syntax error", e.Message); - - gotException = true; - } - - Assert.That(gotException, Is.True); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs deleted file mode 100644 index fa1f01d067f..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using Microsoft.CSharp; -using NUnit.Framework; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests -{ - - /// - /// Tests the LSL compiler. Among other things, test that error messages - /// generated by the C# compiler can be mapped to prper lines/columns in - /// the LSL source. - /// - [TestFixture] - public class CompilerTest : OpenSimTestCase - { - private string m_testDir; - private CSharpCodeProvider m_CSCodeProvider; - private CompilerParameters m_compilerParameters; - // private CompilerResults m_compilerResults; - private ResolveEventHandler m_resolveEventHandler; - - /// - /// Creates a temporary directory where build artifacts are stored. - /// - [OneTimeSetUp] - public void Init() - { - m_testDir = Path.Combine(Path.GetTempPath(), "opensim_compilerTest_" + Path.GetRandomFileName()); - - if (!Directory.Exists(m_testDir)) - { - // Create the temporary directory for housing build artifacts. - Directory.CreateDirectory(m_testDir); - } - } - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - // Create a CSCodeProvider and CompilerParameters. - m_CSCodeProvider = new CSharpCodeProvider(); - m_compilerParameters = new CompilerParameters(); - - string rootPath = System.AppDomain.CurrentDomain.BaseDirectory; - - m_resolveEventHandler = new ResolveEventHandler(AssemblyResolver.OnAssemblyResolve); - - System.AppDomain.CurrentDomain.AssemblyResolve += m_resolveEventHandler; - - m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); - m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); - m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); - m_compilerParameters.GenerateExecutable = false; - } - - /// - /// Removes the temporary build directory and any build artifacts - /// inside it. - /// - [TearDown] - public void CleanUp() - { - System.AppDomain.CurrentDomain.AssemblyResolve -= m_resolveEventHandler; - - if (Directory.Exists(m_testDir)) - { - // Blow away the temporary directory with artifacts. - Directory.Delete(m_testDir, true); - } - } - - private CompilerResults CompileScript( - string input, out Dictionary, KeyValuePair> positionMap) - { - m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); - - CSCodeGenerator cg = new CSCodeGenerator(); - string output = cg.Convert(input); - - output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); - // System.Console.WriteLine(output); - - positionMap = cg.PositionMap; - - CompilerResults compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); - - // foreach (KeyValuePair key in positionMap.Keys) - // { - // KeyValuePair val = positionMap[key]; - // - // System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value); - // } - // - // foreach (CompilerError compErr in m_compilerResults.Errors) - // { - // System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr); - // } - - return compilerResults; - } -/* test too depedent on counting lines and columns maping code generation changes -erros position is better tested on viewers - /// - /// Test that line number errors are resolved as expected when preceding code contains a jump. - /// - [Test] - public void TestJumpAndSyntaxError() - { - TestHelpers.InMethod(); - - Dictionary, KeyValuePair> positionMap; - - CompilerResults compilerResults = CompileScript( -@"default -{ - state_entry() - { - jump l; - @l; - i = 1; - } -}", out positionMap); - - Assert.AreEqual( - new KeyValuePair(7, 9), - positionMap[new KeyValuePair(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]); - } - - - /// - /// Test the C# compiler error message can be mapped to the correct - /// line/column in the LSL source when an undeclared variable is used. - /// - [Test] - public void TestUseUndeclaredVariable() - { - TestHelpers.InMethod(); - - Dictionary, KeyValuePair> positionMap; - - CompilerResults compilerResults = CompileScript( -@"default -{ - state_entry() - { - integer y = x + 3; - } -}", out positionMap); - - Assert.AreEqual( - new KeyValuePair(5, 21), - positionMap[new KeyValuePair(compilerResults.Errors[0].Line, compilerResults.Errors[0].Column)]); - } -*/ - /// - /// Test that a string can be cast to string and another string - /// concatenated. - /// - [Test] - public void TestCastAndConcatString() - { - TestHelpers.InMethod(); - - Dictionary, KeyValuePair> positionMap; - - CompilerResults compilerResults = CompileScript( -@"string s = "" a string""; - -default -{ - state_entry() - { - key gAvatarKey = llDetectedKey(0); - string tmp = (string) gAvatarKey + s; - llSay(0, tmp); - } -}", out positionMap); - - Assert.AreEqual(0, compilerResults.Errors.Count); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs deleted file mode 100644 index 220ec72cfa8..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text.RegularExpressions; -using NUnit.Framework; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - public class LSL_EventTests : OpenSimTestCase - { - CSCodeGenerator m_cg = new CSCodeGenerator(); - - [Test] - public void TestBadEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestCompile("default { bad() {} }", true); - } - - [Test] - public void TestAttachEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestKeyArgEvent("attach"); - } - - [Test] - public void TestObjectRezEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestKeyArgEvent("object_rez"); - } - - [Test] - public void TestMovingEndEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("moving_end"); - } - - [Test] - public void TestMovingStartEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("moving_start"); - } - - [Test] - public void TestNoSensorEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("no_sensor"); - } - - [Test] - public void TestNotAtRotTargetEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("not_at_rot_target"); - } - - [Test] - public void TestNotAtTargetEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("not_at_target"); - } - - [Test] - public void TestStateEntryEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("state_entry"); - } - - [Test] - public void TestStateExitEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("state_exit"); - } - - [Test] - public void TestTimerEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVoidArgEvent("timer"); - } - - private void TestVoidArgEvent(string eventName) - { - TestCompile("default { " + eventName + "() {} }", false); - TestCompile("default { " + eventName + "(integer n) {} }", true); - } - - [Test] - public void TestChangedEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("changed"); - } - - [Test] - public void TestCollisionEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("collision"); - } - - [Test] - public void TestCollisionStartEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("collision_start"); - } - - [Test] - public void TestCollisionEndEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("collision_end"); - } - - [Test] - public void TestOnRezEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("on_rez"); - } - - [Test] - public void TestRunTimePermissionsEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("run_time_permissions"); - } - - [Test] - public void TestSensorEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("sensor"); - } - - [Test] - public void TestTouchEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("touch"); - } - - [Test] - public void TestTouchStartEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("touch_start"); - } - - [Test] - public void TestTouchEndEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntArgEvent("touch_end"); - } - - [Test] - public void TestLandCollisionEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVectorArgEvent("land_collision"); - } - - [Test] - public void TestLandCollisionStartEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVectorArgEvent("land_collision_start"); - } - - [Test] - public void TestLandCollisionEndEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestVectorArgEvent("land_collision_end"); - } - - [Test] - public void TestAtRotTargetEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntRotRotArgEvent("at_rot_target"); - } - - [Test] - public void TestAtTargetEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestIntVecVecArgEvent("at_target"); - } - - [Test] - public void TestControlEvent() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - TestKeyIntIntArgEvent("control"); - } - - private void TestIntArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(integer n) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(integer n, integer o) {{}} }", true); - } - - private void TestKeyArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(key k) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(key k, key l) {{}} }", true); - } - - private void TestVectorArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(vector v) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(vector v, vector w) {{}} }", true); - } - - private void TestIntRotRotArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(integer n, rotation r, rotation s) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(integer n, rotation r, rotation s, rotation t) {{}} }", true); - } - - private void TestIntVecVecArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(integer n, vector v, vector w) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(integer n, vector v, vector w, vector x) {{}} }", true); - } - - private void TestKeyIntIntArgEvent(string eventName) - { - TestCompile("default { " + eventName + "(key k, integer n, integer o) {} }", false); - TestCompile("default { " + eventName + "{{}} }", true); - TestCompile("default { " + eventName + "(string s) {{}} }", true); - TestCompile("default { " + eventName + "(key k, integer n, integer o, integer p) {{}} }", true); - } - - private void TestCompile(string script, bool expectException) - { - bool gotException = false; - Exception ge = null; - - try - { - m_cg.Convert(script); - } - catch (Exception e) - { - gotException = true; - ge = e; - } - - Assert.That( - gotException, - Is.EqualTo(expectException), - "Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a"); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs deleted file mode 100644 index 2d49511c617..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs +++ /dev/null @@ -1,19747 +0,0 @@ -using System;using Tools; -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { -//%+STRING_CONSTANT+3 -public class STRING_CONSTANT : TOKEN{ -public override string yyname { get { return "STRING_CONSTANT"; }} -public override int yynum { get { return 3; }} -public STRING_CONSTANT(Lexer yyl):base(yyl){}} -//%INCREMENT+4 -public class INCREMENT : TOKEN{ public override string yyname { get { return "INCREMENT";}} -public override int yynum { get { return 4; }} - public INCREMENT(Lexer yyl):base(yyl) {}} -//%DECREMENT+5 -public class DECREMENT : TOKEN{ public override string yyname { get { return "DECREMENT";}} -public override int yynum { get { return 5; }} - public DECREMENT(Lexer yyl):base(yyl) {}} -//%PLUS_EQUALS+6 -public class PLUS_EQUALS : TOKEN{ public override string yyname { get { return "PLUS_EQUALS";}} -public override int yynum { get { return 6; }} - public PLUS_EQUALS(Lexer yyl):base(yyl) {}} -//%MINUS_EQUALS+7 -public class MINUS_EQUALS : TOKEN{ public override string yyname { get { return "MINUS_EQUALS";}} -public override int yynum { get { return 7; }} - public MINUS_EQUALS(Lexer yyl):base(yyl) {}} -//%STAR_EQUALS+8 -public class STAR_EQUALS : TOKEN{ public override string yyname { get { return "STAR_EQUALS";}} -public override int yynum { get { return 8; }} - public STAR_EQUALS(Lexer yyl):base(yyl) {}} -//%SLASH_EQUALS+9 -public class SLASH_EQUALS : TOKEN{ public override string yyname { get { return "SLASH_EQUALS";}} -public override int yynum { get { return 9; }} - public SLASH_EQUALS(Lexer yyl):base(yyl) {}} -//%PERCENT_EQUALS+10 -public class PERCENT_EQUALS : TOKEN{ public override string yyname { get { return "PERCENT_EQUALS";}} -public override int yynum { get { return 10; }} - public PERCENT_EQUALS(Lexer yyl):base(yyl) {}} -//%SEMICOLON+11 -public class SEMICOLON : TOKEN{ public override string yyname { get { return "SEMICOLON";}} -public override int yynum { get { return 11; }} - public SEMICOLON(Lexer yyl):base(yyl) {}} -//%LEFT_BRACE+12 -public class LEFT_BRACE : TOKEN{ public override string yyname { get { return "LEFT_BRACE";}} -public override int yynum { get { return 12; }} - public LEFT_BRACE(Lexer yyl):base(yyl) {}} -//%RIGHT_BRACE+13 -public class RIGHT_BRACE : TOKEN{ public override string yyname { get { return "RIGHT_BRACE";}} -public override int yynum { get { return 13; }} - public RIGHT_BRACE(Lexer yyl):base(yyl) {}} -//%COMMA+14 -public class COMMA : TOKEN{ public override string yyname { get { return "COMMA";}} -public override int yynum { get { return 14; }} - public COMMA(Lexer yyl):base(yyl) {}} -//%EQUALS+15 -public class EQUALS : TOKEN{ public override string yyname { get { return "EQUALS";}} -public override int yynum { get { return 15; }} - public EQUALS(Lexer yyl):base(yyl) {}} -//%LEFT_PAREN+16 -public class LEFT_PAREN : TOKEN{ public override string yyname { get { return "LEFT_PAREN";}} -public override int yynum { get { return 16; }} - public LEFT_PAREN(Lexer yyl):base(yyl) {}} -//%RIGHT_PAREN+17 -public class RIGHT_PAREN : TOKEN{ public override string yyname { get { return "RIGHT_PAREN";}} -public override int yynum { get { return 17; }} - public RIGHT_PAREN(Lexer yyl):base(yyl) {}} -//%PLUS+18 -public class PLUS : TOKEN{ public override string yyname { get { return "PLUS";}} -public override int yynum { get { return 18; }} - public PLUS(Lexer yyl):base(yyl) {}} -//%MINUS+19 -public class MINUS : TOKEN{ public override string yyname { get { return "MINUS";}} -public override int yynum { get { return 19; }} - public MINUS(Lexer yyl):base(yyl) {}} -//%STAR+20 -public class STAR : TOKEN{ public override string yyname { get { return "STAR";}} -public override int yynum { get { return 20; }} - public STAR(Lexer yyl):base(yyl) {}} -//%SLASH+21 -public class SLASH : TOKEN{ public override string yyname { get { return "SLASH";}} -public override int yynum { get { return 21; }} - public SLASH(Lexer yyl):base(yyl) {}} -//%PERCENT+22 -public class PERCENT : TOKEN{ public override string yyname { get { return "PERCENT";}} -public override int yynum { get { return 22; }} - public PERCENT(Lexer yyl):base(yyl) {}} -//%AT+23 -public class AT : TOKEN{ public override string yyname { get { return "AT";}} -public override int yynum { get { return 23; }} - public AT(Lexer yyl):base(yyl) {}} -//%PERIOD+24 -public class PERIOD : TOKEN{ public override string yyname { get { return "PERIOD";}} -public override int yynum { get { return 24; }} - public PERIOD(Lexer yyl):base(yyl) {}} -//%LEFT_ANGLE+25 -public class LEFT_ANGLE : TOKEN{ public override string yyname { get { return "LEFT_ANGLE";}} -public override int yynum { get { return 25; }} - public LEFT_ANGLE(Lexer yyl):base(yyl) {}} -//%RIGHT_ANGLE+26 -public class RIGHT_ANGLE : TOKEN{ public override string yyname { get { return "RIGHT_ANGLE";}} -public override int yynum { get { return 26; }} - public RIGHT_ANGLE(Lexer yyl):base(yyl) {}} -//%LEFT_BRACKET+27 -public class LEFT_BRACKET : TOKEN{ public override string yyname { get { return "LEFT_BRACKET";}} -public override int yynum { get { return 27; }} - public LEFT_BRACKET(Lexer yyl):base(yyl) {}} -//%RIGHT_BRACKET+28 -public class RIGHT_BRACKET : TOKEN{ public override string yyname { get { return "RIGHT_BRACKET";}} -public override int yynum { get { return 28; }} - public RIGHT_BRACKET(Lexer yyl):base(yyl) {}} -//%EQUALS_EQUALS+29 -public class EQUALS_EQUALS : TOKEN{ public override string yyname { get { return "EQUALS_EQUALS";}} -public override int yynum { get { return 29; }} - public EQUALS_EQUALS(Lexer yyl):base(yyl) {}} -//%EXCLAMATION_EQUALS+30 -public class EXCLAMATION_EQUALS : TOKEN{ public override string yyname { get { return "EXCLAMATION_EQUALS";}} -public override int yynum { get { return 30; }} - public EXCLAMATION_EQUALS(Lexer yyl):base(yyl) {}} -//%LESS_EQUALS+31 -public class LESS_EQUALS : TOKEN{ public override string yyname { get { return "LESS_EQUALS";}} -public override int yynum { get { return 31; }} - public LESS_EQUALS(Lexer yyl):base(yyl) {}} -//%GREATER_EQUALS+32 -public class GREATER_EQUALS : TOKEN{ public override string yyname { get { return "GREATER_EQUALS";}} -public override int yynum { get { return 32; }} - public GREATER_EQUALS(Lexer yyl):base(yyl) {}} -//%AMP+33 -public class AMP : TOKEN{ public override string yyname { get { return "AMP";}} -public override int yynum { get { return 33; }} - public AMP(Lexer yyl):base(yyl) {}} -//%STROKE+34 -public class STROKE : TOKEN{ public override string yyname { get { return "STROKE";}} -public override int yynum { get { return 34; }} - public STROKE(Lexer yyl):base(yyl) {}} -//%CARET+35 -public class CARET : TOKEN{ public override string yyname { get { return "CARET";}} -public override int yynum { get { return 35; }} - public CARET(Lexer yyl):base(yyl) {}} -//%TILDE+36 -public class TILDE : TOKEN{ public override string yyname { get { return "TILDE";}} -public override int yynum { get { return 36; }} - public TILDE(Lexer yyl):base(yyl) {}} -//%EXCLAMATION+37 -public class EXCLAMATION : TOKEN{ public override string yyname { get { return "EXCLAMATION";}} -public override int yynum { get { return 37; }} - public EXCLAMATION(Lexer yyl):base(yyl) {}} -//%AMP_AMP+38 -public class AMP_AMP : TOKEN{ public override string yyname { get { return "AMP_AMP";}} -public override int yynum { get { return 38; }} - public AMP_AMP(Lexer yyl):base(yyl) {}} -//%STROKE_STROKE+39 -public class STROKE_STROKE : TOKEN{ public override string yyname { get { return "STROKE_STROKE";}} -public override int yynum { get { return 39; }} - public STROKE_STROKE(Lexer yyl):base(yyl) {}} -//%LEFT_SHIFT+40 -public class LEFT_SHIFT : TOKEN{ public override string yyname { get { return "LEFT_SHIFT";}} -public override int yynum { get { return 40; }} - public LEFT_SHIFT(Lexer yyl):base(yyl) {}} -//%RIGHT_SHIFT+41 -public class RIGHT_SHIFT : TOKEN{ public override string yyname { get { return "RIGHT_SHIFT";}} -public override int yynum { get { return 41; }} - public RIGHT_SHIFT(Lexer yyl):base(yyl) {}} -//%IF+42 -public class IF : TOKEN{ public override string yyname { get { return "IF";}} -public override int yynum { get { return 42; }} - public IF(Lexer yyl):base(yyl) {}} -//%ELSE+43 -public class ELSE : TOKEN{ public override string yyname { get { return "ELSE";}} -public override int yynum { get { return 43; }} - public ELSE(Lexer yyl):base(yyl) {}} -//%DO+44 -public class DO : TOKEN{ public override string yyname { get { return "DO";}} -public override int yynum { get { return 44; }} - public DO(Lexer yyl):base(yyl) {}} -//%WHILE+45 -public class WHILE : TOKEN{ public override string yyname { get { return "WHILE";}} -public override int yynum { get { return 45; }} - public WHILE(Lexer yyl):base(yyl) {}} -//%FOR+46 -public class FOR : TOKEN{ public override string yyname { get { return "FOR";}} -public override int yynum { get { return 46; }} - public FOR(Lexer yyl):base(yyl) {}} -//%DEFAULT_STATE+47 -public class DEFAULT_STATE : TOKEN{ public override string yyname { get { return "DEFAULT_STATE";}} -public override int yynum { get { return 47; }} - public DEFAULT_STATE(Lexer yyl):base(yyl) {}} -//%STATE+48 -public class STATE : TOKEN{ public override string yyname { get { return "STATE";}} -public override int yynum { get { return 48; }} - public STATE(Lexer yyl):base(yyl) {}} -//%JUMP+49 -public class JUMP : TOKEN{ public override string yyname { get { return "JUMP";}} -public override int yynum { get { return 49; }} - public JUMP(Lexer yyl):base(yyl) {}} -//%RETURN+50 -public class RETURN : TOKEN{ public override string yyname { get { return "RETURN";}} -public override int yynum { get { return 50; }} - public RETURN(Lexer yyl):base(yyl) {}} -//%INTEGER_TYPE+51 -public class INTEGER_TYPE : TOKEN{ public override string yyname { get { return "INTEGER_TYPE";}} -public override int yynum { get { return 51; }} - public INTEGER_TYPE(Lexer yyl):base(yyl) {}} -//%FLOAT_TYPE+52 -public class FLOAT_TYPE : TOKEN{ public override string yyname { get { return "FLOAT_TYPE";}} -public override int yynum { get { return 52; }} - public FLOAT_TYPE(Lexer yyl):base(yyl) {}} -//%STRING_TYPE+53 -public class STRING_TYPE : TOKEN{ public override string yyname { get { return "STRING_TYPE";}} -public override int yynum { get { return 53; }} - public STRING_TYPE(Lexer yyl):base(yyl) {}} -//%KEY_TYPE+54 -public class KEY_TYPE : TOKEN{ public override string yyname { get { return "KEY_TYPE";}} -public override int yynum { get { return 54; }} - public KEY_TYPE(Lexer yyl):base(yyl) {}} -//%VECTOR_TYPE+55 -public class VECTOR_TYPE : TOKEN{ public override string yyname { get { return "VECTOR_TYPE";}} -public override int yynum { get { return 55; }} - public VECTOR_TYPE(Lexer yyl):base(yyl) {}} -//%ROTATION_TYPE+56 -public class ROTATION_TYPE : TOKEN{ public override string yyname { get { return "ROTATION_TYPE";}} -public override int yynum { get { return 56; }} - public ROTATION_TYPE(Lexer yyl):base(yyl) {}} -//%LIST_TYPE+57 -public class LIST_TYPE : TOKEN{ public override string yyname { get { return "LIST_TYPE";}} -public override int yynum { get { return 57; }} - public LIST_TYPE(Lexer yyl):base(yyl) {}} -//%AT_ROT_TARGET_EVENT+58 -public class AT_ROT_TARGET_EVENT : TOKEN{ public override string yyname { get { return "AT_ROT_TARGET_EVENT";}} -public override int yynum { get { return 58; }} - public AT_ROT_TARGET_EVENT(Lexer yyl):base(yyl) {}} -//%AT_TARGET_EVENT+59 -public class AT_TARGET_EVENT : TOKEN{ public override string yyname { get { return "AT_TARGET_EVENT";}} -public override int yynum { get { return 59; }} - public AT_TARGET_EVENT(Lexer yyl):base(yyl) {}} -//%ATTACH_EVENT+60 -public class ATTACH_EVENT : TOKEN{ public override string yyname { get { return "ATTACH_EVENT";}} -public override int yynum { get { return 60; }} - public ATTACH_EVENT(Lexer yyl):base(yyl) {}} -//%CHANGED_EVENT+61 -public class CHANGED_EVENT : TOKEN{ public override string yyname { get { return "CHANGED_EVENT";}} -public override int yynum { get { return 61; }} - public CHANGED_EVENT(Lexer yyl):base(yyl) {}} -//%COLLISION_EVENT+62 -public class COLLISION_EVENT : TOKEN{ public override string yyname { get { return "COLLISION_EVENT";}} -public override int yynum { get { return 62; }} - public COLLISION_EVENT(Lexer yyl):base(yyl) {}} -//%COLLISION_END_EVENT+63 -public class COLLISION_END_EVENT : TOKEN{ public override string yyname { get { return "COLLISION_END_EVENT";}} -public override int yynum { get { return 63; }} - public COLLISION_END_EVENT(Lexer yyl):base(yyl) {}} -//%COLLISION_START_EVENT+64 -public class COLLISION_START_EVENT : TOKEN{ public override string yyname { get { return "COLLISION_START_EVENT";}} -public override int yynum { get { return 64; }} - public COLLISION_START_EVENT(Lexer yyl):base(yyl) {}} -//%CONTROL_EVENT+65 -public class CONTROL_EVENT : TOKEN{ public override string yyname { get { return "CONTROL_EVENT";}} -public override int yynum { get { return 65; }} - public CONTROL_EVENT(Lexer yyl):base(yyl) {}} -//%DATASERVER_EVENT+66 -public class DATASERVER_EVENT : TOKEN{ public override string yyname { get { return "DATASERVER_EVENT";}} -public override int yynum { get { return 66; }} - public DATASERVER_EVENT(Lexer yyl):base(yyl) {}} -//%EMAIL_EVENT+67 -public class EMAIL_EVENT : TOKEN{ public override string yyname { get { return "EMAIL_EVENT";}} -public override int yynum { get { return 67; }} - public EMAIL_EVENT(Lexer yyl):base(yyl) {}} -//%HTTP_RESPONSE_EVENT+68 -public class HTTP_RESPONSE_EVENT : TOKEN{ public override string yyname { get { return "HTTP_RESPONSE_EVENT";}} -public override int yynum { get { return 68; }} - public HTTP_RESPONSE_EVENT(Lexer yyl):base(yyl) {}} -//%LAND_COLLISION_EVENT+69 -public class LAND_COLLISION_EVENT : TOKEN{ public override string yyname { get { return "LAND_COLLISION_EVENT";}} -public override int yynum { get { return 69; }} - public LAND_COLLISION_EVENT(Lexer yyl):base(yyl) {}} -//%LAND_COLLISION_END_EVENT+70 -public class LAND_COLLISION_END_EVENT : TOKEN{ public override string yyname { get { return "LAND_COLLISION_END_EVENT";}} -public override int yynum { get { return 70; }} - public LAND_COLLISION_END_EVENT(Lexer yyl):base(yyl) {}} -//%LAND_COLLISION_START_EVENT+71 -public class LAND_COLLISION_START_EVENT : TOKEN{ public override string yyname { get { return "LAND_COLLISION_START_EVENT";}} -public override int yynum { get { return 71; }} - public LAND_COLLISION_START_EVENT(Lexer yyl):base(yyl) {}} -//%LINK_MESSAGE_EVENT+72 -public class LINK_MESSAGE_EVENT : TOKEN{ public override string yyname { get { return "LINK_MESSAGE_EVENT";}} -public override int yynum { get { return 72; }} - public LINK_MESSAGE_EVENT(Lexer yyl):base(yyl) {}} -//%LISTEN_EVENT+73 -public class LISTEN_EVENT : TOKEN{ public override string yyname { get { return "LISTEN_EVENT";}} -public override int yynum { get { return 73; }} - public LISTEN_EVENT(Lexer yyl):base(yyl) {}} -//%MONEY_EVENT+74 -public class MONEY_EVENT : TOKEN{ public override string yyname { get { return "MONEY_EVENT";}} -public override int yynum { get { return 74; }} - public MONEY_EVENT(Lexer yyl):base(yyl) {}} -//%MOVING_END_EVENT+75 -public class MOVING_END_EVENT : TOKEN{ public override string yyname { get { return "MOVING_END_EVENT";}} -public override int yynum { get { return 75; }} - public MOVING_END_EVENT(Lexer yyl):base(yyl) {}} -//%MOVING_START_EVENT+76 -public class MOVING_START_EVENT : TOKEN{ public override string yyname { get { return "MOVING_START_EVENT";}} -public override int yynum { get { return 76; }} - public MOVING_START_EVENT(Lexer yyl):base(yyl) {}} -//%NO_SENSOR_EVENT+77 -public class NO_SENSOR_EVENT : TOKEN{ public override string yyname { get { return "NO_SENSOR_EVENT";}} -public override int yynum { get { return 77; }} - public NO_SENSOR_EVENT(Lexer yyl):base(yyl) {}} -//%NOT_AT_ROT_TARGET_EVENT+78 -public class NOT_AT_ROT_TARGET_EVENT : TOKEN{ public override string yyname { get { return "NOT_AT_ROT_TARGET_EVENT";}} -public override int yynum { get { return 78; }} - public NOT_AT_ROT_TARGET_EVENT(Lexer yyl):base(yyl) {}} -//%NOT_AT_TARGET_EVENT+79 -public class NOT_AT_TARGET_EVENT : TOKEN{ public override string yyname { get { return "NOT_AT_TARGET_EVENT";}} -public override int yynum { get { return 79; }} - public NOT_AT_TARGET_EVENT(Lexer yyl):base(yyl) {}} -//%OBJECT_REZ_EVENT+80 -public class OBJECT_REZ_EVENT : TOKEN{ public override string yyname { get { return "OBJECT_REZ_EVENT";}} -public override int yynum { get { return 80; }} - public OBJECT_REZ_EVENT(Lexer yyl):base(yyl) {}} -//%ON_REZ_EVENT+81 -public class ON_REZ_EVENT : TOKEN{ public override string yyname { get { return "ON_REZ_EVENT";}} -public override int yynum { get { return 81; }} - public ON_REZ_EVENT(Lexer yyl):base(yyl) {}} -//%REMOTE_DATA_EVENT+82 -public class REMOTE_DATA_EVENT : TOKEN{ public override string yyname { get { return "REMOTE_DATA_EVENT";}} -public override int yynum { get { return 82; }} - public REMOTE_DATA_EVENT(Lexer yyl):base(yyl) {}} -//%RUN_TIME_PERMISSIONS_EVENT+83 -public class RUN_TIME_PERMISSIONS_EVENT : TOKEN{ public override string yyname { get { return "RUN_TIME_PERMISSIONS_EVENT";}} -public override int yynum { get { return 83; }} - public RUN_TIME_PERMISSIONS_EVENT(Lexer yyl):base(yyl) {}} -//%SENSOR_EVENT+84 -public class SENSOR_EVENT : TOKEN{ public override string yyname { get { return "SENSOR_EVENT";}} -public override int yynum { get { return 84; }} - public SENSOR_EVENT(Lexer yyl):base(yyl) {}} -//%STATE_ENTRY_EVENT+85 -public class STATE_ENTRY_EVENT : TOKEN{ public override string yyname { get { return "STATE_ENTRY_EVENT";}} -public override int yynum { get { return 85; }} - public STATE_ENTRY_EVENT(Lexer yyl):base(yyl) {}} -//%STATE_EXIT_EVENT+86 -public class STATE_EXIT_EVENT : TOKEN{ public override string yyname { get { return "STATE_EXIT_EVENT";}} -public override int yynum { get { return 86; }} - public STATE_EXIT_EVENT(Lexer yyl):base(yyl) {}} -//%TIMER_EVENT+87 -public class TIMER_EVENT : TOKEN{ public override string yyname { get { return "TIMER_EVENT";}} -public override int yynum { get { return 87; }} - public TIMER_EVENT(Lexer yyl):base(yyl) {}} -//%TOUCH_EVENT+88 -public class TOUCH_EVENT : TOKEN{ public override string yyname { get { return "TOUCH_EVENT";}} -public override int yynum { get { return 88; }} - public TOUCH_EVENT(Lexer yyl):base(yyl) {}} -//%TOUCH_START_EVENT+89 -public class TOUCH_START_EVENT : TOKEN{ public override string yyname { get { return "TOUCH_START_EVENT";}} -public override int yynum { get { return 89; }} - public TOUCH_START_EVENT(Lexer yyl):base(yyl) {}} -//%TOUCH_END_EVENT+90 -public class TOUCH_END_EVENT : TOKEN{ public override string yyname { get { return "TOUCH_END_EVENT";}} -public override int yynum { get { return 90; }} - public TOUCH_END_EVENT(Lexer yyl):base(yyl) {}} -//%HTTP_REQUEST_EVENT+91 -public class HTTP_REQUEST_EVENT : TOKEN{ public override string yyname { get { return "HTTP_REQUEST_EVENT";}} -public override int yynum { get { return 91; }} - public HTTP_REQUEST_EVENT(Lexer yyl):base(yyl) {}} -//%TRANSACTION_RESULT_EVENT+92 -public class TRANSACTION_RESULT_EVENT : TOKEN{ public override string yyname { get { return "TRANSACTION_RESULT_EVENT";}} -public override int yynum { get { return 92; }} - public TRANSACTION_RESULT_EVENT(Lexer yyl):base(yyl) {}} -//%IDENT+93 -public class IDENT : TOKEN{ public override string yyname { get { return "IDENT";}} -public override int yynum { get { return 93; }} - public IDENT(Lexer yyl):base(yyl) {}} -//%INTEGER_CONSTANT+94 -public class INTEGER_CONSTANT : TOKEN{ public override string yyname { get { return "INTEGER_CONSTANT";}} -public override int yynum { get { return 94; }} - public INTEGER_CONSTANT(Lexer yyl):base(yyl) {}} -//%HEX_INTEGER_CONSTANT+95 -public class HEX_INTEGER_CONSTANT : TOKEN{ public override string yyname { get { return "HEX_INTEGER_CONSTANT";}} -public override int yynum { get { return 95; }} - public HEX_INTEGER_CONSTANT(Lexer yyl):base(yyl) {}} -//%FLOAT_CONSTANT+96 -public class FLOAT_CONSTANT : TOKEN{ public override string yyname { get { return "FLOAT_CONSTANT";}} -public override int yynum { get { return 96; }} - public FLOAT_CONSTANT(Lexer yyl):base(yyl) {}} -//%|LSLTokens -public class yyLSLTokens : YyLexer { - public yyLSLTokens(ErrorHandler eh):base(eh) { arr = new int[] { -101,4,6,52,0, -46,0,53,0,6, -102,4,16,117,0, -115,0,45,0,97, -0,115,0,99,0, -105,0,105,0,2, -0,103,5,27,7, -27,104,9,1,27, -3,96,0,105,5, -2,3,94,0,2, -1,3,96,0,2, -1,7,26,106,9, -1,26,3,36,0, -107,5,1,3,36, -0,2,1,7,25, -108,9,1,25,3, -172,0,109,5,7, -3,60,0,2,1, -3,124,0,2,1, -3,62,0,2,1, -3,126,0,2,1, -3,61,0,2,1, -3,43,0,2,1, -3,172,0,2,1, -7,24,110,9,1, -24,3,35,0,111, -5,12,3,59,0, -2,1,3,33,0, -2,1,3,44,0, -2,1,3,92,0, -2,1,3,47,0, -2,1,3,35,0, -2,1,3,46,0, -2,1,3,42,0, -2,1,3,64,0, -2,1,3,38,0, -2,1,3,34,0, -2,1,3,37,0, -2,1,7,23,112, -9,1,23,3,187, -0,113,5,1,3, -187,0,2,1,7, -22,114,9,1,22, -3,171,0,115,5, -1,3,171,0,2, -1,7,21,116,9, -1,21,3,59,15, -117,5,4,3,93, -0,2,1,3,125, -0,2,1,3,41, -0,2,1,3,59, -15,2,1,7,20, -118,9,1,20,3, -58,15,119,5,4, -3,123,0,2,1, -3,58,15,2,1, -3,40,0,2,1, -3,91,0,2,1, -7,19,120,9,1, -19,3,173,0,121, -5,2,3,45,0, -2,1,3,173,0, -2,1,7,18,122, -9,1,18,3,63, -32,123,5,2,3, -63,32,2,1,3, -95,0,2,1,7, -17,124,9,1,17, -3,0,224,125,5, -1,3,0,224,2, -1,7,15,126,9, -1,15,3,0,6, -127,5,1,3,0, -6,2,1,7,14, -128,9,1,14,3, -1,0,129,5,5, -3,13,0,2,1, -3,10,0,2,1, -3,1,0,2,1, -3,9,0,2,1, -3,0,0,2,1, -7,13,130,9,1, -13,3,41,32,131, -5,1,3,41,32, -2,1,7,12,132, -9,1,12,3,40, -32,133,5,1,3, -40,32,2,1,7, -11,134,9,1,11, -3,160,0,135,5, -2,3,160,0,2, -1,3,32,0,2, -1,7,10,136,9, -1,10,3,178,0, -137,5,1,3,178, -0,2,1,7,9, -138,9,1,9,3, -238,22,139,5,1, -3,238,22,2,1, -7,8,140,9,1, -8,3,96,6,141, -5,11,3,50,0, -2,1,3,49,0, -2,1,3,57,0, -2,1,3,48,0, -2,1,3,56,0, -2,1,3,55,0, -2,1,3,54,0, -2,1,3,53,0, -2,1,3,52,0, -2,1,3,96,6, -2,1,3,51,0, -2,1,7,7,142, -9,1,7,3,136, -4,143,5,1,3, -136,4,2,1,7, -6,144,9,1,6, -3,3,9,145,5, -1,3,3,9,2, -1,7,5,146,9, -1,5,3,0,3, -147,5,1,3,0, -3,2,1,7,4, -148,9,1,4,3, -187,1,149,5,1, -3,187,1,2,1, -7,3,150,9,1, -3,3,176,2,151, -5,1,3,176,2, -2,1,7,2,152, -9,1,2,3,197, -1,153,5,1,3, -197,1,2,1,7, -1,154,9,1,1, -3,170,0,155,5, -27,3,97,0,2, -1,3,105,0,2, -1,3,113,0,2, -1,3,121,0,2, -1,3,102,0,2, -1,3,110,0,2, -1,3,118,0,2, -1,3,99,0,2, -1,3,107,0,2, -1,3,115,0,2, -1,3,104,0,2, -1,3,112,0,2, -1,3,120,0,2, -1,3,101,0,2, -1,3,109,0,2, -1,3,117,0,2, -1,3,98,0,2, -1,3,106,0,2, -1,3,114,0,2, -1,3,122,0,2, -1,3,103,0,2, -1,3,111,0,2, -1,3,119,0,2, -1,3,100,0,2, -1,3,108,0,2, -1,3,170,0,2, -1,3,116,0,2, -1,7,0,156,9, -1,0,3,192,0, -157,5,27,3,70, -0,2,1,3,78, -0,2,1,3,86, -0,2,1,3,67, -0,2,1,3,75, -0,2,1,3,83, -0,2,1,3,72, -0,2,1,3,80, -0,2,1,3,88, -0,2,1,3,69, -0,2,1,3,77, -0,2,1,3,85, -0,2,1,3,66, -0,2,1,3,74, -0,2,1,3,82, -0,2,1,3,90, -0,2,1,3,71, -0,2,1,3,79, -0,2,1,3,87, -0,2,1,3,68, -0,2,1,3,192, -0,2,1,3,76, -0,2,1,3,84, -0,2,1,3,65, -0,2,1,3,73, -0,2,1,3,81, -0,2,1,3,89, -0,2,1,7,27, -2,0,158,5,3, -159,4,14,67,0, -79,0,77,0,77, -0,69,0,78,0, -84,0,160,12,1, -2176,161,5,119,3, -238,22,162,12,1, -2177,163,5,0,164, -11,1,1063,0,165, -4,0,1,-1,3, -117,0,162,3,63, -32,162,3,37,0, -162,3,114,0,162, -3,74,0,162,3, -34,0,162,3,111, -0,162,3,71,0, -162,3,108,0,162, -3,68,0,162,3, -105,0,162,3,65, -0,162,3,102,0, -162,3,62,0,162, -3,99,0,162,3, -59,0,162,3,96, -0,162,3,96,6, -162,3,173,0,162, -3,93,0,162,3, -53,0,162,3,13, -0,162,3,170,0, -162,3,90,0,162, -3,50,0,162,3, -10,0,166,12,1, -2576,167,5,0,168, -11,1,1067,0,165, -1,-1,3,87,0, -162,3,47,0,162, -3,100,0,162,3, -124,0,162,3,84, -0,162,3,44,0, -162,3,121,0,162, -3,81,0,162,3, -41,0,162,3,1, -0,162,3,59,15, -162,3,78,0,162, -3,38,0,162,3, -58,15,162,3,115, -0,162,3,75,0, -162,3,35,0,162, -3,192,0,162,3, -112,0,162,3,72, -0,162,3,32,0, -162,3,109,0,162, -3,69,0,162,3, -187,1,162,3,106, -0,162,3,66,0, -162,3,103,0,162, -3,77,0,162,3, -3,9,162,3,118, -0,162,3,60,0, -162,3,0,3,162, -3,197,1,162,3, -176,2,162,3,57, -0,162,3,70,0, -162,3,94,0,162, -3,54,0,162,3, -171,0,162,3,91, -0,162,3,51,0, -162,3,88,0,162, -3,48,0,162,3, -125,0,162,3,85, -0,162,3,56,0, -162,3,97,0,162, -3,122,0,162,3, -82,0,162,3,42, -0,169,12,1,2314, -170,5,1,3,47, -0,171,12,1,2329, -172,5,0,173,11, -1,1049,0,165,1, --1,174,11,1,1063, -0,165,1,-1,3, -0,6,162,3,119, -0,162,3,79,0, -162,3,41,32,162, -3,116,0,162,3, -76,0,162,3,36, -0,162,3,113,0, -162,3,73,0,162, -3,33,0,162,3, -110,0,162,3,40, -32,162,3,0,224, -162,3,187,0,162, -3,107,0,162,3, -67,0,162,3,104, -0,162,3,64,0, -162,3,101,0,162, -3,61,0,162,3, -178,0,162,3,98, -0,162,3,45,0, -162,3,136,4,162, -3,95,0,162,3, -55,0,162,3,172, -0,162,3,92,0, -162,3,52,0,162, -3,89,0,162,3, -49,0,162,3,9, -0,162,3,126,0, -162,3,86,0,162, -3,46,0,162,3, -123,0,162,3,83, -0,162,3,43,0, -162,3,160,0,162, -3,120,0,162,3, -80,0,162,3,40, -0,162,0,165,1, --1,175,4,18,89, -0,89,0,73,0, -78,0,73,0,84, -0,73,0,65,0, -76,0,176,12,1, -2777,177,5,91,3, -117,0,178,12,1, -8453,179,5,63,3, -97,0,180,12,1, -8489,181,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,182,11,1,867, -0,183,4,10,73, -0,68,0,69,0, -78,0,84,0,1, --1,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,184, -11,1,867,0,183, -1,-1,3,77,0, -178,3,37,0,185, -12,1,7119,186,5, -1,3,61,0,187, -12,1,7127,188,5, -0,189,11,1,40, -0,190,4,28,80, -0,69,0,82,0, -67,0,69,0,78, -0,84,0,95,0, -69,0,81,0,85, -0,65,0,76,0, -83,0,1,-1,191, -11,1,101,0,192, -4,14,80,0,69, -0,82,0,67,0, -69,0,78,0,84, -0,1,-1,3,114, -0,193,12,1,30702, -194,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -195,12,1,30782,196, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,197,12,1, -30863,198,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,199,12,1,30951, -200,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -201,12,1,31044,202, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,203, -12,1,31124,204,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,205,12, -1,31160,206,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,207,12,1, -31250,208,5,63,3, -97,0,209,12,1, -31317,210,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,211,12,1,31410, -212,5,63,3,97, -0,213,12,1,31477, -214,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -215,11,1,705,0, -216,4,34,82,0, -69,0,77,0,79, -0,84,0,69,0, -95,0,68,0,65, -0,84,0,65,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,217,11,1, -867,0,183,1,-1, -3,89,0,180,218, -11,1,867,0,183, -1,-1,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -219,11,1,867,0, -183,1,-1,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,220,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,221, -11,1,867,0,183, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,222,11,1,867, -0,183,1,-1,3, -89,0,180,223,11, -1,867,0,183,1, --1,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -224,11,1,867,0, -183,1,-1,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,225, -12,1,31955,226,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,227,12, -1,32037,228,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -229,12,1,32122,230, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,231,12, -1,32194,232,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,233,11,1, -273,0,234,4,12, -82,0,69,0,84, -0,85,0,82,0, -78,0,1,-1,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,235, -11,1,867,0,183, -1,-1,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,236,11, -1,867,0,183,1, --1,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -237,11,1,867,0, -183,1,-1,3,89, -0,180,238,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,239, -12,1,32464,240,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,241,12,1, -32536,242,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,243,12,1,32572, -244,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -245,12,1,32665,246, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,247,12, -1,32733,248,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -249,12,1,32814,250, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,251, -12,1,32894,252,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,253,12, -1,32930,254,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,255,12,1,33008, -256,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -257,12,1,33088,258, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,259,12,1, -33173,260,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,261, -12,1,33254,262,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,263,12,1, -33322,264,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,265,12,1,33398, -266,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -267,12,1,33474,268, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,269,12, -1,33542,270,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,271,12,1, -33630,272,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -273,12,1,33702,274, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,275, -12,1,33778,276,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,277,11, -1,720,0,278,4, -52,82,0,85,0, -78,0,95,0,84, -0,73,0,77,0, -69,0,95,0,80, -0,69,0,82,0, -77,0,73,0,83, -0,83,0,73,0, -79,0,78,0,83, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,279, -11,1,867,0,183, -1,-1,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,280,11,1, -867,0,183,1,-1, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,281, -11,1,867,0,183, -1,-1,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,282,11,1, -867,0,183,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,283, -11,1,867,0,183, -1,-1,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,284,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,285, -11,1,867,0,183, -1,-1,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,286,11, -1,867,0,183,1, --1,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,287,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,288, -11,1,867,0,183, -1,-1,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,289,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,290, -11,1,867,0,183, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,291,11,1,867, -0,183,1,-1,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -292,11,1,867,0, -183,1,-1,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,293,11, -1,867,0,183,1, --1,3,89,0,180, -294,11,1,867,0, -183,1,-1,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,295,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -296,11,1,867,0, -183,1,-1,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,297,12,1, -34750,298,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,299,12,1,34843, -300,5,63,3,97, -0,301,12,1,34910, -302,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -303,12,1,35003,304, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,305,12, -1,35071,306,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,307,12,1, -35159,308,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -309,12,1,35231,310, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,311, -11,1,330,0,312, -4,26,82,0,79, -0,84,0,65,0, -84,0,73,0,79, -0,78,0,95,0, -84,0,89,0,80, -0,69,0,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -313,11,1,867,0, -183,1,-1,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,314,11,1, -867,0,183,1,-1, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -315,11,1,867,0, -183,1,-1,3,89, -0,180,316,11,1, -867,0,183,1,-1, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,317,11, -1,867,0,183,1, --1,3,89,0,180, -318,11,1,867,0, -183,1,-1,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,319,11,1, -867,0,183,1,-1, -3,74,0,178,3, -34,0,320,12,1, -6998,321,5,0,322, -11,1,963,0,165, -1,-1,3,111,0, -323,12,1,35625,324, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,325,12, -1,35697,326,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,327,12,1, -35733,328,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,329, -12,1,35818,330,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,331,12, -1,35898,332,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,333,12, -1,35984,334,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,335,11,1, -695,0,336,4,24, -79,0,78,0,95, -0,82,0,69,0, -90,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,337, -11,1,867,0,183, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,338,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -339,11,1,867,0, -183,1,-1,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,340,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,341,12, -1,36308,342,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,343,12, -1,36392,344,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,345,12,1, -36472,346,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,347,12,1,36546, -348,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -349,12,1,36639,350, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,351, -12,1,36675,352,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,353,12,1,36760, -354,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -355,12,1,36840,356, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -357,12,1,36926,358, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,359, -11,1,681,0,360, -4,32,79,0,66, -0,74,0,69,0, -67,0,84,0,95, -0,82,0,69,0, -90,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,361, -11,1,867,0,183, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,362,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -363,11,1,867,0, -183,1,-1,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,364,11,1, -867,0,183,1,-1, -3,89,0,180,365, -11,1,867,0,183, -1,-1,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,366,11,1,867, -0,183,1,-1,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,367,11, -1,867,0,183,1, --1,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,368, -11,1,867,0,183, -1,-1,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,369,11, -1,867,0,183,1, --1,3,71,0,178, -3,108,0,370,12, -1,40068,371,5,63, -3,97,0,372,12, -1,40135,373,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,374,12,1,40207, -375,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -376,12,1,40297,377, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,378, -12,1,40333,379,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,380,12, -1,40407,381,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,382,12,1, -40495,383,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,384, -12,1,40586,385,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,386,12,1,40677, -387,5,63,3,97, -0,180,3,70,0, -180,3,105,0,388, -12,1,40745,389,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,390,12, -1,40821,391,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,392,12,1,40889, -393,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -394,12,1,40977,395, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,396,12, -1,41049,397,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,398,12,1, -41085,399,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,400,12,1,41161, -401,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -402,12,1,41254,403, -5,63,3,97,0, -404,12,1,41321,405, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,406,12,1, -41406,407,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,408,12,1,41499, -409,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -410,11,1,541,0, -411,4,52,76,0, -65,0,78,0,68, -0,95,0,67,0, -79,0,76,0,76, -0,73,0,83,0, -73,0,79,0,78, -0,95,0,83,0, -84,0,65,0,82, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,-1,3,89,0, -180,412,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -413,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,414,11,1,867, -0,183,1,-1,3, -89,0,180,415,11, -1,867,0,183,1, --1,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -416,12,1,41765,417, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,418,12, -1,41837,419,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,420,12,1, -41927,421,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,422,11,1,519, -0,423,4,48,76, -0,65,0,78,0, -68,0,95,0,67, -0,79,0,76,0, -76,0,73,0,83, -0,73,0,79,0, -78,0,95,0,69, -0,78,0,68,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,424,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,425,11,1,867, -0,183,1,-1,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,426,11, -1,867,0,183,1, --1,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -427,11,1,501,0, -428,4,40,76,0, -65,0,78,0,68, -0,95,0,67,0, -79,0,76,0,76, -0,73,0,83,0, -73,0,79,0,78, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -429,11,1,867,0, -183,1,-1,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,430,11,1, -867,0,183,1,-1, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -431,11,1,867,0, -183,1,-1,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,432,11,1, -867,0,183,1,-1, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -433,11,1,867,0, -183,1,-1,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,434, -11,1,867,0,183, -1,-1,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,435,11, -1,867,0,183,1, --1,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -436,11,1,867,0, -183,1,-1,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,437,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,438, -11,1,867,0,183, -1,-1,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,439,11,1,867, -0,183,1,-1,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,440, -11,1,867,0,183, -1,-1,3,70,0, -180,3,105,0,441, -12,1,42776,442,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,443,12,1, -42848,444,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,445, -12,1,42923,446,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,447,12, -1,42959,448,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -449,12,1,43040,450, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,451, -12,1,43120,452,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,453,12, -1,43196,454,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,455,12,1, -43272,456,5,63,3, -97,0,457,12,1, -43339,458,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,459, -12,1,43426,460,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,461,12, -1,43506,462,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,463,11,1, -565,0,464,4,36, -76,0,73,0,78, -0,75,0,95,0, -77,0,69,0,83, -0,83,0,65,0, -71,0,69,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,465,11,1, -867,0,183,1,-1, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,466,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,467,11,1, -867,0,183,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,468, -11,1,867,0,183, -1,-1,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,469,11,1,867, -0,183,1,-1,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,470,11, -1,867,0,183,1, --1,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,471,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,472, -11,1,867,0,183, -1,-1,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,473,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,474,12,1,44052, -475,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -476,12,1,44145,477, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,478, -12,1,44225,479,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,480,12,1, -44297,481,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,482,11,1,581, -0,483,4,24,76, -0,73,0,83,0, -84,0,69,0,78, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -484,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,485,11,1, -342,0,486,4,18, -76,0,73,0,83, -0,84,0,95,0, -84,0,89,0,80, -0,69,0,1,-1, -3,89,0,180,487, -11,1,867,0,183, -1,-1,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,488,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,489, -11,1,867,0,183, -1,-1,3,68,0, -178,3,105,0,490, -12,1,12205,491,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -492,12,1,12276,493, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,494, -11,1,209,0,495, -4,4,73,0,70, -0,1,-1,3,75, -0,180,3,48,0, -180,3,110,0,496, -12,1,12397,497,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,498,12, -1,12490,499,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,500,12,1, -12570,501,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,502, -12,1,12657,503,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,504,12, -1,12737,505,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -506,12,1,12822,507, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,508, -11,1,283,0,509, -4,24,73,0,78, -0,84,0,69,0, -71,0,69,0,82, -0,95,0,84,0, -89,0,80,0,69, -0,1,-1,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,510, -11,1,867,0,183, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,511,11,1,867, -0,183,1,-1,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -512,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,513,11,1, -867,0,183,1,-1, -3,89,0,180,514, -11,1,867,0,183, -1,-1,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,515,11,1, -867,0,183,1,-1, -3,65,0,178,3, -102,0,516,12,1, -13168,517,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,518,12,1,13256, -519,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,520,12, -1,13341,521,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,522,11,1, -238,0,523,4,6, -70,0,79,0,82, -0,1,-1,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,524, -11,1,867,0,183, -1,-1,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,525, -12,1,13499,526,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,527,12, -1,13587,528,5,63, -3,97,0,529,12, -1,13654,530,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,531,12,1, -13747,532,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,533,11,1,294, -0,534,4,20,70, -0,76,0,79,0, -65,0,84,0,95, -0,84,0,89,0, -80,0,69,0,1, --1,3,89,0,180, -535,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,536,11,1,867, -0,183,1,-1,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,537,11, -1,867,0,183,1, --1,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,538,11,1, -867,0,183,1,-1, -3,62,0,539,12, -1,3503,540,5,2, -3,61,0,541,12, -1,3631,542,5,0, -543,11,1,154,0, -544,4,28,71,0, -82,0,69,0,65, -0,84,0,69,0, -82,0,95,0,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,-1,3,62, -0,545,12,1,3509, -546,5,0,547,11, -1,203,0,548,4, -22,82,0,73,0, -71,0,72,0,84, -0,95,0,83,0, -72,0,73,0,70, -0,84,0,1,-1, -549,11,1,121,0, -550,4,22,82,0, -73,0,71,0,72, -0,84,0,95,0, -65,0,78,0,71, -0,76,0,69,0, -1,-1,3,99,0, -551,12,1,18331,552, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,553,12,1,18408, -554,5,63,3,97, -0,555,12,1,18475, -556,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,557, -12,1,18547,558,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,559,12,1,18634, -560,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -561,12,1,18714,562, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,563, -12,1,18804,564,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,565,11, -1,390,0,566,4, -26,67,0,72,0, -65,0,78,0,71, -0,69,0,68,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,567,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -568,11,1,867,0, -183,1,-1,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,569, -11,1,867,0,183, -1,-1,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,570,11,1, -867,0,183,1,-1, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,571,11, -1,867,0,183,1, --1,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,572,12, -1,19139,573,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,574,12,1,19211, -575,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -576,12,1,19304,577, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,578,12,1, -19389,579,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,580,12,1,19477, -581,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,582,12, -1,19568,583,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,584,11,1, -450,0,585,4,26, -67,0,79,0,78, -0,84,0,82,0, -79,0,76,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,586, -11,1,867,0,183, -1,-1,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,587,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -588,11,1,867,0, -183,1,-1,3,89, -0,180,589,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,590,12, -1,19830,591,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -592,12,1,19921,593, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,594,12, -1,19989,595,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,596,12,1, -20065,597,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -598,12,1,20133,599, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,600, -12,1,20221,601,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,602,12,1, -20293,603,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,604,12,1,20329, -605,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -606,12,1,20405,607, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,608, -12,1,20498,609,5, -63,3,97,0,610, -12,1,20565,611,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,612,12,1,20650, -613,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -614,12,1,20743,615, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,616, -11,1,431,0,617, -4,42,67,0,79, -0,76,0,76,0, -73,0,83,0,73, -0,79,0,78,0, -95,0,83,0,84, -0,65,0,82,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,89,0,180, -618,11,1,867,0, -183,1,-1,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,619, -11,1,867,0,183, -1,-1,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -620,11,1,867,0, -183,1,-1,3,89, -0,180,621,11,1, -867,0,183,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,622, -12,1,21009,623,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,624,12,1, -21081,625,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,626,12,1,21171, -627,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -628,11,1,414,0, -629,4,38,67,0, -79,0,76,0,76, -0,73,0,83,0, -73,0,79,0,78, -0,95,0,69,0, -78,0,68,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,630,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -631,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,632,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,633, -11,1,401,0,634, -4,30,67,0,79, -0,76,0,76,0, -73,0,83,0,73, -0,79,0,78,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,635, -11,1,867,0,183, -1,-1,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,636,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,637, -11,1,867,0,183, -1,-1,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,638,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,639, -11,1,867,0,183, -1,-1,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,640,11, -1,867,0,183,1, --1,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,641,11,1, -867,0,183,1,-1, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,642, -11,1,867,0,183, -1,-1,3,59,0, -643,12,1,4588,644, -5,0,645,11,1, -46,0,646,4,18, -83,0,69,0,77, -0,73,0,67,0, -79,0,76,0,79, -0,78,0,1,-1, -3,56,0,647,12, -1,8827,648,5,11, -3,50,0,647,3, -49,0,647,3,57, -0,647,3,48,0, -647,3,56,0,647, -3,55,0,647,3, -46,0,649,12,1, -8844,650,5,14,3, -48,0,651,12,1, -5724,652,5,14,3, -48,0,651,3,70, -0,653,12,1,5795, -654,5,0,655,11, -1,904,0,656,4, -28,70,0,76,0, -79,0,65,0,84, -0,95,0,67,0, -79,0,78,0,83, -0,84,0,65,0, -78,0,84,0,1, --1,3,55,0,651, -3,51,0,651,3, -69,0,657,12,1, -5924,658,5,12,3, -50,0,659,12,1, -5983,660,5,12,3, -50,0,659,3,49, -0,659,3,57,0, -659,3,48,0,659, -3,56,0,659,3, -102,0,653,3,55, -0,659,3,70,0, -653,3,54,0,659, -3,53,0,659,3, -52,0,659,3,51, -0,659,661,11,1, -904,0,656,1,-1, -3,49,0,659,3, -57,0,659,3,48, -0,659,3,56,0, -659,3,55,0,659, -3,54,0,659,3, -45,0,662,12,1, -5933,663,5,10,3, -50,0,659,3,49, -0,659,3,57,0, -659,3,48,0,659, -3,56,0,659,3, -55,0,659,3,54, -0,659,3,53,0, -659,3,52,0,659, -3,51,0,659,0, -165,1,-1,3,53, -0,659,3,52,0, -659,3,43,0,662, -3,51,0,659,0, -165,1,-1,3,54, -0,651,3,102,0, -653,3,50,0,651, -3,57,0,651,3, -53,0,651,3,101, -0,657,3,49,0, -651,3,56,0,651, -3,52,0,651,664, -11,1,904,0,656, -1,-1,3,70,0, -653,3,55,0,651, -3,51,0,651,3, -69,0,657,3,54, -0,651,3,102,0, -653,3,50,0,651, -3,57,0,651,3, -53,0,651,3,101, -0,657,3,49,0, -651,3,56,0,651, -3,52,0,651,665, -11,1,904,0,656, -1,-1,3,54,0, -647,3,53,0,647, -3,52,0,647,3, -51,0,647,666,11, -1,879,0,667,4, -32,73,0,78,0, -84,0,69,0,71, -0,69,0,82,0, -95,0,67,0,79, -0,78,0,83,0, -84,0,65,0,78, -0,84,0,1,-1, -3,93,0,668,12, -1,7362,669,5,0, -670,11,1,131,0, -671,4,26,82,0, -73,0,71,0,72, -0,84,0,95,0, -66,0,82,0,65, -0,67,0,75,0, -69,0,84,0,1, --1,3,53,0,647, -3,13,0,672,12, -1,8696,673,5,0, -674,11,1,1072,0, -165,1,-1,3,90, -0,178,3,50,0, -647,3,10,0,672, -3,87,0,178,3, -47,0,675,12,1, -5072,676,5,3,3, -61,0,677,12,1, -5080,678,5,0,679, -11,1,34,0,680, -4,24,83,0,76, -0,65,0,83,0, -72,0,95,0,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,-1,3,47, -0,681,12,1,5207, -682,5,118,3,238, -22,683,12,1,5208, -684,5,118,3,238, -22,683,3,117,0, -683,3,63,32,683, -3,37,0,683,3, -114,0,683,3,74, -0,683,3,34,0, -683,3,111,0,683, -3,71,0,683,3, -108,0,683,3,68, -0,683,3,105,0, -683,3,65,0,683, -3,102,0,683,3, -62,0,683,3,99, -0,683,3,59,0, -683,3,96,0,683, -3,96,6,683,3, -173,0,683,3,93, -0,683,3,53,0, -683,3,13,0,683, -3,170,0,683,3, -90,0,683,3,50, -0,683,3,87,0, -683,3,47,0,683, -3,100,0,683,3, -124,0,683,3,84, -0,683,3,44,0, -683,3,121,0,683, -3,81,0,683,3, -41,0,683,3,1, -0,683,3,59,15, -683,3,78,0,683, -3,38,0,683,3, -58,15,683,3,115, -0,683,3,75,0, -683,3,35,0,683, -3,192,0,683,3, -112,0,683,3,72, -0,683,3,32,0, -683,3,109,0,683, -3,69,0,683,3, -187,1,683,3,106, -0,683,3,66,0, -683,3,103,0,683, -3,77,0,683,3, -3,9,683,3,118, -0,683,3,60,0, -683,3,0,3,683, -3,197,1,683,3, -176,2,683,3,57, -0,683,3,70,0, -683,3,94,0,683, -3,54,0,683,3, -171,0,683,3,91, -0,683,3,51,0, -683,3,88,0,683, -3,48,0,683,3, -125,0,683,3,85, -0,683,3,56,0, -683,3,97,0,683, -3,122,0,683,3, -82,0,683,3,42, -0,683,3,0,6, -683,3,119,0,683, -3,79,0,683,3, -41,32,683,3,116, -0,683,3,76,0, -683,3,36,0,683, -3,113,0,683,3, -73,0,683,3,33, -0,683,3,110,0, -683,3,40,32,683, -3,0,224,683,3, -187,0,683,3,107, -0,683,3,67,0, -683,3,104,0,683, -3,64,0,683,3, -101,0,683,3,61, -0,683,3,178,0, -683,3,98,0,683, -3,45,0,683,3, -136,4,683,3,95, -0,683,3,55,0, -683,3,172,0,683, -3,92,0,683,3, -52,0,683,3,89, -0,683,3,49,0, -683,3,9,0,683, -3,126,0,683,3, -86,0,683,3,46, -0,683,3,123,0, -683,3,83,0,683, -3,43,0,683,3, -160,0,683,3,120, -0,683,3,80,0, -683,3,40,0,683, -685,11,1,1076,0, -165,1,-1,3,117, -0,683,3,63,32, -683,3,37,0,683, -3,114,0,683,3, -74,0,683,3,34, -0,683,3,111,0, -683,3,71,0,683, -3,108,0,683,3, -68,0,683,3,105, -0,683,3,65,0, -683,3,102,0,683, -3,62,0,683,3, -99,0,683,3,59, -0,683,3,96,0, -683,3,96,6,683, -3,173,0,683,3, -93,0,683,3,53, -0,683,3,13,0, -683,3,170,0,683, -3,90,0,683,3, -50,0,683,3,87, -0,683,3,47,0, -683,3,100,0,683, -3,124,0,683,3, -84,0,683,3,44, -0,683,3,121,0, -683,3,81,0,683, -3,41,0,683,3, -1,0,683,3,59, -15,683,3,78,0, -683,3,38,0,683, -3,58,15,683,3, -115,0,683,3,75, -0,683,3,35,0, -683,3,192,0,683, -3,112,0,683,3, -72,0,683,3,32, -0,683,3,109,0, -683,3,69,0,683, -3,187,1,683,3, -106,0,683,3,66, -0,683,3,103,0, -683,3,77,0,683, -3,3,9,683,3, -118,0,683,3,60, -0,683,3,0,3, -683,3,197,1,683, -3,176,2,683,3, -57,0,683,3,70, -0,683,3,94,0, -683,3,54,0,683, -3,171,0,683,3, -91,0,683,3,51, -0,683,3,88,0, -683,3,48,0,683, -3,125,0,683,3, -85,0,683,3,56, -0,683,3,97,0, -683,3,122,0,683, -3,82,0,683,3, -42,0,683,3,0, -6,683,3,119,0, -683,3,79,0,683, -3,41,32,683,3, -116,0,683,3,76, -0,683,3,36,0, -683,3,113,0,683, -3,73,0,683,3, -33,0,683,3,110, -0,683,3,40,32, -683,3,0,224,683, -3,187,0,683,3, -107,0,683,3,67, -0,683,3,104,0, -683,3,64,0,683, -3,101,0,683,3, -61,0,683,3,178, -0,683,3,98,0, -683,3,45,0,683, -3,136,4,683,3, -95,0,683,3,55, -0,683,3,172,0, -683,3,92,0,683, -3,52,0,683,3, -89,0,683,3,49, -0,683,3,9,0, -683,3,126,0,683, -3,86,0,683,3, -46,0,683,3,123, -0,683,3,83,0, -683,3,43,0,683, -3,160,0,683,3, -120,0,683,3,80, -0,683,3,40,0, -683,686,11,1,1076, -0,165,1,-1,3, -42,0,687,12,1, -5450,688,5,0,689, -11,1,1037,0,165, -1,-1,690,11,1, -96,0,691,4,10, -83,0,76,0,65, -0,83,0,72,0, -1,-1,3,124,0, -692,12,1,3262,693, -5,1,3,124,0, -694,12,1,3267,695, -5,0,696,11,1, -191,0,697,4,26, -83,0,84,0,82, -0,79,0,75,0, -69,0,95,0,83, -0,84,0,82,0, -79,0,75,0,69, -0,1,-1,698,11, -1,165,0,699,4, -12,83,0,84,0, -82,0,79,0,75, -0,69,0,1,-1, -3,84,0,178,3, -44,0,700,12,1, -4950,701,5,0,702, -11,1,61,0,703, -4,10,67,0,79, -0,77,0,77,0, -65,0,1,-1,3, -121,0,178,3,81, -0,178,3,41,0, -704,12,1,7604,705, -5,0,706,11,1, -76,0,707,4,22, -82,0,73,0,71, -0,72,0,84,0, -95,0,80,0,65, -0,82,0,69,0, -78,0,1,-1,3, -118,0,708,12,1, -17610,709,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,710,12,1,17690, -711,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -712,12,1,17764,713, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,714, -12,1,17857,715,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,716,12, -1,17945,717,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -718,12,1,18030,719, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,720, -11,1,320,0,721, -4,22,86,0,69, -0,67,0,84,0, -79,0,82,0,95, -0,84,0,89,0, -80,0,69,0,1, --1,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,722,11,1, -867,0,183,1,-1, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,723, -11,1,867,0,183, -1,-1,3,89,0, -180,724,11,1,867, -0,183,1,-1,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,725,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -726,11,1,867,0, -183,1,-1,3,78, -0,178,3,38,0, -727,12,1,6757,728, -5,1,3,38,0, -729,12,1,6777,730, -5,0,731,11,1, -185,0,732,4,14, -65,0,77,0,80, -0,95,0,65,0, -77,0,80,0,1, --1,733,11,1,160, -0,734,4,6,65, -0,77,0,80,0, -1,-1,3,115,0, -735,12,1,22173,736, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,737, -12,1,22253,738,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,739,12,1, -22325,740,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,741,12,1,22401, -742,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -743,12,1,22489,744, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,745,12,1, -22574,746,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,747,11,1,744, -0,748,4,24,83, -0,69,0,78,0, -83,0,79,0,82, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,749,11,1,867, -0,183,1,-1,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,750,11, -1,867,0,183,1, --1,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -751,11,1,867,0, -183,1,-1,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,752,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -753,12,1,22866,754, -5,63,3,97,0, -755,12,1,22933,756, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,757, -12,1,23026,758,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,759,12, -1,23106,760,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,761,12,1, -23142,762,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,763,12,1,23222, -764,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,765, -12,1,23294,766,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,767,12, -1,23387,768,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -769,12,1,23472,770, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,771,12, -1,23542,772,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,773,11,1, -754,0,774,4,34, -83,0,84,0,65, -0,84,0,69,0, -95,0,69,0,78, -0,84,0,82,0, -89,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,775,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -776,11,1,867,0, -183,1,-1,3,89, -0,180,777,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,778,12,1, -23781,779,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -780,12,1,23849,781, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,782, -12,1,23942,783,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,784,11, -1,769,0,785,4, -32,83,0,84,0, -65,0,84,0,69, -0,95,0,69,0, -88,0,73,0,84, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,89,0,180,786, -11,1,867,0,183, -1,-1,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,787,11,1, -867,0,183,1,-1, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,788,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,789, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,790,11,1,256, -0,791,4,10,83, -0,84,0,65,0, -84,0,69,0,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -792,11,1,867,0, -183,1,-1,3,89, -0,180,793,11,1, -867,0,183,1,-1, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,794,12,1,24391, -795,5,63,3,97, -0,180,3,70,0, -180,3,105,0,796, -12,1,24459,797,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,798,12,1, -24531,799,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,800, -12,1,24618,801,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,802,11, -1,303,0,803,4, -22,83,0,84,0, -82,0,73,0,78, -0,71,0,95,0, -84,0,89,0,80, -0,69,0,1,-1, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,804,11,1,867, -0,183,1,-1,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,805, -11,1,867,0,183, -1,-1,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,806,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,807,11,1,867, -0,183,1,-1,3, -89,0,180,808,11, -1,867,0,183,1, --1,3,75,0,178, -3,112,0,178,3, -72,0,178,3,32, -0,672,3,109,0, -809,12,1,28058,810, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,811, -12,1,28146,812,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,813,12,1, -28218,814,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,815,12,1,28298, -816,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,817, -12,1,28368,818,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,819,11, -1,591,0,820,4, -22,77,0,79,0, -78,0,69,0,89, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -821,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,822,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,823,12,1,28579, -824,5,63,3,97, -0,180,3,70,0, -180,3,105,0,825, -12,1,28647,826,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,827,12,1, -28719,828,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,829, -12,1,28806,830,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,831,12, -1,28842,832,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,833,12,1, -28918,834,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,835,12,1,29011, -836,5,63,3,97, -0,837,12,1,29078, -838,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,839,12, -1,29163,840,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,841,12,1, -29256,842,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,843,11,1,614, -0,844,4,36,77, -0,79,0,86,0, -73,0,78,0,71, -0,95,0,83,0, -84,0,65,0,82, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,-1,3,89,0, -180,845,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -846,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,847,11,1,867, -0,183,1,-1,3, -89,0,180,848,11, -1,867,0,183,1, --1,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -849,12,1,29522,850, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,851,12, -1,29594,852,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,853,12,1, -29684,854,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,855,11,1,600, -0,856,4,32,77, -0,79,0,86,0, -73,0,78,0,71, -0,95,0,69,0, -78,0,68,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,857,11,1, -867,0,183,1,-1, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -858,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,859,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,860, -11,1,867,0,183, -1,-1,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,861,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,862,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,863, -11,1,867,0,183, -1,-1,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -864,11,1,867,0, -183,1,-1,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,865,11,1, -867,0,183,1,-1, -3,69,0,178,3, -106,0,866,12,1, -30221,867,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,868,12,1,30303, -869,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,870,12, -1,30384,871,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,872,12,1,30462, -873,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -874,11,1,265,0, -875,4,8,74,0, -85,0,77,0,80, -0,1,-1,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,876,11, -1,867,0,183,1, --1,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,877,11,1, -867,0,183,1,-1, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,878, -11,1,867,0,183, -1,-1,3,66,0, -178,3,103,0,178, -3,100,0,879,12, -1,38027,880,5,63, -3,97,0,881,12, -1,38094,882,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,883,12,1, -38187,884,5,63,3, -97,0,885,12,1, -38254,886,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,887,12,1,38330, -888,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -889,12,1,38410,890, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,891,12,1, -38495,892,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,893,12,1, -38568,894,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,895,12,1,38648, -896,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,897,12, -1,38733,898,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,899,11,1, -461,0,900,4,32, -68,0,65,0,84, -0,65,0,83,0, -69,0,82,0,86, -0,69,0,82,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -901,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,902,11,1, -867,0,183,1,-1, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,903,11, -1,867,0,183,1, --1,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,904,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,905, -11,1,867,0,183, -1,-1,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,906,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,907,11,1, -867,0,183,1,-1, -3,89,0,180,908, -11,1,867,0,183, -1,-1,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -909,12,1,39187,910, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,911,12,1,39258, -912,5,63,3,97, -0,913,12,1,39325, -914,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -915,12,1,39407,916, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,917,12,1, -39498,918,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,919,12,1,39591, -920,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -921,11,1,245,0, -922,4,26,68,0, -69,0,70,0,65, -0,85,0,76,0, -84,0,95,0,83, -0,84,0,65,0, -84,0,69,0,1, --1,3,89,0,180, -923,11,1,867,0, -183,1,-1,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,924, -11,1,867,0,183, -1,-1,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,925,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,926,11,1, -867,0,183,1,-1, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,927,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,928, -12,1,39915,929,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,930,11, -1,223,0,931,4, -4,68,0,79,0, -1,-1,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,932,11,1,867, -0,183,1,-1,3, -60,0,933,12,1, -2901,934,5,2,3, -61,0,935,12,1, -3029,936,5,0,937, -11,1,148,0,938, -4,22,76,0,69, -0,83,0,83,0, -95,0,69,0,81, -0,85,0,65,0, -76,0,83,0,1, --1,3,60,0,939, -12,1,2905,940,5, -0,941,11,1,197, -0,942,4,20,76, -0,69,0,70,0, -84,0,95,0,83, -0,72,0,73,0, -70,0,84,0,1, --1,943,11,1,116, -0,944,4,20,76, -0,69,0,70,0, -84,0,95,0,65, -0,78,0,71,0, -76,0,69,0,1, --1,3,97,0,945, -12,1,9444,946,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,947,12, -1,9537,948,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,949,12,1, -9573,950,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,951, -12,1,9658,952,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,953,12, -1,9746,954,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,955,12,1, -9839,956,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,957,12,1,9875, -958,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -959,12,1,9968,960, -5,63,3,97,0, -961,12,1,10035,962, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,963,12,1, -10120,964,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,965, -12,1,10207,966,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,967,12, -1,10287,968,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,969,12,1, -10380,970,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,971,11,1,350, -0,972,4,38,65, -0,84,0,95,0, -82,0,79,0,84, -0,95,0,84,0, -65,0,82,0,71, -0,69,0,84,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -89,0,180,973,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -974,11,1,867,0, -183,1,-1,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,975, -11,1,867,0,183, -1,-1,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,976,11, -1,867,0,183,1, --1,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,977, -11,1,867,0,183, -1,-1,3,89,0, -180,978,11,1,867, -0,183,1,-1,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,979,11, -1,867,0,183,1, --1,3,89,0,180, -980,11,1,867,0, -183,1,-1,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,981,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,982,12,1,10866, -983,5,63,3,97, -0,984,12,1,10933, -985,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,986,12, -1,11018,987,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -988,12,1,11105,989, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,990, -12,1,11185,991,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,992,12, -1,11278,993,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,994,11,1, -367,0,995,4,30, -65,0,84,0,95, -0,84,0,65,0, -82,0,71,0,69, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,-1,3,89,0, -180,996,11,1,867, -0,183,1,-1,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,997,11, -1,867,0,183,1, --1,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,998,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,999,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1000,11,1, -867,0,183,1,-1, -3,89,0,180,1001, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,1002,12,1,11670, -1003,5,63,3,97, -0,1004,12,1,11737, -1005,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -1006,12,1,11811,1007, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,1008,12,1,11888, -1009,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1010,11,1,380,0, -1011,4,24,65,0, -84,0,84,0,65, -0,67,0,72,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1012,11,1,867, -0,183,1,-1,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1013,11, -1,867,0,183,1, --1,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1014, -11,1,867,0,183, -1,-1,3,89,0, -180,1015,11,1,867, -0,183,1,-1,3, -89,0,180,1016,11, -1,867,0,183,1, --1,3,57,0,647, -3,94,0,1017,12, -1,2778,1018,5,0, -1019,11,1,170,0, -1020,4,10,67,0, -65,0,82,0,69, -0,84,0,1,-1, -3,54,0,647,3, -91,0,1021,12,1, -7969,1022,5,0,1023, -11,1,126,0,1024, -4,24,76,0,69, -0,70,0,84,0, -95,0,66,0,82, -0,65,0,67,0, -75,0,69,0,84, -0,1,-1,3,51, -0,647,3,88,0, -178,3,48,0,1025, -12,1,9070,1026,5, -13,3,48,0,647, -3,88,0,1027,12, -1,9149,1028,5,22, -3,48,0,1029,12, -1,9199,1030,5,22, -3,48,0,1029,3, -70,0,1029,3,55, -0,1029,3,66,0, -1029,3,51,0,1029, -3,99,0,1029,3, -65,0,1029,3,69, -0,1029,3,54,0, -1029,3,102,0,1029, -3,50,0,1029,3, -98,0,1029,3,57, -0,1029,3,68,0, -1029,3,53,0,1029, -3,101,0,1029,3, -49,0,1029,3,97, -0,1029,3,56,0, -1029,3,67,0,1029, -3,52,0,1029,3, -100,0,1029,1031,11, -1,885,0,1032,4, -40,72,0,69,0, -88,0,95,0,73, -0,78,0,84,0, -69,0,71,0,69, -0,82,0,95,0, -67,0,79,0,78, -0,83,0,84,0, -65,0,78,0,84, -0,1,-1,3,70, -0,1029,3,55,0, -1029,3,66,0,1029, -3,51,0,1029,3, -99,0,1029,3,65, -0,1029,3,69,0, -1029,3,54,0,1029, -3,102,0,1029,3, -50,0,1029,3,98, -0,1029,3,57,0, -1029,3,68,0,1029, -3,53,0,1029,3, -101,0,1029,3,49, -0,1029,3,97,0, -1029,3,56,0,1029, -3,67,0,1029,3, -52,0,1029,3,100, -0,1029,0,165,1, --1,3,55,0,647, -3,51,0,647,3, -54,0,647,3,50, -0,647,3,120,0, -1027,3,57,0,647, -3,46,0,649,3, -53,0,647,3,49, -0,647,3,56,0, -647,3,52,0,647, -1033,11,1,879,0, -667,1,-1,3,125, -0,1034,12,1,7483, -1035,5,0,1036,11, -1,56,0,1037,4, -22,82,0,73,0, -71,0,72,0,84, -0,95,0,66,0, -82,0,65,0,67, -0,69,0,1,-1, -3,85,0,178,3, -45,0,1038,12,1, -8090,1039,5,2,3, -61,0,1040,12,1, -8098,1041,5,0,1042, -11,1,22,0,1043, -4,24,77,0,73, -0,78,0,85,0, -83,0,95,0,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,-1,3,45, -0,1044,12,1,8243, -1045,5,0,1046,11, -1,10,0,1047,4, -18,68,0,69,0, -67,0,82,0,69, -0,77,0,69,0, -78,0,84,0,1, --1,1048,11,1,86, -0,1049,4,10,77, -0,73,0,78,0, -85,0,83,0,1, --1,3,122,0,178, -3,82,0,178,3, -42,0,1050,12,1, -6395,1051,5,1,3, -61,0,1052,12,1, -6403,1053,5,0,1054, -11,1,28,0,1055, -4,22,83,0,84, -0,65,0,82,0, -95,0,69,0,81, -0,85,0,65,0, -76,0,83,0,1, --1,1056,11,1,91, -0,1057,4,8,83, -0,84,0,65,0, -82,0,1,-1,3, -119,0,1058,12,1, -37426,1059,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,1060,12, -1,37503,1061,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,1062,12,1,37571, -1063,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,1064,12, -1,37662,1065,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,1066,12,1, -37742,1067,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1068,11,1,229, -0,1069,4,10,87, -0,72,0,73,0, -76,0,69,0,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1070,11,1,867,0, -183,1,-1,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1071, -11,1,867,0,183, -1,-1,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1072,11,1, -867,0,183,1,-1, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1073,11,1, -867,0,183,1,-1, -3,79,0,178,3, -116,0,1074,12,1, -44630,1075,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -1076,12,1,44698,1077, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,1078,12,1, -44779,1079,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,1080,12,1,44859, -1081,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,1082,12, -1,44944,1083,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1084,11,1, -783,0,1085,4,22, -84,0,73,0,77, -0,69,0,82,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1086,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1087,11,1, -867,0,183,1,-1, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1088,11,1,867, -0,183,1,-1,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,1089,12,1, -45195,1090,5,63,3, -97,0,1091,12,1, -45262,1092,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -1093,12,1,45334,1094, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,1095, -12,1,45410,1096,5, -63,3,97,0,1097, -12,1,45477,1098,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,1099,12, -1,45551,1100,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,1101,12,1, -45644,1102,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -1103,12,1,45712,1104, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,1105, -12,1,45800,1106,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,1107,12,1, -45872,1108,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,1109,12,1,45908, -1110,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,1111,12, -1,45993,1112,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,1113,12,1, -46073,1114,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,1115,12,1,46149, -1116,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -1117,12,1,46231,1118, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,1119,12,1, -46322,1120,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,1121,12,1,46415, -1122,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1123,11,1,845,0, -1124,4,48,84,0, -82,0,65,0,78, -0,83,0,65,0, -67,0,84,0,73, -0,79,0,78,0, -95,0,82,0,69, -0,83,0,85,0, -76,0,84,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,89, -0,180,1125,11,1, -867,0,183,1,-1, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1126,11,1,867, -0,183,1,-1,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1127,11, -1,867,0,183,1, --1,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1128,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1129,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1130,11,1,867, -0,183,1,-1,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1131,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1132,11,1,867, -0,183,1,-1,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1133,11, -1,867,0,183,1, --1,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1134,11,1,867, -0,183,1,-1,3, -89,0,180,1135,11, -1,867,0,183,1, --1,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1136,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1137,11,1,867, -0,183,1,-1,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1138,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1139,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1140,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,1141,12,1,47238, -1142,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -1143,12,1,47320,1144, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,1145, -12,1,47394,1146,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -1147,12,1,47471,1148, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,1149, -12,1,47507,1150,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,1151,12, -1,47583,1152,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,1153,12,1, -47676,1154,5,63,3, -97,0,1155,12,1, -47743,1156,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,1157, -12,1,47828,1158,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,1159,12, -1,47921,1160,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1161,11,1, -801,0,1162,4,34, -84,0,79,0,85, -0,67,0,72,0, -95,0,83,0,84, -0,65,0,82,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,89,0,180, -1163,11,1,867,0, -183,1,-1,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1164, -11,1,867,0,183, -1,-1,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1165,11,1,867,0, -183,1,-1,3,89, -0,180,1166,11,1, -867,0,183,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,1167, -12,1,48187,1168,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,1169,12,1, -48259,1170,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,1171,12,1,48349, -1172,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1173,11,1,816,0, -1174,4,30,84,0, -79,0,85,0,67, -0,72,0,95,0, -69,0,78,0,68, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1175, -11,1,867,0,183, -1,-1,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1176,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1177, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1178,11,1,792, -0,1179,4,22,84, -0,79,0,85,0, -67,0,72,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,-1,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1180,11,1,867,0, -183,1,-1,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1181,11,1, -867,0,183,1,-1, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1182, -11,1,867,0,183, -1,-1,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1183,11,1,867, -0,183,1,-1,3, -76,0,178,3,113, -0,178,3,73,0, -178,3,33,0,1184, -12,1,4709,1185,5, -1,3,61,0,1186, -12,1,4717,1187,5, -0,1188,11,1,142, -0,1189,4,36,69, -0,88,0,67,0, -76,0,65,0,77, -0,65,0,84,0, -73,0,79,0,78, -0,95,0,69,0, -81,0,85,0,65, -0,76,0,83,0, -1,-1,1190,11,1, -180,0,1191,4,22, -69,0,88,0,67, -0,76,0,65,0, -77,0,65,0,84, -0,73,0,79,0, -78,0,1,-1,3, -110,0,1192,12,1, -14009,1193,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,1194,12,1,14097, -1195,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -1196,12,1,14133,1197, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,1198, -12,1,14209,1199,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,1200,12, -1,14289,1201,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,1202,12,1,14361, -1203,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -1204,12,1,14437,1205, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,1206, -12,1,14525,1207,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,1208,12,1,14610, -1209,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1210,11,1,630,0, -1211,4,30,78,0, -79,0,95,0,83, -0,69,0,78,0, -83,0,79,0,82, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1212,11,1,867, -0,183,1,-1,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1213,11, -1,867,0,183,1, --1,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1214,11,1,867,0, -183,1,-1,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1215,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1216,11,1,867,0, -183,1,-1,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1217,11,1, -867,0,183,1,-1, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,1218, -12,1,15030,1219,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,1220,12, -1,15066,1221,5,63, -3,97,0,1222,12, -1,15133,1223,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,1224,12,1, -15226,1225,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,1226,12,1,15262, -1227,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,1228,12, -1,15347,1229,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,1230,12,1, -15435,1231,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,1232,12,1,15528, -1233,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -1234,12,1,15564,1235, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,1236, -12,1,15657,1237,5, -63,3,97,0,1238, -12,1,15724,1239,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,1240,12,1,15809, -1241,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,1242,12, -1,15896,1243,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,1244,12,1, -15976,1245,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,1246,12,1,16069, -1247,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1248,11,1,643,0, -1249,4,46,78,0, -79,0,84,0,95, -0,65,0,84,0, -95,0,82,0,79, -0,84,0,95,0, -84,0,65,0,82, -0,71,0,69,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,89,0,180, -1250,11,1,867,0, -183,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1251,11,1, -867,0,183,1,-1, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1252,11,1,867, -0,183,1,-1,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1253,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1254,11,1,867, -0,183,1,-1,3, -89,0,180,1255,11, -1,867,0,183,1, --1,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1256,11,1,867,0, -183,1,-1,3,89, -0,180,1257,11,1, -867,0,183,1,-1, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1258, -11,1,867,0,183, -1,-1,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,1259,12, -1,16555,1260,5,63, -3,97,0,1261,12, -1,16622,1262,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -1263,12,1,16707,1264, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,1265,12,1, -16794,1266,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,1267,12,1,16874, -1268,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -1269,12,1,16967,1270, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1271, -11,1,664,0,1272, -4,38,78,0,79, -0,84,0,95,0, -65,0,84,0,95, -0,84,0,65,0, -82,0,71,0,69, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,-1,3,89,0, -180,1273,11,1,867, -0,183,1,-1,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1274,11, -1,867,0,183,1, --1,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1275,11,1, -867,0,183,1,-1, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1276,11,1,867, -0,183,1,-1,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1277,11,1, -867,0,183,1,-1, -3,89,0,180,1278, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1279,11,1,867, -0,183,1,-1,3, -89,0,180,1280,11, -1,867,0,183,1, --1,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1281, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1282,11,1,867, -0,183,1,-1,3, -89,0,180,1283,11, -1,867,0,183,1, --1,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1284,11,1,867,0, -183,1,-1,3,70, -0,178,3,107,0, -1285,12,1,21812,1286, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,1287, -12,1,21892,1288,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,1289,12,1, -21962,1290,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1291,11,1,313, -0,1292,4,16,75, -0,69,0,89,0, -95,0,84,0,89, -0,80,0,69,0, -1,-1,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1293,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1294, -11,1,867,0,183, -1,-1,3,67,0, -178,3,104,0,1295, -12,1,24934,1296,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,1297,12, -1,25027,1298,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,1299,12,1, -25120,1300,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -1301,12,1,25198,1302, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,1303, -12,1,25234,1304,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,1305,12,1,25319, -1306,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -1307,12,1,25399,1308, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -1309,12,1,25468,1310, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,1311, -12,1,25550,1312,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,180,3,83, -0,180,3,56,0, -180,3,118,0,180, -3,99,0,180,3, -72,0,180,3,107, -0,180,3,80,0, -180,3,53,0,180, -3,115,0,180,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,1313,12, -1,25630,1314,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,1315,12,1, -25706,1316,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,1317,12,1,25799, -1318,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1319,11,1,829,0, -1320,4,36,72,0, -84,0,84,0,80, -0,95,0,82,0, -69,0,81,0,85, -0,69,0,83,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,89,0,180, -1321,11,1,867,0, -183,1,-1,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1322,11,1, -867,0,183,1,-1, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1323, -11,1,867,0,183, -1,-1,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1324,11,1,867, -0,183,1,-1,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,1325,12,1, -26075,1326,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -1327,12,1,26153,1328, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,1329, -12,1,26241,1330,5, -63,3,97,0,180, -3,70,0,180,3, -105,0,180,3,78, -0,180,3,51,0, -180,3,113,0,180, -3,86,0,180,3, -121,0,180,3,67, -0,180,3,102,0, -180,3,75,0,180, -3,48,0,180,3, -110,0,1331,12,1, -26313,1332,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,1333,12,1,26389, -1334,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -1335,12,1,26469,1336, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1337, -11,1,484,0,1338, -4,38,72,0,84, -0,84,0,80,0, -95,0,82,0,69, -0,83,0,80,0, -79,0,78,0,83, -0,69,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,-1,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1339,11,1,867, -0,183,1,-1,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1340,11, -1,867,0,183,1, --1,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1341,11,1,867, -0,183,1,-1,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1342,11, -1,867,0,183,1, --1,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1343,11,1,867, -0,183,1,-1,3, -88,0,180,3,69, -0,180,3,104,0, -180,3,77,0,180, -3,50,0,180,3, -112,0,180,3,85, -0,180,3,120,0, -180,3,66,0,180, -3,101,0,180,3, -74,0,180,3,109, -0,180,3,82,0, -180,3,55,0,180, -3,117,0,180,3, -90,0,180,3,98, -0,180,3,71,0, -180,3,106,0,180, -3,79,0,180,3, -52,0,180,3,114, -0,180,3,87,0, -180,3,122,0,180, -3,95,0,180,3, -68,0,180,3,103, -0,180,3,76,0, -180,3,49,0,180, -3,111,0,180,3, -84,0,180,3,57, -0,180,3,119,0, -180,3,65,0,180, -3,100,0,180,3, -73,0,180,3,108, -0,180,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1344,11, -1,867,0,183,1, --1,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1345,11,1,867,0, -183,1,-1,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1346, -11,1,867,0,183, -1,-1,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1347,11,1,867, -0,183,1,-1,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1348, -11,1,867,0,183, -1,-1,3,89,0, -180,1349,11,1,867, -0,183,1,-1,3, -89,0,180,1350,11, -1,867,0,183,1, --1,3,64,0,1351, -12,1,6636,1352,5, -0,1353,11,1,106, -0,1354,4,4,65, -0,84,0,1,-1, -3,101,0,1355,12, -1,27097,1356,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -1357,12,1,27178,1358, -5,63,3,97,0, -1359,12,1,27245,1360, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,1361,12, -1,27313,1362,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,180,3,88, -0,180,3,69,0, -180,3,104,0,180, -3,77,0,180,3, -50,0,180,3,112, -0,180,3,85,0, -180,3,120,0,180, -3,66,0,180,3, -101,0,180,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -1363,12,1,27404,1364, -5,63,3,97,0, -180,3,70,0,180, -3,105,0,180,3, -78,0,180,3,51, -0,180,3,113,0, -180,3,86,0,180, -3,121,0,180,3, -67,0,180,3,102, -0,180,3,75,0, -180,3,48,0,180, -3,110,0,180,3, -83,0,180,3,56, -0,180,3,118,0, -180,3,99,0,180, -3,72,0,180,3, -107,0,180,3,80, -0,180,3,53,0, -180,3,115,0,180, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1365, -11,1,475,0,1366, -4,22,69,0,77, -0,65,0,73,0, -76,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, --1,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1367,11,1, -867,0,183,1,-1, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1368,11,1,867,0, -183,1,-1,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,180,3,74,0, -180,3,109,0,180, -3,82,0,180,3, -55,0,180,3,117, -0,180,3,90,0, -180,3,98,0,180, -3,71,0,180,3, -106,0,180,3,79, -0,180,3,52,0, -180,3,114,0,180, -3,87,0,180,3, -122,0,180,3,95, -0,180,3,68,0, -180,3,103,0,180, -3,76,0,180,3, -49,0,180,3,111, -0,180,3,84,0, -180,3,57,0,180, -3,119,0,180,3, -65,0,180,3,100, -0,180,3,73,0, -180,3,108,0,180, -3,81,0,180,3, -54,0,180,3,116, -0,180,3,89,0, -180,1369,11,1,867, -0,183,1,-1,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,1370,12, -1,27668,1371,5,63, -3,97,0,180,3, -70,0,180,3,105, -0,180,3,78,0, -180,3,51,0,180, -3,113,0,180,3, -86,0,180,3,121, -0,180,3,67,0, -180,3,102,0,180, -3,75,0,180,3, -48,0,180,3,110, -0,180,3,83,0, -180,3,56,0,180, -3,118,0,180,3, -99,0,180,3,72, -0,180,3,107,0, -180,3,80,0,180, -3,53,0,180,3, -115,0,1372,12,1, -27744,1373,5,63,3, -97,0,180,3,70, -0,180,3,105,0, -180,3,78,0,180, -3,51,0,180,3, -113,0,180,3,86, -0,180,3,121,0, -180,3,67,0,180, -3,102,0,180,3, -75,0,180,3,48, -0,180,3,110,0, -180,3,83,0,180, -3,56,0,180,3, -118,0,180,3,99, -0,180,3,72,0, -180,3,107,0,180, -3,80,0,180,3, -53,0,180,3,115, -0,180,3,88,0, -180,3,69,0,180, -3,104,0,180,3, -77,0,180,3,50, -0,180,3,112,0, -180,3,85,0,180, -3,120,0,180,3, -66,0,180,3,101, -0,1374,12,1,27824, -1375,5,63,3,97, -0,180,3,70,0, -180,3,105,0,180, -3,78,0,180,3, -51,0,180,3,113, -0,180,3,86,0, -180,3,121,0,180, -3,67,0,180,3, -102,0,180,3,75, -0,180,3,48,0, -180,3,110,0,180, -3,83,0,180,3, -56,0,180,3,118, -0,180,3,99,0, -180,3,72,0,180, -3,107,0,180,3, -80,0,180,3,53, -0,180,3,115,0, -180,3,88,0,180, -3,69,0,180,3, -104,0,180,3,77, -0,180,3,50,0, -180,3,112,0,180, -3,85,0,180,3, -120,0,180,3,66, -0,180,3,101,0, -180,3,74,0,180, -3,109,0,180,3, -82,0,180,3,55, -0,180,3,117,0, -180,3,90,0,180, -3,98,0,180,3, -71,0,180,3,106, -0,180,3,79,0, -180,3,52,0,180, -3,114,0,180,3, -87,0,180,3,122, -0,180,3,95,0, -180,3,68,0,180, -3,103,0,180,3, -76,0,180,3,49, -0,180,3,111,0, -180,3,84,0,180, -3,57,0,180,3, -119,0,180,3,65, -0,180,3,100,0, -180,3,73,0,180, -3,108,0,180,3, -81,0,180,3,54, -0,180,3,116,0, -180,3,89,0,180, -1376,11,1,215,0, -1377,4,8,69,0, -76,0,83,0,69, -0,1,-1,3,74, -0,180,3,109,0, -180,3,82,0,180, -3,55,0,180,3, -117,0,180,3,90, -0,180,3,98,0, -180,3,71,0,180, -3,106,0,180,3, -79,0,180,3,52, -0,180,3,114,0, -180,3,87,0,180, -3,122,0,180,3, -95,0,180,3,68, -0,180,3,103,0, -180,3,76,0,180, -3,49,0,180,3, -111,0,180,3,84, -0,180,3,57,0, -180,3,119,0,180, -3,65,0,180,3, -100,0,180,3,73, -0,180,3,108,0, -180,3,81,0,180, -3,54,0,180,3, -116,0,180,3,89, -0,180,1378,11,1, -867,0,183,1,-1, -3,88,0,180,3, -69,0,180,3,104, -0,180,3,77,0, -180,3,50,0,180, -3,112,0,180,3, -85,0,180,3,120, -0,180,3,66,0, -180,3,101,0,180, -3,74,0,180,3, -109,0,180,3,82, -0,180,3,55,0, -180,3,117,0,180, -3,90,0,180,3, -98,0,180,3,71, -0,180,3,106,0, -180,3,79,0,180, -3,52,0,180,3, -114,0,180,3,87, -0,180,3,122,0, -180,3,95,0,180, -3,68,0,180,3, -103,0,180,3,76, -0,180,3,49,0, -180,3,111,0,180, -3,84,0,180,3, -57,0,180,3,119, -0,180,3,65,0, -180,3,100,0,180, -3,73,0,180,3, -108,0,180,3,81, -0,180,3,54,0, -180,3,116,0,180, -3,89,0,180,1379, -11,1,867,0,183, -1,-1,3,81,0, -180,3,54,0,180, -3,116,0,180,3, -89,0,180,1380,11, -1,867,0,183,1, --1,3,61,0,1381, -12,1,3985,1382,5, -1,3,61,0,1383, -12,1,3993,1384,5, -0,1385,11,1,136, -0,1386,4,26,69, -0,81,0,85,0, -65,0,76,0,83, -0,95,0,69,0, -81,0,85,0,65, -0,76,0,83,0, -1,-1,1387,11,1, -66,0,1388,4,12, -69,0,81,0,85, -0,65,0,76,0, -83,0,1,-1,3, -98,0,178,3,95, -0,178,3,55,0, -647,3,52,0,647, -3,89,0,178,3, -49,0,647,3,9, -0,672,3,126,0, -1389,12,1,3864,1390, -5,0,1391,11,1, -175,0,1392,4,10, -84,0,73,0,76, -0,68,0,69,0, -1,-1,3,86,0, -178,3,46,0,1393, -12,1,5674,1394,5, -14,3,48,0,651, -3,70,0,653,3, -55,0,651,3,51, -0,651,3,69,0, -657,3,54,0,651, -3,102,0,653,3, -50,0,651,3,57, -0,651,3,53,0, -651,3,101,0,657, -3,49,0,651,3, -56,0,651,3,52, -0,651,1395,11,1, -111,0,1396,4,12, -80,0,69,0,82, -0,73,0,79,0, -68,0,1,-1,3, -123,0,1397,12,1, -7726,1398,5,0,1399, -11,1,51,0,1400, -4,20,76,0,69, -0,70,0,84,0, -95,0,66,0,82, -0,65,0,67,0, -69,0,1,-1,3, -83,0,178,3,43, -0,1401,12,1,4226, -1402,5,2,3,61, -0,1403,12,1,4234, -1404,5,0,1405,11, -1,16,0,1406,4, -22,80,0,76,0, -85,0,83,0,95, -0,69,0,81,0, -85,0,65,0,76, -0,83,0,1,-1, -3,43,0,1407,12, -1,4355,1408,5,0, -1409,11,1,2,0, -1410,4,18,73,0, -78,0,67,0,82, -0,69,0,77,0, -69,0,78,0,84, -0,1,-1,1411,11, -1,81,0,1412,4, -8,80,0,76,0, -85,0,83,0,1, --1,3,120,0,178, -3,80,0,178,3, -40,0,1413,12,1, -7848,1414,5,0,1415, -11,1,71,0,1416, -4,20,76,0,69, -0,70,0,84,0, -95,0,80,0,65, -0,82,0,69,0, -78,0,1,-1,0, -165,1,-1,1417,4, -12,83,0,84,0, -82,0,73,0,78, -0,71,0,1418,12, -1,1095,1419,5,119, -3,238,22,1420,12, -1,1096,1421,5,0, -1422,11,1,968,0, -165,1,-1,3,117, -0,1420,3,63,32, -1420,3,37,0,1420, -3,114,0,1420,3, -74,0,1420,3,34, -0,1423,12,1,1836, -1424,5,0,1425,11, -1,1032,0,165,1, --1,3,111,0,1420, -3,71,0,1420,3, -108,0,1420,3,68, -0,1420,3,105,0, -1420,3,65,0,1420, -3,102,0,1420,3, -62,0,1420,3,99, -0,1420,3,59,0, -1420,3,96,0,1420, -3,96,6,1420,3, -173,0,1420,3,93, -0,1420,3,53,0, -1420,3,13,0,1420, -3,170,0,1420,3, -90,0,1420,3,50, -0,1420,3,10,0, -1426,12,1,1975,1427, -5,0,1428,11,1, -974,0,165,1,-1, -3,87,0,1420,3, -47,0,1420,3,100, -0,1420,3,124,0, -1420,3,84,0,1420, -3,44,0,1420,3, -121,0,1420,3,81, -0,1420,3,41,0, -1420,3,1,0,1420, -3,59,15,1420,3, -78,0,1420,3,38, -0,1420,3,58,15, -1420,3,115,0,1420, -3,75,0,1420,3, -35,0,1420,3,192, -0,1420,3,112,0, -1420,3,72,0,1420, -3,32,0,1420,3, -109,0,1420,3,69, -0,1420,3,187,1, -1420,3,106,0,1420, -3,66,0,1420,3, -103,0,1420,3,77, -0,1420,3,3,9, -1420,3,118,0,1420, -3,60,0,1420,3, -0,3,1420,3,197, -1,1420,3,176,2, -1420,3,57,0,1420, -3,70,0,1420,3, -94,0,1420,3,54, -0,1420,3,171,0, -1420,3,91,0,1420, -3,51,0,1420,3, -88,0,1420,3,48, -0,1420,3,125,0, -1420,3,85,0,1420, -3,56,0,1420,3, -97,0,1420,3,122, -0,1420,3,82,0, -1420,3,42,0,1420, -3,0,6,1420,3, -119,0,1420,3,79, -0,1420,3,41,32, -1420,3,116,0,1420, -3,76,0,1420,3, -36,0,1420,3,113, -0,1420,3,73,0, -1420,3,33,0,1420, -3,110,0,1420,3, -40,32,1420,3,0, -224,1420,3,187,0, -1420,3,107,0,1420, -3,67,0,1420,3, -104,0,1420,3,64, -0,1420,3,101,0, -1420,3,61,0,1420, -3,178,0,1420,3, -98,0,1420,3,45, -0,1420,3,136,4, -1420,3,95,0,1420, -3,55,0,1420,3, -172,0,1420,3,92, -0,1429,12,1,1229, -1430,5,4,3,116, -0,1431,12,1,1682, -1432,5,0,1433,11, -1,991,0,165,1, --1,3,34,0,1434, -12,1,1370,1435,5, -0,1436,11,1,1003, -0,165,1,-1,3, -92,0,1437,12,1, -1243,1438,5,0,1439, -11,1,1015,0,165, -1,-1,3,110,0, -1440,12,1,1541,1441, -5,0,1442,11,1, -979,0,165,1,-1, -1443,11,1,1027,0, -165,1,-1,3,52, -0,1420,3,89,0, -1420,3,49,0,1420, -3,9,0,1420,3, -126,0,1420,3,86, -0,1420,3,46,0, -1420,3,123,0,1420, -3,83,0,1420,3, -43,0,1420,3,160, -0,1420,3,120,0, -1420,3,80,0,1420, -3,40,0,1420,0, -165,1,-1,1444,5, -94,844,1445,10,844, -1,76,1400,1446,10, -1400,1,12,1043,1447, -10,1043,1,7,671, -1448,10,671,1,28, -1366,1449,10,1366,1, -67,1338,1450,10,1338, -1,68,1451,4,30, -83,0,84,0,82, -0,73,0,78,0, -71,0,95,0,67, -0,79,0,78,0, -83,0,84,0,65, -0,78,0,84,0, -1452,10,1451,1,3, -1396,1453,10,1396,1, -24,856,1454,10,856, -1,75,192,1455,10, -192,1,22,944,1456, -10,944,1,25,707, -1457,10,707,1,17, -972,1458,10,972,1, -58,1416,1459,10,1416, -1,16,234,1460,10, -234,1,50,585,1461, -10,585,1,65,1272, -1462,10,1272,1,79, -732,1463,10,732,1, -38,1211,1464,10,1211, -1,77,617,1465,10, -617,1,64,820,1466, -10,820,1,74,938, -1467,10,938,1,31, -509,1468,10,509,1, -51,1179,1469,10,1179, -1,88,1320,1470,10, -1320,1,91,1057,1471, -10,1057,1,20,1037, -1472,10,1037,1,13, -1406,1473,10,1406,1, -6,1055,1474,10,1055, -1,8,464,1475,10, -464,1,72,495,1476, -10,495,1,42,1020, -1477,10,1020,1,35, -774,1478,10,774,1, -85,785,1479,10,785, -1,86,791,1480,10, -791,1,48,1354,1481, -10,1354,1,23,1249, -1482,10,1249,1,78, -548,1483,10,548,1, -41,699,1484,10,699, -1,34,667,1485,10, -667,1,94,1410,1486, -10,1410,1,4,1174, -1487,10,1174,1,90, -646,1488,10,646,1, -11,566,1489,10,566, -1,61,922,1490,10, -922,1,47,1085,1491, -10,1085,1,87,190, -1492,10,190,1,10, -1124,1493,10,1124,1, -92,1386,1494,10,1386, -1,29,734,1495,10, -734,1,33,216,1496, -10,216,1,82,486, -1497,10,486,1,57, -803,1498,10,803,1, -53,1032,1499,10,1032, -1,95,1292,1500,10, -1292,1,54,995,1501, -10,995,1,59,1189, -1502,10,1189,1,30, -1024,1503,10,1024,1, -27,1388,1504,10,1388, -1,15,1162,1505,10, -1162,1,89,875,1506, -10,875,1,49,278, -1507,10,278,1,83, -411,1508,10,411,1, -71,900,1509,10,900, -1,66,1047,1510,10, -1047,1,5,1191,1511, -10,1191,1,37,336, -1512,10,336,1,81, -544,1513,10,544,1, -32,656,1514,10,656, -1,96,423,1515,10, -423,1,70,691,1516, -10,691,1,21,428, -1517,10,428,1,69, -1069,1518,10,1069,1, -45,312,1519,10,312, -1,56,634,1520,10, -634,1,62,680,1521, -10,680,1,9,534, -1522,10,534,1,52, -942,1523,10,942,1, -40,1392,1524,10,1392, -1,36,360,1525,10, -360,1,80,703,1526, -10,703,1,14,523, -1527,10,523,1,46, -748,1528,10,748,1, -84,183,1529,10,183, -1,93,1377,1530,10, -1377,1,43,721,1531, -10,721,1,55,697, -1532,10,697,1,39, -1412,1533,10,1412,1, -18,1011,1534,10,1011, -1,60,629,1535,10, -629,1,63,550,1536, -10,550,1,26,1049, -1537,10,1049,1,19, -931,1538,10,931,1, -44,483,1539,10,483, -1,73,1540,5,0,0}; - new Tfactory(this,"MOVING_START_EVENT",new TCreator(MOVING_START_EVENT_factory)); - new Tfactory(this,"LEFT_BRACE",new TCreator(LEFT_BRACE_factory)); - new Tfactory(this,"MINUS_EQUALS",new TCreator(MINUS_EQUALS_factory)); - new Tfactory(this,"RIGHT_BRACKET",new TCreator(RIGHT_BRACKET_factory)); - new Tfactory(this,"EMAIL_EVENT",new TCreator(EMAIL_EVENT_factory)); - new Tfactory(this,"HTTP_RESPONSE_EVENT",new TCreator(HTTP_RESPONSE_EVENT_factory)); - new Tfactory(this,"STRING_CONSTANT",new TCreator(STRING_CONSTANT_factory)); - new Tfactory(this,"PERIOD",new TCreator(PERIOD_factory)); - new Tfactory(this,"MOVING_END_EVENT",new TCreator(MOVING_END_EVENT_factory)); - new Tfactory(this,"PERCENT",new TCreator(PERCENT_factory)); - new Tfactory(this,"LEFT_ANGLE",new TCreator(LEFT_ANGLE_factory)); - new Tfactory(this,"RIGHT_PAREN",new TCreator(RIGHT_PAREN_factory)); - new Tfactory(this,"AT_ROT_TARGET_EVENT",new TCreator(AT_ROT_TARGET_EVENT_factory)); - new Tfactory(this,"LEFT_PAREN",new TCreator(LEFT_PAREN_factory)); - new Tfactory(this,"RETURN",new TCreator(RETURN_factory)); - new Tfactory(this,"CONTROL_EVENT",new TCreator(CONTROL_EVENT_factory)); - new Tfactory(this,"NOT_AT_TARGET_EVENT",new TCreator(NOT_AT_TARGET_EVENT_factory)); - new Tfactory(this,"AMP_AMP",new TCreator(AMP_AMP_factory)); - new Tfactory(this,"NO_SENSOR_EVENT",new TCreator(NO_SENSOR_EVENT_factory)); - new Tfactory(this,"COLLISION_START_EVENT",new TCreator(COLLISION_START_EVENT_factory)); - new Tfactory(this,"MONEY_EVENT",new TCreator(MONEY_EVENT_factory)); - new Tfactory(this,"LESS_EQUALS",new TCreator(LESS_EQUALS_factory)); - new Tfactory(this,"INTEGER_TYPE",new TCreator(INTEGER_TYPE_factory)); - new Tfactory(this,"TOUCH_EVENT",new TCreator(TOUCH_EVENT_factory)); - new Tfactory(this,"HTTP_REQUEST_EVENT",new TCreator(HTTP_REQUEST_EVENT_factory)); - new Tfactory(this,"STAR",new TCreator(STAR_factory)); - new Tfactory(this,"RIGHT_BRACE",new TCreator(RIGHT_BRACE_factory)); - new Tfactory(this,"PLUS_EQUALS",new TCreator(PLUS_EQUALS_factory)); - new Tfactory(this,"STAR_EQUALS",new TCreator(STAR_EQUALS_factory)); - new Tfactory(this,"LINK_MESSAGE_EVENT",new TCreator(LINK_MESSAGE_EVENT_factory)); - new Tfactory(this,"IF",new TCreator(IF_factory)); - new Tfactory(this,"CARET",new TCreator(CARET_factory)); - new Tfactory(this,"STATE_ENTRY_EVENT",new TCreator(STATE_ENTRY_EVENT_factory)); - new Tfactory(this,"STATE_EXIT_EVENT",new TCreator(STATE_EXIT_EVENT_factory)); - new Tfactory(this,"STATE",new TCreator(STATE_factory)); - new Tfactory(this,"AT",new TCreator(AT_factory)); - new Tfactory(this,"NOT_AT_ROT_TARGET_EVENT",new TCreator(NOT_AT_ROT_TARGET_EVENT_factory)); - new Tfactory(this,"RIGHT_SHIFT",new TCreator(RIGHT_SHIFT_factory)); - new Tfactory(this,"STROKE",new TCreator(STROKE_factory)); - new Tfactory(this,"INTEGER_CONSTANT",new TCreator(INTEGER_CONSTANT_factory)); - new Tfactory(this,"INCREMENT",new TCreator(INCREMENT_factory)); - new Tfactory(this,"TOUCH_END_EVENT",new TCreator(TOUCH_END_EVENT_factory)); - new Tfactory(this,"SEMICOLON",new TCreator(SEMICOLON_factory)); - new Tfactory(this,"CHANGED_EVENT",new TCreator(CHANGED_EVENT_factory)); - new Tfactory(this,"DEFAULT_STATE",new TCreator(DEFAULT_STATE_factory)); - new Tfactory(this,"TIMER_EVENT",new TCreator(TIMER_EVENT_factory)); - new Tfactory(this,"PERCENT_EQUALS",new TCreator(PERCENT_EQUALS_factory)); - new Tfactory(this,"TRANSACTION_RESULT_EVENT",new TCreator(TRANSACTION_RESULT_EVENT_factory)); - new Tfactory(this,"EQUALS_EQUALS",new TCreator(EQUALS_EQUALS_factory)); - new Tfactory(this,"AMP",new TCreator(AMP_factory)); - new Tfactory(this,"REMOTE_DATA_EVENT",new TCreator(REMOTE_DATA_EVENT_factory)); - new Tfactory(this,"LIST_TYPE",new TCreator(LIST_TYPE_factory)); - new Tfactory(this,"STRING_TYPE",new TCreator(STRING_TYPE_factory)); - new Tfactory(this,"HEX_INTEGER_CONSTANT",new TCreator(HEX_INTEGER_CONSTANT_factory)); - new Tfactory(this,"KEY_TYPE",new TCreator(KEY_TYPE_factory)); - new Tfactory(this,"AT_TARGET_EVENT",new TCreator(AT_TARGET_EVENT_factory)); - new Tfactory(this,"EXCLAMATION_EQUALS",new TCreator(EXCLAMATION_EQUALS_factory)); - new Tfactory(this,"LEFT_BRACKET",new TCreator(LEFT_BRACKET_factory)); - new Tfactory(this,"EQUALS",new TCreator(EQUALS_factory)); - new Tfactory(this,"TOUCH_START_EVENT",new TCreator(TOUCH_START_EVENT_factory)); - new Tfactory(this,"JUMP",new TCreator(JUMP_factory)); - new Tfactory(this,"RUN_TIME_PERMISSIONS_EVENT",new TCreator(RUN_TIME_PERMISSIONS_EVENT_factory)); - new Tfactory(this,"LAND_COLLISION_START_EVENT",new TCreator(LAND_COLLISION_START_EVENT_factory)); - new Tfactory(this,"DATASERVER_EVENT",new TCreator(DATASERVER_EVENT_factory)); - new Tfactory(this,"DECREMENT",new TCreator(DECREMENT_factory)); - new Tfactory(this,"EXCLAMATION",new TCreator(EXCLAMATION_factory)); - new Tfactory(this,"ON_REZ_EVENT",new TCreator(ON_REZ_EVENT_factory)); - new Tfactory(this,"GREATER_EQUALS",new TCreator(GREATER_EQUALS_factory)); - new Tfactory(this,"FLOAT_CONSTANT",new TCreator(FLOAT_CONSTANT_factory)); - new Tfactory(this,"LAND_COLLISION_END_EVENT",new TCreator(LAND_COLLISION_END_EVENT_factory)); - new Tfactory(this,"SLASH",new TCreator(SLASH_factory)); - new Tfactory(this,"LAND_COLLISION_EVENT",new TCreator(LAND_COLLISION_EVENT_factory)); - new Tfactory(this,"WHILE",new TCreator(WHILE_factory)); - new Tfactory(this,"ROTATION_TYPE",new TCreator(ROTATION_TYPE_factory)); - new Tfactory(this,"COLLISION_EVENT",new TCreator(COLLISION_EVENT_factory)); - new Tfactory(this,"SLASH_EQUALS",new TCreator(SLASH_EQUALS_factory)); - new Tfactory(this,"FLOAT_TYPE",new TCreator(FLOAT_TYPE_factory)); - new Tfactory(this,"LEFT_SHIFT",new TCreator(LEFT_SHIFT_factory)); - new Tfactory(this,"TILDE",new TCreator(TILDE_factory)); - new Tfactory(this,"OBJECT_REZ_EVENT",new TCreator(OBJECT_REZ_EVENT_factory)); - new Tfactory(this,"COMMA",new TCreator(COMMA_factory)); - new Tfactory(this,"FOR",new TCreator(FOR_factory)); - new Tfactory(this,"SENSOR_EVENT",new TCreator(SENSOR_EVENT_factory)); - new Tfactory(this,"IDENT",new TCreator(IDENT_factory)); - new Tfactory(this,"ELSE",new TCreator(ELSE_factory)); - new Tfactory(this,"VECTOR_TYPE",new TCreator(VECTOR_TYPE_factory)); - new Tfactory(this,"STROKE_STROKE",new TCreator(STROKE_STROKE_factory)); - new Tfactory(this,"PLUS",new TCreator(PLUS_factory)); - new Tfactory(this,"ATTACH_EVENT",new TCreator(ATTACH_EVENT_factory)); - new Tfactory(this,"COLLISION_END_EVENT",new TCreator(COLLISION_END_EVENT_factory)); - new Tfactory(this,"RIGHT_ANGLE",new TCreator(RIGHT_ANGLE_factory)); - new Tfactory(this,"MINUS",new TCreator(MINUS_factory)); - new Tfactory(this,"DO",new TCreator(DO_factory)); - new Tfactory(this,"LISTEN_EVENT",new TCreator(LISTEN_EVENT_factory)); -} -public static object MOVING_START_EVENT_factory(Lexer yyl) { return new MOVING_START_EVENT(yyl);} -public static object LEFT_BRACE_factory(Lexer yyl) { return new LEFT_BRACE(yyl);} -public static object MINUS_EQUALS_factory(Lexer yyl) { return new MINUS_EQUALS(yyl);} -public static object RIGHT_BRACKET_factory(Lexer yyl) { return new RIGHT_BRACKET(yyl);} -public static object EMAIL_EVENT_factory(Lexer yyl) { return new EMAIL_EVENT(yyl);} -public static object HTTP_RESPONSE_EVENT_factory(Lexer yyl) { return new HTTP_RESPONSE_EVENT(yyl);} -public static object STRING_CONSTANT_factory(Lexer yyl) { return new STRING_CONSTANT(yyl);} -public static object PERIOD_factory(Lexer yyl) { return new PERIOD(yyl);} -public static object MOVING_END_EVENT_factory(Lexer yyl) { return new MOVING_END_EVENT(yyl);} -public static object PERCENT_factory(Lexer yyl) { return new PERCENT(yyl);} -public static object LEFT_ANGLE_factory(Lexer yyl) { return new LEFT_ANGLE(yyl);} -public static object RIGHT_PAREN_factory(Lexer yyl) { return new RIGHT_PAREN(yyl);} -public static object AT_ROT_TARGET_EVENT_factory(Lexer yyl) { return new AT_ROT_TARGET_EVENT(yyl);} -public static object LEFT_PAREN_factory(Lexer yyl) { return new LEFT_PAREN(yyl);} -public static object RETURN_factory(Lexer yyl) { return new RETURN(yyl);} -public static object CONTROL_EVENT_factory(Lexer yyl) { return new CONTROL_EVENT(yyl);} -public static object NOT_AT_TARGET_EVENT_factory(Lexer yyl) { return new NOT_AT_TARGET_EVENT(yyl);} -public static object AMP_AMP_factory(Lexer yyl) { return new AMP_AMP(yyl);} -public static object NO_SENSOR_EVENT_factory(Lexer yyl) { return new NO_SENSOR_EVENT(yyl);} -public static object COLLISION_START_EVENT_factory(Lexer yyl) { return new COLLISION_START_EVENT(yyl);} -public static object MONEY_EVENT_factory(Lexer yyl) { return new MONEY_EVENT(yyl);} -public static object LESS_EQUALS_factory(Lexer yyl) { return new LESS_EQUALS(yyl);} -public static object INTEGER_TYPE_factory(Lexer yyl) { return new INTEGER_TYPE(yyl);} -public static object TOUCH_EVENT_factory(Lexer yyl) { return new TOUCH_EVENT(yyl);} -public static object HTTP_REQUEST_EVENT_factory(Lexer yyl) { return new HTTP_REQUEST_EVENT(yyl);} -public static object STAR_factory(Lexer yyl) { return new STAR(yyl);} -public static object RIGHT_BRACE_factory(Lexer yyl) { return new RIGHT_BRACE(yyl);} -public static object PLUS_EQUALS_factory(Lexer yyl) { return new PLUS_EQUALS(yyl);} -public static object STAR_EQUALS_factory(Lexer yyl) { return new STAR_EQUALS(yyl);} -public static object LINK_MESSAGE_EVENT_factory(Lexer yyl) { return new LINK_MESSAGE_EVENT(yyl);} -public static object IF_factory(Lexer yyl) { return new IF(yyl);} -public static object CARET_factory(Lexer yyl) { return new CARET(yyl);} -public static object STATE_ENTRY_EVENT_factory(Lexer yyl) { return new STATE_ENTRY_EVENT(yyl);} -public static object STATE_EXIT_EVENT_factory(Lexer yyl) { return new STATE_EXIT_EVENT(yyl);} -public static object STATE_factory(Lexer yyl) { return new STATE(yyl);} -public static object AT_factory(Lexer yyl) { return new AT(yyl);} -public static object NOT_AT_ROT_TARGET_EVENT_factory(Lexer yyl) { return new NOT_AT_ROT_TARGET_EVENT(yyl);} -public static object RIGHT_SHIFT_factory(Lexer yyl) { return new RIGHT_SHIFT(yyl);} -public static object STROKE_factory(Lexer yyl) { return new STROKE(yyl);} -public static object INTEGER_CONSTANT_factory(Lexer yyl) { return new INTEGER_CONSTANT(yyl);} -public static object INCREMENT_factory(Lexer yyl) { return new INCREMENT(yyl);} -public static object TOUCH_END_EVENT_factory(Lexer yyl) { return new TOUCH_END_EVENT(yyl);} -public static object SEMICOLON_factory(Lexer yyl) { return new SEMICOLON(yyl);} -public static object CHANGED_EVENT_factory(Lexer yyl) { return new CHANGED_EVENT(yyl);} -public static object DEFAULT_STATE_factory(Lexer yyl) { return new DEFAULT_STATE(yyl);} -public static object TIMER_EVENT_factory(Lexer yyl) { return new TIMER_EVENT(yyl);} -public static object PERCENT_EQUALS_factory(Lexer yyl) { return new PERCENT_EQUALS(yyl);} -public static object TRANSACTION_RESULT_EVENT_factory(Lexer yyl) { return new TRANSACTION_RESULT_EVENT(yyl);} -public static object EQUALS_EQUALS_factory(Lexer yyl) { return new EQUALS_EQUALS(yyl);} -public static object AMP_factory(Lexer yyl) { return new AMP(yyl);} -public static object REMOTE_DATA_EVENT_factory(Lexer yyl) { return new REMOTE_DATA_EVENT(yyl);} -public static object LIST_TYPE_factory(Lexer yyl) { return new LIST_TYPE(yyl);} -public static object STRING_TYPE_factory(Lexer yyl) { return new STRING_TYPE(yyl);} -public static object HEX_INTEGER_CONSTANT_factory(Lexer yyl) { return new HEX_INTEGER_CONSTANT(yyl);} -public static object KEY_TYPE_factory(Lexer yyl) { return new KEY_TYPE(yyl);} -public static object AT_TARGET_EVENT_factory(Lexer yyl) { return new AT_TARGET_EVENT(yyl);} -public static object EXCLAMATION_EQUALS_factory(Lexer yyl) { return new EXCLAMATION_EQUALS(yyl);} -public static object LEFT_BRACKET_factory(Lexer yyl) { return new LEFT_BRACKET(yyl);} -public static object EQUALS_factory(Lexer yyl) { return new EQUALS(yyl);} -public static object TOUCH_START_EVENT_factory(Lexer yyl) { return new TOUCH_START_EVENT(yyl);} -public static object JUMP_factory(Lexer yyl) { return new JUMP(yyl);} -public static object RUN_TIME_PERMISSIONS_EVENT_factory(Lexer yyl) { return new RUN_TIME_PERMISSIONS_EVENT(yyl);} -public static object LAND_COLLISION_START_EVENT_factory(Lexer yyl) { return new LAND_COLLISION_START_EVENT(yyl);} -public static object DATASERVER_EVENT_factory(Lexer yyl) { return new DATASERVER_EVENT(yyl);} -public static object DECREMENT_factory(Lexer yyl) { return new DECREMENT(yyl);} -public static object EXCLAMATION_factory(Lexer yyl) { return new EXCLAMATION(yyl);} -public static object ON_REZ_EVENT_factory(Lexer yyl) { return new ON_REZ_EVENT(yyl);} -public static object GREATER_EQUALS_factory(Lexer yyl) { return new GREATER_EQUALS(yyl);} -public static object FLOAT_CONSTANT_factory(Lexer yyl) { return new FLOAT_CONSTANT(yyl);} -public static object LAND_COLLISION_END_EVENT_factory(Lexer yyl) { return new LAND_COLLISION_END_EVENT(yyl);} -public static object SLASH_factory(Lexer yyl) { return new SLASH(yyl);} -public static object LAND_COLLISION_EVENT_factory(Lexer yyl) { return new LAND_COLLISION_EVENT(yyl);} -public static object WHILE_factory(Lexer yyl) { return new WHILE(yyl);} -public static object ROTATION_TYPE_factory(Lexer yyl) { return new ROTATION_TYPE(yyl);} -public static object COLLISION_EVENT_factory(Lexer yyl) { return new COLLISION_EVENT(yyl);} -public static object SLASH_EQUALS_factory(Lexer yyl) { return new SLASH_EQUALS(yyl);} -public static object FLOAT_TYPE_factory(Lexer yyl) { return new FLOAT_TYPE(yyl);} -public static object LEFT_SHIFT_factory(Lexer yyl) { return new LEFT_SHIFT(yyl);} -public static object TILDE_factory(Lexer yyl) { return new TILDE(yyl);} -public static object OBJECT_REZ_EVENT_factory(Lexer yyl) { return new OBJECT_REZ_EVENT(yyl);} -public static object COMMA_factory(Lexer yyl) { return new COMMA(yyl);} -public static object FOR_factory(Lexer yyl) { return new FOR(yyl);} -public static object SENSOR_EVENT_factory(Lexer yyl) { return new SENSOR_EVENT(yyl);} -public static object IDENT_factory(Lexer yyl) { return new IDENT(yyl);} -public static object ELSE_factory(Lexer yyl) { return new ELSE(yyl);} -public static object VECTOR_TYPE_factory(Lexer yyl) { return new VECTOR_TYPE(yyl);} -public static object STROKE_STROKE_factory(Lexer yyl) { return new STROKE_STROKE(yyl);} -public static object PLUS_factory(Lexer yyl) { return new PLUS(yyl);} -public static object ATTACH_EVENT_factory(Lexer yyl) { return new ATTACH_EVENT(yyl);} -public static object COLLISION_END_EVENT_factory(Lexer yyl) { return new COLLISION_END_EVENT(yyl);} -public static object RIGHT_ANGLE_factory(Lexer yyl) { return new RIGHT_ANGLE(yyl);} -public static object MINUS_factory(Lexer yyl) { return new MINUS(yyl);} -public static object DO_factory(Lexer yyl) { return new DO(yyl);} -public static object LISTEN_EVENT_factory(Lexer yyl) { return new LISTEN_EVENT(yyl);} -public override TOKEN OldAction(Lexer yym,ref string yytext,int action, ref bool reject) { - switch(action) { - case -1: break; - case 1076: ; - break; - case 974: { ((LSLTokens)yym).str += "\\n"; } - break; - case 1003: { ((LSLTokens)yym).str += "\\\""; } - break; - case 968: { ((LSLTokens)yym).str += yytext; } - break; - case 991: { ((LSLTokens)yym).str += " "; } - break; - case 1072: ; - break; - case 979: { ((LSLTokens)yym).str += "\\n"; } - break; - case 1063: ; - break; - case 963: { yym.yy_begin("STRING"); ((LSLTokens)yym).str = "";} - break; - case 1049: { yym.yy_begin("YYINITIAL"); } - break; - case 1067: ; - break; - case 1032: { yym.yy_begin("YYINITIAL"); ((LSLTokens)yym).yytext = ((LSLTokens)yym).str; ((LSLTokens)yym).str = String.Empty; return new STRING_CONSTANT(yym); } - // break; - case 1027: { ((LSLTokens)yym).str += '\\'; } - break; - case 1015: { ((LSLTokens)yym).str += "\\\\"; } - break; - case 1037: { yym.yy_begin("COMMENT"); } - break; - } - return null; -}} -public class LSLTokens:Lexer { -public LSLTokens():base(new yyLSLTokens(new ErrorHandler(false))) {} -public LSLTokens(ErrorHandler eh):base(new yyLSLTokens(eh)) {} -public LSLTokens(YyLexer tks):base(tks){} - - public string str; - - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs deleted file mode 100644 index 439d0068073..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs +++ /dev/null @@ -1,13521 +0,0 @@ -using System;using Tools; -namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { -//%+LSLProgramRoot+97 -public class LSLProgramRoot : SYMBOL{ - public LSLProgramRoot (Parser yyp, States s ):base(((LSLSyntax -)yyp)){ while (0< s . kids . Count ) kids . Add ( s . kids . Pop ()); -} - public LSLProgramRoot (Parser yyp, GlobalDefinitions gd , States s ):base(((LSLSyntax -)yyp)){ while (0< gd . kids . Count ) kids . Add ( gd . kids . Pop ()); - while (0< s . kids . Count ) kids . Add ( s . kids . Pop ()); -} - -public override string yyname { get { return "LSLProgramRoot"; }} -public override int yynum { get { return 97; }} -public LSLProgramRoot(Parser yyp):base(yyp){}} -//%+GlobalDefinitions+98 -public class GlobalDefinitions : SYMBOL{ - public GlobalDefinitions (Parser yyp, GlobalVariableDeclaration gvd ):base(((LSLSyntax -)yyp)){ kids . Add ( gvd ); -} - public GlobalDefinitions (Parser yyp, GlobalDefinitions gd , GlobalVariableDeclaration gvd ):base(((LSLSyntax -)yyp)){ while (0< gd . kids . Count ) kids . Add ( gd . kids . Pop ()); - kids . Add ( gvd ); -} - public GlobalDefinitions (Parser yyp, GlobalFunctionDefinition gfd ):base(((LSLSyntax -)yyp)){ kids . Add ( gfd ); -} - public GlobalDefinitions (Parser yyp, GlobalDefinitions gd , GlobalFunctionDefinition gfd ):base(((LSLSyntax -)yyp)){ while (0< gd . kids . Count ) kids . Add ( gd . kids . Pop ()); - kids . Add ( gfd ); -} - -public override string yyname { get { return "GlobalDefinitions"; }} -public override int yynum { get { return 98; }} -public GlobalDefinitions(Parser yyp):base(yyp){}} -//%+GlobalVariableDeclaration+99 -public class GlobalVariableDeclaration : SYMBOL{ - public GlobalVariableDeclaration (Parser yyp, Declaration d ):base(((LSLSyntax -)yyp)){ kids . Add ( d ); -} - public GlobalVariableDeclaration (Parser yyp, Assignment a ):base(((LSLSyntax -)yyp)){ kids . Add ( a ); -} - -public override string yyname { get { return "GlobalVariableDeclaration"; }} -public override int yynum { get { return 99; }} -public GlobalVariableDeclaration(Parser yyp):base(yyp){}} -//%+GlobalFunctionDefinition+100 -public class GlobalFunctionDefinition : SYMBOL{ - private string m_returnType ; - private string m_name ; - public GlobalFunctionDefinition (Parser yyp, string returnType , string name , ArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp)){ m_returnType = returnType ; - m_name = name ; - kids . Add ( adl ); - kids . Add ( cs ); -} - public string ReturnType { get { return m_returnType ; -} - set { m_returnType = value ; -} -} - public string Name { get { return m_name ; -} -} - -public override string yyname { get { return "GlobalFunctionDefinition"; }} -public override int yynum { get { return 100; }} -public GlobalFunctionDefinition(Parser yyp):base(yyp){}} -//%+States+101 -public class States : SYMBOL{ - public States (Parser yyp, State ds ):base(((LSLSyntax -)yyp)){ kids . Add ( ds ); -} - public States (Parser yyp, States s , State us ):base(((LSLSyntax -)yyp)){ while (0< s . kids . Count ) kids . Add ( s . kids . Pop ()); - kids . Add ( us ); -} - -public override string yyname { get { return "States"; }} -public override int yynum { get { return 101; }} -public States(Parser yyp):base(yyp){}} -//%+State+102 -public class State : SYMBOL{ - private string m_name ; - public State (Parser yyp, string name , StateBody sb ):base(((LSLSyntax -)yyp)){ m_name = name ; - while (0< sb . kids . Count ) kids . Add ( sb . kids . Pop ()); -} - public override string ToString (){ return "STATE<"+ m_name +">"; -} - public string Name { get { return m_name ; -} -} - -public override string yyname { get { return "State"; }} -public override int yynum { get { return 102; }} -public State(Parser yyp):base(yyp){}} -//%+StateBody+103 -public class StateBody : SYMBOL{ - public StateBody (Parser yyp, StateBody sb , StateEvent se ):base(((LSLSyntax -)yyp)){ while (0< sb . kids . Count ) kids . Add ( sb . kids . Pop ()); - kids . Add ( se ); -} - public StateBody (Parser yyp, StateEvent se ):base(((LSLSyntax -)yyp)){ kids . Add ( se ); -} - -public override string yyname { get { return "StateBody"; }} -public override int yynum { get { return 103; }} -public StateBody(Parser yyp):base(yyp){}} -//%+StateEvent+104 -public class StateEvent : SYMBOL{ - private string m_name ; - public StateEvent (Parser yyp, string name , CompoundStatement cs ):base(((LSLSyntax -)yyp)){ m_name = name ; - kids . Add ( cs ); -} - public StateEvent (Parser yyp, string name , ArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp)){ m_name = name ; - if (0< adl . kids . Count ) kids . Add ( adl ); - kids . Add ( cs ); -} - public override string ToString (){ return "EVENT<"+ m_name +">"; -} - public string Name { get { return m_name ; -} -} - -public override string yyname { get { return "StateEvent"; }} -public override int yynum { get { return 104; }} -public StateEvent(Parser yyp):base(yyp){}} -//%+VoidArgStateEvent+105 -public class VoidArgStateEvent : StateEvent{ - public VoidArgStateEvent (Parser yyp, string name , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , cs ){} - -public override string yyname { get { return "VoidArgStateEvent"; }} -public override int yynum { get { return 105; }} -public VoidArgStateEvent(Parser yyp):base(yyp){}} -//%+KeyArgStateEvent+106 -public class KeyArgStateEvent : StateEvent{ - public KeyArgStateEvent (Parser yyp, string name , KeyArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "KeyArgStateEvent"; }} -public override int yynum { get { return 106; }} -public KeyArgStateEvent(Parser yyp):base(yyp){}} -//%+IntArgStateEvent+107 -public class IntArgStateEvent : StateEvent{ - public IntArgStateEvent (Parser yyp, string name , IntArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "IntArgStateEvent"; }} -public override int yynum { get { return 107; }} -public IntArgStateEvent(Parser yyp):base(yyp){}} -//%+VectorArgStateEvent+108 -public class VectorArgStateEvent : StateEvent{ - public VectorArgStateEvent (Parser yyp, string name , VectorArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "VectorArgStateEvent"; }} -public override int yynum { get { return 108; }} -public VectorArgStateEvent(Parser yyp):base(yyp){}} -//%+IntRotRotArgStateEvent+109 -public class IntRotRotArgStateEvent : StateEvent{ - public IntRotRotArgStateEvent (Parser yyp, string name , IntRotRotArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "IntRotRotArgStateEvent"; }} -public override int yynum { get { return 109; }} -public IntRotRotArgStateEvent(Parser yyp):base(yyp){}} -//%+IntVecVecArgStateEvent+110 -public class IntVecVecArgStateEvent : StateEvent{ - public IntVecVecArgStateEvent (Parser yyp, string name , IntVecVecArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "IntVecVecArgStateEvent"; }} -public override int yynum { get { return 110; }} -public IntVecVecArgStateEvent(Parser yyp):base(yyp){}} -//%+KeyIntIntArgStateEvent+111 -public class KeyIntIntArgStateEvent : StateEvent{ - public KeyIntIntArgStateEvent (Parser yyp, string name , KeyIntIntArgumentDeclarationList adl , CompoundStatement cs ):base(((LSLSyntax -)yyp), name , adl , cs ){} - -public override string yyname { get { return "KeyIntIntArgStateEvent"; }} -public override int yynum { get { return 111; }} -public KeyIntIntArgStateEvent(Parser yyp):base(yyp){}} -//%+ArgumentDeclarationList+112 -public class ArgumentDeclarationList : SYMBOL{ - public ArgumentDeclarationList (Parser yyp, Declaration d ):base(((LSLSyntax -)yyp)){ kids . Add ( d ); -} - public ArgumentDeclarationList (Parser yyp, Declaration d , Declaration d2 ):base(((LSLSyntax -)yyp)){ kids . Add ( d ); - kids . Add ( d2 ); -} - public ArgumentDeclarationList (Parser yyp, Declaration d , Declaration d2 , Declaration d3 ):base(((LSLSyntax -)yyp)){ kids . Add ( d ); - kids . Add ( d2 ); - kids . Add ( d3 ); -} - public ArgumentDeclarationList (Parser yyp, ArgumentDeclarationList adl , Declaration d ):base(((LSLSyntax -)yyp)){ while (0< adl . kids . Count ) kids . Add ( adl . kids . Pop ()); - kids . Add ( d ); -} - -public override string yyname { get { return "ArgumentDeclarationList"; }} -public override int yynum { get { return 112; }} -public ArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+KeyArgumentDeclarationList+113 -public class KeyArgumentDeclarationList : ArgumentDeclarationList{ - public KeyArgumentDeclarationList (Parser yyp, KeyDeclaration d ):base(((LSLSyntax -)yyp), d ){} - -public override string yyname { get { return "KeyArgumentDeclarationList"; }} -public override int yynum { get { return 113; }} -public KeyArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+IntArgumentDeclarationList+114 -public class IntArgumentDeclarationList : ArgumentDeclarationList{ - public IntArgumentDeclarationList (Parser yyp, IntDeclaration d ):base(((LSLSyntax -)yyp), d ){} - -public override string yyname { get { return "IntArgumentDeclarationList"; }} -public override int yynum { get { return 114; }} -public IntArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+VectorArgumentDeclarationList+115 -public class VectorArgumentDeclarationList : ArgumentDeclarationList{ - public VectorArgumentDeclarationList (Parser yyp, VecDeclaration d ):base(((LSLSyntax -)yyp), d ){} - -public override string yyname { get { return "VectorArgumentDeclarationList"; }} -public override int yynum { get { return 115; }} -public VectorArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+IntRotRotArgumentDeclarationList+116 -public class IntRotRotArgumentDeclarationList : ArgumentDeclarationList{ - public IntRotRotArgumentDeclarationList (Parser yyp, Declaration d1 , Declaration d2 , Declaration d3 ):base(((LSLSyntax -)yyp), d1 , d2 , d3 ){} - -public override string yyname { get { return "IntRotRotArgumentDeclarationList"; }} -public override int yynum { get { return 116; }} -public IntRotRotArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+IntVecVecArgumentDeclarationList+117 -public class IntVecVecArgumentDeclarationList : ArgumentDeclarationList{ - public IntVecVecArgumentDeclarationList (Parser yyp, Declaration d1 , Declaration d2 , Declaration d3 ):base(((LSLSyntax -)yyp), d1 , d2 , d3 ){} - -public override string yyname { get { return "IntVecVecArgumentDeclarationList"; }} -public override int yynum { get { return 117; }} -public IntVecVecArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+KeyIntIntArgumentDeclarationList+118 -public class KeyIntIntArgumentDeclarationList : ArgumentDeclarationList{ - public KeyIntIntArgumentDeclarationList (Parser yyp, Declaration d1 , Declaration d2 , Declaration d3 ):base(((LSLSyntax -)yyp), d1 , d2 , d3 ){} - -public override string yyname { get { return "KeyIntIntArgumentDeclarationList"; }} -public override int yynum { get { return 118; }} -public KeyIntIntArgumentDeclarationList(Parser yyp):base(yyp){}} -//%+Declaration+119 -public class Declaration : SYMBOL{ - private string m_datatype ; - private string m_id ; - public Declaration (Parser yyp, string type , string id ):base(((LSLSyntax -)yyp)){ m_datatype = type ; - m_id = id ; -} - public override string ToString (){ return "Declaration<"+ m_datatype +":"+ m_id +">"; -} - public string Datatype { get { return m_datatype ; -} - set { m_datatype = value ; -} -} - public string Id { get { return m_id ; -} -} - -public override string yyname { get { return "Declaration"; }} -public override int yynum { get { return 119; }} -public Declaration(Parser yyp):base(yyp){}} -//%+KeyDeclaration+120 -public class KeyDeclaration : Declaration{ - public KeyDeclaration (Parser yyp, string type , string id ):base(((LSLSyntax -)yyp), type , id ){} - -public override string yyname { get { return "KeyDeclaration"; }} -public override int yynum { get { return 120; }} -public KeyDeclaration(Parser yyp):base(yyp){}} -//%+IntDeclaration+121 -public class IntDeclaration : Declaration{ - public IntDeclaration (Parser yyp, string type , string id ):base(((LSLSyntax -)yyp), type , id ){} - -public override string yyname { get { return "IntDeclaration"; }} -public override int yynum { get { return 121; }} -public IntDeclaration(Parser yyp):base(yyp){}} -//%+VecDeclaration+122 -public class VecDeclaration : Declaration{ - public VecDeclaration (Parser yyp, string type , string id ):base(((LSLSyntax -)yyp), type , id ){} - -public override string yyname { get { return "VecDeclaration"; }} -public override int yynum { get { return 122; }} -public VecDeclaration(Parser yyp):base(yyp){}} -//%+RotDeclaration+123 -public class RotDeclaration : Declaration{ - public RotDeclaration (Parser yyp, string type , string id ):base(((LSLSyntax -)yyp), type , id ){} - -public override string yyname { get { return "RotDeclaration"; }} -public override int yynum { get { return 123; }} -public RotDeclaration(Parser yyp):base(yyp){}} -//%+Typename+124 -public class Typename : SYMBOL{ - public string yytext ; - public Typename (Parser yyp, string text ):base(((LSLSyntax -)yyp)){ yytext = text ; -} - -public override string yyname { get { return "Typename"; }} -public override int yynum { get { return 124; }} -public Typename(Parser yyp):base(yyp){}} -//%+Event+125 -public class Event : SYMBOL{ - public string yytext ; - public Event (Parser yyp, string text ):base(((LSLSyntax -)yyp)){ yytext = text ; -} - -public override string yyname { get { return "Event"; }} -public override int yynum { get { return 125; }} -public Event(Parser yyp):base(yyp){}} -//%+VoidArgEvent+126 -public class VoidArgEvent : Event{ - public VoidArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "VoidArgEvent"; }} -public override int yynum { get { return 126; }} -public VoidArgEvent(Parser yyp):base(yyp){}} -//%+KeyArgEvent+127 -public class KeyArgEvent : Event{ - public KeyArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "KeyArgEvent"; }} -public override int yynum { get { return 127; }} -public KeyArgEvent(Parser yyp):base(yyp){}} -//%+IntArgEvent+128 -public class IntArgEvent : Event{ - public IntArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "IntArgEvent"; }} -public override int yynum { get { return 128; }} -public IntArgEvent(Parser yyp):base(yyp){}} -//%+VectorArgEvent+129 -public class VectorArgEvent : Event{ - public VectorArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "VectorArgEvent"; }} -public override int yynum { get { return 129; }} -public VectorArgEvent(Parser yyp):base(yyp){}} -//%+IntRotRotArgEvent+130 -public class IntRotRotArgEvent : Event{ - public IntRotRotArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "IntRotRotArgEvent"; }} -public override int yynum { get { return 130; }} -public IntRotRotArgEvent(Parser yyp):base(yyp){}} -//%+IntVecVecArgEvent+131 -public class IntVecVecArgEvent : Event{ - public IntVecVecArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "IntVecVecArgEvent"; }} -public override int yynum { get { return 131; }} -public IntVecVecArgEvent(Parser yyp):base(yyp){}} -//%+KeyIntIntArgEvent+132 -public class KeyIntIntArgEvent : Event{ - public KeyIntIntArgEvent (Parser yyp, string text ):base(((LSLSyntax -)yyp), text ){} - -public override string yyname { get { return "KeyIntIntArgEvent"; }} -public override int yynum { get { return 132; }} -public KeyIntIntArgEvent(Parser yyp):base(yyp){}} -//%+CompoundStatement+133 -public class CompoundStatement : SYMBOL{ - public CompoundStatement (Parser yyp):base(((LSLSyntax -)yyp)){} - public CompoundStatement (Parser yyp, StatementList sl ):base(((LSLSyntax -)yyp)){ while (0< sl . kids . Count ) kids . Add ( sl . kids . Pop ()); -} - -public override string yyname { get { return "CompoundStatement"; }} -public override int yynum { get { return 133; }} -} -//%+StatementList+134 -public class StatementList : SYMBOL{ - private void AddStatement ( Statement s ){ if ( s . kids . Top is IfStatement || s . kids . Top is WhileStatement || s . kids . Top is DoWhileStatement || s . kids . Top is ForLoop ) kids . Add ( s . kids . Pop ()); - else kids . Add ( s ); -} - public StatementList (Parser yyp, Statement s ):base(((LSLSyntax -)yyp)){ AddStatement ( s ); -} - public StatementList (Parser yyp, StatementList sl , Statement s ):base(((LSLSyntax -)yyp)){ while (0< sl . kids . Count ) kids . Add ( sl . kids . Pop ()); - AddStatement ( s ); -} - -public override string yyname { get { return "StatementList"; }} -public override int yynum { get { return 134; }} -public StatementList(Parser yyp):base(yyp){}} -//%+Statement+135 -public class Statement : SYMBOL{ - public Statement (Parser yyp, Declaration d ):base(((LSLSyntax -)yyp)){ kids . Add ( d ); -} - public Statement (Parser yyp, CompoundStatement cs ):base(((LSLSyntax -)yyp)){ kids . Add ( cs ); -} - public Statement (Parser yyp, FunctionCall fc ):base(((LSLSyntax -)yyp)){ kids . Add ( fc ); -} - public Statement (Parser yyp, Assignment a ):base(((LSLSyntax -)yyp)){ kids . Add ( a ); -} - public Statement (Parser yyp, Expression e ):base(((LSLSyntax -)yyp)){ kids . Add ( e ); -} - public Statement (Parser yyp, ReturnStatement rs ):base(((LSLSyntax -)yyp)){ kids . Add ( rs ); -} - public Statement (Parser yyp, StateChange sc ):base(((LSLSyntax -)yyp)){ kids . Add ( sc ); -} - public Statement (Parser yyp, IfStatement ifs ):base(((LSLSyntax -)yyp)){ kids . Add ( ifs ); -} - public Statement (Parser yyp, WhileStatement ifs ):base(((LSLSyntax -)yyp)){ kids . Add ( ifs ); -} - public Statement (Parser yyp, DoWhileStatement ifs ):base(((LSLSyntax -)yyp)){ kids . Add ( ifs ); -} - public Statement (Parser yyp, ForLoop fl ):base(((LSLSyntax -)yyp)){ kids . Add ( fl ); -} - public Statement (Parser yyp, JumpLabel jl ):base(((LSLSyntax -)yyp)){ kids . Add ( jl ); -} - public Statement (Parser yyp, JumpStatement js ):base(((LSLSyntax -)yyp)){ kids . Add ( js ); -} - public Statement (Parser yyp, EmptyStatement es ):base(((LSLSyntax -)yyp)){ kids . Add ( es ); -} - -public override string yyname { get { return "Statement"; }} -public override int yynum { get { return 135; }} -public Statement(Parser yyp):base(yyp){}} -//%+EmptyStatement+136 -public class EmptyStatement : SYMBOL{ - public EmptyStatement (Parser yyp):base(((LSLSyntax -)yyp)){} - public override string ToString (){ return base . ToString (); -} - -public override string yyname { get { return "EmptyStatement"; }} -public override int yynum { get { return 136; }} -} -//%+Assignment+137 -public class Assignment : SYMBOL{ - protected string m_assignmentType ; - public Assignment (Parser yyp, SYMBOL lhs , SYMBOL rhs , string assignmentType ):base(((LSLSyntax -)yyp)){ m_assignmentType = assignmentType ; - kids . Add ( lhs ); - if ( rhs is ConstantExpression ) while (0< rhs . kids . Count ) kids . Add ( rhs . kids . Pop ()); - else kids . Add ( rhs ); -} - public Assignment (Parser yyp, SimpleAssignment sa ):base(((LSLSyntax -)yyp)){ m_assignmentType = sa . AssignmentType ; - while (0< sa . kids . Count ) kids . Add ( sa . kids . Pop ()); -} - public string AssignmentType { get { return m_assignmentType ; -} -} - public override string ToString (){ return base . ToString ()+"<"+ m_assignmentType +">"; -} - -public override string yyname { get { return "Assignment"; }} -public override int yynum { get { return 137; }} -public Assignment(Parser yyp):base(yyp){}} -//%+SimpleAssignment+138 -public class SimpleAssignment : Assignment{ - public SimpleAssignment (Parser yyp, SYMBOL lhs , SYMBOL rhs , string assignmentType ):base(((LSLSyntax -)yyp)){ m_assignmentType = assignmentType ; - kids . Add ( lhs ); - if ( rhs is ConstantExpression ) while (0< rhs . kids . Count ) kids . Add ( rhs . kids . Pop ()); - else kids . Add ( rhs ); -} - -public override string yyname { get { return "SimpleAssignment"; }} -public override int yynum { get { return 138; }} -public SimpleAssignment(Parser yyp):base(yyp){}} -//%+ReturnStatement+139 -public class ReturnStatement : SYMBOL{ - public ReturnStatement (Parser yyp):base(((LSLSyntax -)yyp)){} - public ReturnStatement (Parser yyp, Expression e ):base(((LSLSyntax -)yyp)){ if ( e is ConstantExpression ) while (0< e . kids . Count ) kids . Add ( e . kids . Pop ()); - else kids . Add ( e ); -} - -public override string yyname { get { return "ReturnStatement"; }} -public override int yynum { get { return 139; }} -} -//%+JumpLabel+140 -public class JumpLabel : SYMBOL{ - private string m_labelName ; - public JumpLabel (Parser yyp, string labelName ):base(((LSLSyntax -)yyp)){ m_labelName = labelName ; -} - public string LabelName { get { return m_labelName ; -} -} - public override string ToString (){ return base . ToString ()+"<"+ m_labelName +">"; -} - -public override string yyname { get { return "JumpLabel"; }} -public override int yynum { get { return 140; }} -public JumpLabel(Parser yyp):base(yyp){}} -//%+JumpStatement+141 -public class JumpStatement : SYMBOL{ - private string m_targetName ; - public JumpStatement (Parser yyp, string targetName ):base(((LSLSyntax -)yyp)){ m_targetName = targetName ; -} - public string TargetName { get { return m_targetName ; -} -} - public override string ToString (){ return base . ToString ()+"<"+ m_targetName +">"; -} - -public override string yyname { get { return "JumpStatement"; }} -public override int yynum { get { return 141; }} -public JumpStatement(Parser yyp):base(yyp){}} -//%+StateChange+142 -public class StateChange : SYMBOL{ - private string m_newState ; - public StateChange (Parser yyp, string newState ):base(((LSLSyntax -)yyp)){ m_newState = newState ; -} - public string NewState { get { return m_newState ; -} -} - -public override string yyname { get { return "StateChange"; }} -public override int yynum { get { return 142; }} -public StateChange(Parser yyp):base(yyp){}} -//%+IfStatement+143 -public class IfStatement : SYMBOL{ - private void AddStatement ( Statement s ){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); - else kids . Add ( s ); -} - public IfStatement (Parser yyp, SYMBOL s , Statement ifs ):base(((LSLSyntax -)yyp)){ kids . Add ( s ); - AddStatement ( ifs ); -} - public IfStatement (Parser yyp, SYMBOL s , Statement ifs , Statement es ):base(((LSLSyntax -)yyp)){ kids . Add ( s ); - AddStatement ( ifs ); - if (0< es . kids . Count && es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ()); - else AddStatement ( es ); -} - -public override string yyname { get { return "IfStatement"; }} -public override int yynum { get { return 143; }} -public IfStatement(Parser yyp):base(yyp){}} -//%+WhileStatement+144 -public class WhileStatement : SYMBOL{ - public WhileStatement (Parser yyp, SYMBOL s , Statement st ):base(((LSLSyntax -)yyp)){ kids . Add ( s ); - if (0< st . kids . Count && st . kids . Top is CompoundStatement ) kids . Add ( st . kids . Pop ()); - else kids . Add ( st ); -} - -public override string yyname { get { return "WhileStatement"; }} -public override int yynum { get { return 144; }} -public WhileStatement(Parser yyp):base(yyp){}} -//%+DoWhileStatement+145 -public class DoWhileStatement : SYMBOL{ - public DoWhileStatement (Parser yyp, SYMBOL s , Statement st ):base(((LSLSyntax -)yyp)){ if (0< st . kids . Count && st . kids . Top is CompoundStatement ) kids . Add ( st . kids . Pop ()); - else kids . Add ( st ); - kids . Add ( s ); -} - -public override string yyname { get { return "DoWhileStatement"; }} -public override int yynum { get { return 145; }} -public DoWhileStatement(Parser yyp):base(yyp){}} -//%+ForLoop+146 -public class ForLoop : SYMBOL{ - public ForLoop (Parser yyp, ForLoopStatement flsa , Expression e , ForLoopStatement flsb , Statement s ):base(((LSLSyntax -)yyp)){ kids . Add ( flsa ); - kids . Add ( e ); - kids . Add ( flsb ); - if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); - else kids . Add ( s ); -} - -public override string yyname { get { return "ForLoop"; }} -public override int yynum { get { return 146; }} -public ForLoop(Parser yyp):base(yyp){}} -//%+ForLoopStatement+147 -public class ForLoopStatement : SYMBOL{ - public ForLoopStatement (Parser yyp, Expression e ):base(((LSLSyntax -)yyp)){ kids . Add ( e ); -} - public ForLoopStatement (Parser yyp, SimpleAssignment sa ):base(((LSLSyntax -)yyp)){ kids . Add ( sa ); -} - public ForLoopStatement (Parser yyp, ForLoopStatement fls , Expression e ):base(((LSLSyntax -)yyp)){ while (0< fls . kids . Count ) kids . Add ( fls . kids . Pop ()); - kids . Add ( e ); -} - public ForLoopStatement (Parser yyp, ForLoopStatement fls , SimpleAssignment sa ):base(((LSLSyntax -)yyp)){ while (0< fls . kids . Count ) kids . Add ( fls . kids . Pop ()); - kids . Add ( sa ); -} - -public override string yyname { get { return "ForLoopStatement"; }} -public override int yynum { get { return 147; }} -public ForLoopStatement(Parser yyp):base(yyp){}} -//%+FunctionCall+148 -public class FunctionCall : SYMBOL{ - private string m_id ; - public FunctionCall (Parser yyp, string id , ArgumentList al ):base(((LSLSyntax -)yyp)){ m_id = id ; - kids . Add ( al ); -} - public override string ToString (){ return base . ToString ()+"<"+ m_id +">"; -} - public string Id { get { return m_id ; -} -} - -public override string yyname { get { return "FunctionCall"; }} -public override int yynum { get { return 148; }} -public FunctionCall(Parser yyp):base(yyp){}} -//%+ArgumentList+149 -public class ArgumentList : SYMBOL{ - public ArgumentList (Parser yyp, Argument a ):base(((LSLSyntax -)yyp)){ AddArgument ( a ); -} - public ArgumentList (Parser yyp, ArgumentList al , Argument a ):base(((LSLSyntax -)yyp)){ while (0< al . kids . Count ) kids . Add ( al . kids . Pop ()); - AddArgument ( a ); -} - private void AddArgument ( Argument a ){ if ( a is ExpressionArgument ) while (0< a . kids . Count ) kids . Add ( a . kids . Pop ()); - else kids . Add ( a ); -} - -public override string yyname { get { return "ArgumentList"; }} -public override int yynum { get { return 149; }} -public ArgumentList(Parser yyp):base(yyp){}} -//%+Argument+150 -public class Argument : SYMBOL{ -public override string yyname { get { return "Argument"; }} -public override int yynum { get { return 150; }} -public Argument(Parser yyp):base(yyp){}} -//%+ExpressionArgument+151 -public class ExpressionArgument : Argument{ - public ExpressionArgument (Parser yyp, Expression e ):base(((LSLSyntax -)yyp)){ if ( e is ConstantExpression ) while (0< e . kids . Count ) kids . Add ( e . kids . Pop ()); - else kids . Add ( e ); -} - -public override string yyname { get { return "ExpressionArgument"; }} -public override int yynum { get { return 151; }} -public ExpressionArgument(Parser yyp):base(yyp){}} -//%+Constant+152 -public class Constant : SYMBOL{ - private string m_type ; - private string m_val ; - public Constant (Parser yyp, string type , string val ):base(((LSLSyntax -)yyp)){ m_type = type ; - m_val = val ; -} - public override string ToString (){ return base . ToString ()+"<"+ m_type +":"+ m_val +">"; -} - public string Value { get { return m_val ; -} - set { m_val = value ; -} -} - public string Type { get { return m_type ; -} - set { m_type = value ; -} -} - -public override string yyname { get { return "Constant"; }} -public override int yynum { get { return 152; }} -public Constant(Parser yyp):base(yyp){}} -//%+VectorConstant+153 -public class VectorConstant : Constant{ - public VectorConstant (Parser yyp, Expression valX , Expression valY , Expression valZ ):base(((LSLSyntax -)yyp),"vector", null ){ kids . Add ( valX ); - kids . Add ( valY ); - kids . Add ( valZ ); -} - -public override string yyname { get { return "VectorConstant"; }} -public override int yynum { get { return 153; }} -public VectorConstant(Parser yyp):base(yyp){}} -//%+RotationConstant+154 -public class RotationConstant : Constant{ - public RotationConstant (Parser yyp, Expression valX , Expression valY , Expression valZ , Expression valS ):base(((LSLSyntax -)yyp),"rotation", null ){ kids . Add ( valX ); - kids . Add ( valY ); - kids . Add ( valZ ); - kids . Add ( valS ); -} - -public override string yyname { get { return "RotationConstant"; }} -public override int yynum { get { return 154; }} -public RotationConstant(Parser yyp):base(yyp){}} -//%+ListConstant+155 -public class ListConstant : Constant{ - public ListConstant (Parser yyp, ArgumentList al ):base(((LSLSyntax -)yyp),"list", null ){ kids . Add ( al ); -} - -public override string yyname { get { return "ListConstant"; }} -public override int yynum { get { return 155; }} -public ListConstant(Parser yyp):base(yyp){}} -//%+Expression+156 -public class Expression : SYMBOL{ - protected void AddExpression ( Expression e ){ if ( e is ConstantExpression ) while (0< e . kids . Count ) kids . Add ( e . kids . Pop ()); - else kids . Add ( e ); -} - -public override string yyname { get { return "Expression"; }} -public override int yynum { get { return 156; }} -public Expression(Parser yyp):base(yyp){}} -//%+ConstantExpression+157 -public class ConstantExpression : Expression{ - public ConstantExpression (Parser yyp, Constant c ):base(((LSLSyntax -)yyp)){ kids . Add ( c ); -} - -public override string yyname { get { return "ConstantExpression"; }} -public override int yynum { get { return 157; }} -public ConstantExpression(Parser yyp):base(yyp){}} -//%+IdentExpression+158 -public class IdentExpression : Expression{ - protected string m_name ; - public IdentExpression (Parser yyp, string name ):base(((LSLSyntax -)yyp)){ m_name = name ; -} - public override string ToString (){ return base . ToString ()+"<"+ m_name +">"; -} - public string Name { get { return m_name ; -} -} - -public override string yyname { get { return "IdentExpression"; }} -public override int yynum { get { return 158; }} -public IdentExpression(Parser yyp):base(yyp){}} -//%+IdentDotExpression+159 -public class IdentDotExpression : IdentExpression{ - private string m_member ; - public IdentDotExpression (Parser yyp, string name , string member ):base(((LSLSyntax -)yyp), name ){ m_member = member ; -} - public override string ToString (){ string baseToString = base . ToString (); - return baseToString . Substring (0, baseToString . Length -1)+"."+ m_member +">"; -} - public string Member { get { return m_member ; -} -} - -public override string yyname { get { return "IdentDotExpression"; }} -public override int yynum { get { return 159; }} -public IdentDotExpression(Parser yyp):base(yyp){}} -//%+FunctionCallExpression+160 -public class FunctionCallExpression : Expression{ - public FunctionCallExpression (Parser yyp, FunctionCall fc ):base(((LSLSyntax -)yyp)){ kids . Add ( fc ); -} - -public override string yyname { get { return "FunctionCallExpression"; }} -public override int yynum { get { return 160; }} -public FunctionCallExpression(Parser yyp):base(yyp){}} -//%+BinaryExpression+161 -public class BinaryExpression : Expression{ - private string m_expressionSymbol ; - public BinaryExpression (Parser yyp, Expression lhs , Expression rhs , string expressionSymbol ):base(((LSLSyntax -)yyp)){ m_expressionSymbol = expressionSymbol ; - AddExpression ( lhs ); - AddExpression ( rhs ); -} - public string ExpressionSymbol { get { return m_expressionSymbol ; -} -} - public override string ToString (){ return base . ToString ()+"<"+ m_expressionSymbol +">"; -} - -public override string yyname { get { return "BinaryExpression"; }} -public override int yynum { get { return 161; }} -public BinaryExpression(Parser yyp):base(yyp){}} -//%+UnaryExpression+162 -public class UnaryExpression : Expression{ - private string m_unarySymbol ; - public UnaryExpression (Parser yyp, string unarySymbol , Expression e ):base(((LSLSyntax -)yyp)){ m_unarySymbol = unarySymbol ; - AddExpression ( e ); -} - public string UnarySymbol { get { return m_unarySymbol ; -} -} - public override string ToString (){ return base . ToString ()+"<"+ m_unarySymbol +">"; -} - -public override string yyname { get { return "UnaryExpression"; }} -public override int yynum { get { return 162; }} -public UnaryExpression(Parser yyp):base(yyp){}} -//%+TypecastExpression+163 -public class TypecastExpression : Expression{ - private string m_typecastType ; - public TypecastExpression (Parser yyp, string typecastType , SYMBOL rhs ):base(((LSLSyntax -)yyp)){ m_typecastType = typecastType ; - kids . Add ( rhs ); -} - public string TypecastType { get { return m_typecastType ; -} - set { m_typecastType = value ; -} -} - -public override string yyname { get { return "TypecastExpression"; }} -public override int yynum { get { return 163; }} -public TypecastExpression(Parser yyp):base(yyp){}} -//%+ParenthesisExpression+164 -public class ParenthesisExpression : Expression{ - public ParenthesisExpression (Parser yyp, SYMBOL s ):base(((LSLSyntax -)yyp)){ kids . Add ( s ); -} - -public override string yyname { get { return "ParenthesisExpression"; }} -public override int yynum { get { return 164; }} -public ParenthesisExpression(Parser yyp):base(yyp){}} -//%+IncrementDecrementExpression+165 -public class IncrementDecrementExpression : Expression{ - private string m_name ; - private string m_operation ; - private bool m_postOperation ; - public IncrementDecrementExpression (Parser yyp, string name , string operation , bool postOperation ):base(((LSLSyntax -)yyp)){ m_name = name ; - m_operation = operation ; - m_postOperation = postOperation ; -} - public IncrementDecrementExpression (Parser yyp, IdentDotExpression ide , string operation , bool postOperation ):base(((LSLSyntax -)yyp)){ m_operation = operation ; - m_postOperation = postOperation ; - kids . Add ( ide ); -} - public override string ToString (){ return base . ToString ()+"<"+( m_postOperation ? m_name + m_operation : m_operation + m_name )+">"; -} - public string Name { get { return m_name ; -} -} - public string Operation { get { return m_operation ; -} -} - public bool PostOperation { get { return m_postOperation ; -} -} - -public override string yyname { get { return "IncrementDecrementExpression"; }} -public override int yynum { get { return 165; }} -public IncrementDecrementExpression(Parser yyp):base(yyp){}} - -public class LSLProgramRoot_1 : LSLProgramRoot { - public LSLProgramRoot_1(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((States)(yyq.StackAt(0).m_value)) - ){}} - -public class LSLProgramRoot_2 : LSLProgramRoot { - public LSLProgramRoot_2(Parser yyq):base(yyq, - ((States)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalDefinitions_1 : GlobalDefinitions { - public GlobalDefinitions_1(Parser yyq):base(yyq, - ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalDefinitions_2 : GlobalDefinitions { - public GlobalDefinitions_2(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((GlobalVariableDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalDefinitions_3 : GlobalDefinitions { - public GlobalDefinitions_3(Parser yyq):base(yyq, - ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalDefinitions_4 : GlobalDefinitions { - public GlobalDefinitions_4(Parser yyq):base(yyq, - ((GlobalDefinitions)(yyq.StackAt(1).m_value)) - , - ((GlobalFunctionDefinition)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalVariableDeclaration_1 : GlobalVariableDeclaration { - public GlobalVariableDeclaration_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(1).m_value)) - ){}} - -public class GlobalVariableDeclaration_2 : GlobalVariableDeclaration { - public GlobalVariableDeclaration_2(Parser yyq):base(yyq,new Assignment(((LSLSyntax -)yyq), - ((Declaration)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - , - ((EQUALS)(yyq.StackAt(2).m_value)) - .yytext)){}} - -public class GlobalFunctionDefinition_1 : GlobalFunctionDefinition { - public GlobalFunctionDefinition_1(Parser yyq):base(yyq,"void", - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class GlobalFunctionDefinition_2 : GlobalFunctionDefinition { - public GlobalFunctionDefinition_2(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class States_1 : States { - public States_1(Parser yyq):base(yyq, - ((State)(yyq.StackAt(0).m_value)) - ){}} - -public class States_2 : States { - public States_2(Parser yyq):base(yyq, - ((States)(yyq.StackAt(1).m_value)) - , - ((State)(yyq.StackAt(0).m_value)) - ){}} - -public class State_1 : State { - public State_1(Parser yyq):base(yyq, - ((DEFAULT_STATE)(yyq.StackAt(3).m_value)) - .yytext, - ((StateBody)(yyq.StackAt(1).m_value)) - ){}} - -public class State_2 : State { - public State_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((StateBody)(yyq.StackAt(1).m_value)) - ){}} - -public class StateBody_1 : StateBody { - public StateBody_1(Parser yyq):base(yyq, - ((StateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_2 : StateBody { - public StateBody_2(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((StateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_3 : StateBody { - public StateBody_3(Parser yyq):base(yyq, - ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_4 : StateBody { - public StateBody_4(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((VoidArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_5 : StateBody { - public StateBody_5(Parser yyq):base(yyq, - ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_6 : StateBody { - public StateBody_6(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((KeyArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_7 : StateBody { - public StateBody_7(Parser yyq):base(yyq, - ((IntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_8 : StateBody { - public StateBody_8(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_9 : StateBody { - public StateBody_9(Parser yyq):base(yyq, - ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_10 : StateBody { - public StateBody_10(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((VectorArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_11 : StateBody { - public StateBody_11(Parser yyq):base(yyq, - ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_12 : StateBody { - public StateBody_12(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntRotRotArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_13 : StateBody { - public StateBody_13(Parser yyq):base(yyq, - ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_14 : StateBody { - public StateBody_14(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((IntVecVecArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_15 : StateBody { - public StateBody_15(Parser yyq):base(yyq, - ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateBody_16 : StateBody { - public StateBody_16(Parser yyq):base(yyq, - ((StateBody)(yyq.StackAt(1).m_value)) - , - ((KeyIntIntArgStateEvent)(yyq.StackAt(0).m_value)) - ){}} - -public class StateEvent_1 : StateEvent { - public StateEvent_1(Parser yyq):base(yyq, - ((Event)(yyq.StackAt(4).m_value)) - .yytext, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class VoidArgStateEvent_1 : VoidArgStateEvent { - public VoidArgStateEvent_1(Parser yyq):base(yyq, - ((VoidArgEvent)(yyq.StackAt(3).m_value)) - .yytext, - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class KeyArgStateEvent_1 : KeyArgStateEvent { - public KeyArgStateEvent_1(Parser yyq):base(yyq, - ((KeyArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((KeyArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class IntArgStateEvent_1 : IntArgStateEvent { - public IntArgStateEvent_1(Parser yyq):base(yyq, - ((IntArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class VectorArgStateEvent_1 : VectorArgStateEvent { - public VectorArgStateEvent_1(Parser yyq):base(yyq, - ((VectorArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((VectorArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class IntRotRotArgStateEvent_1 : IntRotRotArgStateEvent { - public IntRotRotArgStateEvent_1(Parser yyq):base(yyq, - ((IntRotRotArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntRotRotArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class IntVecVecArgStateEvent_1 : IntVecVecArgStateEvent { - public IntVecVecArgStateEvent_1(Parser yyq):base(yyq, - ((IntVecVecArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((IntVecVecArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class KeyIntIntArgStateEvent_1 : KeyIntIntArgStateEvent { - public KeyIntIntArgStateEvent_1(Parser yyq):base(yyq, - ((KeyIntIntArgEvent)(yyq.StackAt(4).m_value)) - .yytext, - ((KeyIntIntArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class ArgumentDeclarationList_1 : ArgumentDeclarationList { - public ArgumentDeclarationList_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(0).m_value)) - ){}} - -public class ArgumentDeclarationList_2 : ArgumentDeclarationList { - public ArgumentDeclarationList_2(Parser yyq):base(yyq, - ((ArgumentDeclarationList)(yyq.StackAt(2).m_value)) - , - ((Declaration)(yyq.StackAt(0).m_value)) - ){}} - -public class KeyArgumentDeclarationList_1 : KeyArgumentDeclarationList { - public KeyArgumentDeclarationList_1(Parser yyq):base(yyq, - ((KeyDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class IntArgumentDeclarationList_1 : IntArgumentDeclarationList { - public IntArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class VectorArgumentDeclarationList_1 : VectorArgumentDeclarationList { - public VectorArgumentDeclarationList_1(Parser yyq):base(yyq, - ((VecDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class IntRotRotArgumentDeclarationList_1 : IntRotRotArgumentDeclarationList { - public IntRotRotArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(4).m_value)) - , - ((RotDeclaration)(yyq.StackAt(2).m_value)) - , - ((RotDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class IntVecVecArgumentDeclarationList_1 : IntVecVecArgumentDeclarationList { - public IntVecVecArgumentDeclarationList_1(Parser yyq):base(yyq, - ((IntDeclaration)(yyq.StackAt(4).m_value)) - , - ((VecDeclaration)(yyq.StackAt(2).m_value)) - , - ((VecDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class KeyIntIntArgumentDeclarationList_1 : KeyIntIntArgumentDeclarationList { - public KeyIntIntArgumentDeclarationList_1(Parser yyq):base(yyq, - ((KeyDeclaration)(yyq.StackAt(4).m_value)) - , - ((IntDeclaration)(yyq.StackAt(2).m_value)) - , - ((IntDeclaration)(yyq.StackAt(0).m_value)) - ){}} - -public class Declaration_1 : Declaration { - public Declaration_1(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class KeyDeclaration_1 : KeyDeclaration { - public KeyDeclaration_1(Parser yyq):base(yyq, - ((KEY_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntDeclaration_1 : IntDeclaration { - public IntDeclaration_1(Parser yyq):base(yyq, - ((INTEGER_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VecDeclaration_1 : VecDeclaration { - public VecDeclaration_1(Parser yyq):base(yyq, - ((VECTOR_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class RotDeclaration_1 : RotDeclaration { - public RotDeclaration_1(Parser yyq):base(yyq, - ((ROTATION_TYPE)(yyq.StackAt(1).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class CompoundStatement_1 : CompoundStatement { - public CompoundStatement_1(Parser yyq):base(yyq){}} - -public class CompoundStatement_2 : CompoundStatement { - public CompoundStatement_2(Parser yyq):base(yyq, - ((StatementList)(yyq.StackAt(1).m_value)) - ){}} - -public class StatementList_1 : StatementList { - public StatementList_1(Parser yyq):base(yyq, - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class StatementList_2 : StatementList { - public StatementList_2(Parser yyq):base(yyq, - ((StatementList)(yyq.StackAt(1).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class EmptyStatement_1 : EmptyStatement { - public EmptyStatement_1(Parser yyq):base(yyq){}} - -public class Statement_1 : Statement { - public Statement_1(Parser yyq):base(yyq, - ((EmptyStatement)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_2 : Statement { - public Statement_2(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_3 : Statement { - public Statement_3(Parser yyq):base(yyq, - ((Assignment)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_4 : Statement { - public Statement_4(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_5 : Statement { - public Statement_5(Parser yyq):base(yyq, - ((ReturnStatement)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_6 : Statement { - public Statement_6(Parser yyq):base(yyq, - ((JumpLabel)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_7 : Statement { - public Statement_7(Parser yyq):base(yyq, - ((JumpStatement)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_8 : Statement { - public Statement_8(Parser yyq):base(yyq, - ((StateChange)(yyq.StackAt(1).m_value)) - ){}} - -public class Statement_9 : Statement { - public Statement_9(Parser yyq):base(yyq, - ((IfStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class Statement_10 : Statement { - public Statement_10(Parser yyq):base(yyq, - ((WhileStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class Statement_11 : Statement { - public Statement_11(Parser yyq):base(yyq, - ((DoWhileStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class Statement_12 : Statement { - public Statement_12(Parser yyq):base(yyq, - ((ForLoop)(yyq.StackAt(0).m_value)) - ){}} - -public class Statement_13 : Statement { - public Statement_13(Parser yyq):base(yyq, - ((CompoundStatement)(yyq.StackAt(0).m_value)) - ){}} - -public class JumpLabel_1 : JumpLabel { - public JumpLabel_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class JumpStatement_1 : JumpStatement { - public JumpStatement_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class StateChange_1 : StateChange { - public StateChange_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class StateChange_2 : StateChange { - public StateChange_2(Parser yyq):base(yyq, - ((DEFAULT_STATE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IfStatement_1 : IfStatement { - public IfStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class IfStatement_2 : IfStatement { - public IfStatement_2(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(4).m_value)) - , - ((Statement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class IfStatement_3 : IfStatement { - public IfStatement_3(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class IfStatement_4 : IfStatement { - public IfStatement_4(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(4).m_value)) - , - ((Statement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class WhileStatement_1 : WhileStatement { - public WhileStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class WhileStatement_2 : WhileStatement { - public WhileStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class DoWhileStatement_1 : DoWhileStatement { - public DoWhileStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(5).m_value)) - ){}} - -public class DoWhileStatement_2 : DoWhileStatement { - public DoWhileStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(5).m_value)) - ){}} - -public class ForLoop_1 : ForLoop { - public ForLoop_1(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(6).m_value)) - , - ((Expression)(yyq.StackAt(4).m_value)) - , - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class ForLoop_2 : ForLoop { - public ForLoop_2(Parser yyq):base(yyq,null, - ((Expression)(yyq.StackAt(4).m_value)) - , - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Statement)(yyq.StackAt(0).m_value)) - ){}} - -public class ForLoopStatement_1 : ForLoopStatement { - public ForLoopStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class ForLoopStatement_2 : ForLoopStatement { - public ForLoopStatement_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} - -public class ForLoopStatement_3 : ForLoopStatement { - public ForLoopStatement_3(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class ForLoopStatement_4 : ForLoopStatement { - public ForLoopStatement_4(Parser yyq):base(yyq, - ((ForLoopStatement)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} - -public class Assignment_1 : Assignment { - public Assignment_1(Parser yyq):base(yyq, - ((Declaration)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class Assignment_2 : Assignment { - public Assignment_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - ){}} - -public class SimpleAssignment_1 : SimpleAssignment { - public SimpleAssignment_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_2 : SimpleAssignment { - public SimpleAssignment_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_3 : SimpleAssignment { - public SimpleAssignment_3(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_4 : SimpleAssignment { - public SimpleAssignment_4(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_5 : SimpleAssignment { - public SimpleAssignment_5(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_6 : SimpleAssignment { - public SimpleAssignment_6(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_7 : SimpleAssignment { - public SimpleAssignment_7(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_8 : SimpleAssignment { - public SimpleAssignment_8(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_9 : SimpleAssignment { - public SimpleAssignment_9(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_10 : SimpleAssignment { - public SimpleAssignment_10(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_11 : SimpleAssignment { - public SimpleAssignment_11(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_12 : SimpleAssignment { - public SimpleAssignment_12(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_13 : SimpleAssignment { - public SimpleAssignment_13(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_14 : SimpleAssignment { - public SimpleAssignment_14(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_15 : SimpleAssignment { - public SimpleAssignment_15(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_16 : SimpleAssignment { - public SimpleAssignment_16(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_17 : SimpleAssignment { - public SimpleAssignment_17(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_18 : SimpleAssignment { - public SimpleAssignment_18(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - , - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_19 : SimpleAssignment { - public SimpleAssignment_19(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_20 : SimpleAssignment { - public SimpleAssignment_20(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PLUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_21 : SimpleAssignment { - public SimpleAssignment_21(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((MINUS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_22 : SimpleAssignment { - public SimpleAssignment_22(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((STAR_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_23 : SimpleAssignment { - public SimpleAssignment_23(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((SLASH_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class SimpleAssignment_24 : SimpleAssignment { - public SimpleAssignment_24(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(4).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext), - ((SimpleAssignment)(yyq.StackAt(0).m_value)) - , - ((PERCENT_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class ReturnStatement_1 : ReturnStatement { - public ReturnStatement_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class ReturnStatement_2 : ReturnStatement { - public ReturnStatement_2(Parser yyq):base(yyq){}} - -public class Constant_1 : Constant { - public Constant_1(Parser yyq):base(yyq,"integer", - ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Constant_2 : Constant { - public Constant_2(Parser yyq):base(yyq,"integer", - ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Constant_3 : Constant { - public Constant_3(Parser yyq):base(yyq,"float", - ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Constant_4 : Constant { - public Constant_4(Parser yyq):base(yyq,"string", - ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class ListConstant_1 : ListConstant { - public ListConstant_1(Parser yyq):base(yyq, - ((ArgumentList)(yyq.StackAt(1).m_value)) - ){}} - -public class VectorConstant_1 : VectorConstant { - public VectorConstant_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(5).m_value)) - , - ((Expression)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - ){}} - -public class RotationConstant_1 : RotationConstant { - public RotationConstant_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(7).m_value)) - , - ((Expression)(yyq.StackAt(5).m_value)) - , - ((Expression)(yyq.StackAt(3).m_value)) - , - ((Expression)(yyq.StackAt(1).m_value)) - ){}} - -public class ConstantExpression_1 : ConstantExpression { - public ConstantExpression_1(Parser yyq):base(yyq, - ((Constant)(yyq.StackAt(0).m_value)) - ){}} - -public class IdentExpression_1 : IdentExpression { - public IdentExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IdentDotExpression_1 : IdentDotExpression { - public IdentDotExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IncrementDecrementExpression_1 : IncrementDecrementExpression { - public IncrementDecrementExpression_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} - -public class IncrementDecrementExpression_2 : IncrementDecrementExpression { - public IncrementDecrementExpression_2(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} - -public class IncrementDecrementExpression_3 : IncrementDecrementExpression { - public IncrementDecrementExpression_3(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} - -public class IncrementDecrementExpression_4 : IncrementDecrementExpression { - public IncrementDecrementExpression_4(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true){}} - -public class IncrementDecrementExpression_5 : IncrementDecrementExpression { - public IncrementDecrementExpression_5(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(1).m_value)) - .yytext, false){}} - -public class IncrementDecrementExpression_6 : IncrementDecrementExpression { - public IncrementDecrementExpression_6(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(1).m_value)) - .yytext, false){}} - -public class IncrementDecrementExpression_7 : IncrementDecrementExpression { - public IncrementDecrementExpression_7(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(3).m_value)) - .yytext, false){}} - -public class IncrementDecrementExpression_8 : IncrementDecrementExpression { - public IncrementDecrementExpression_8(Parser yyq):base(yyq,new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(3).m_value)) - .yytext, false){}} - -public class FunctionCallExpression_1 : FunctionCallExpression { - public FunctionCallExpression_1(Parser yyq):base(yyq, - ((FunctionCall)(yyq.StackAt(0).m_value)) - ){}} - -public class BinaryExpression_1 : BinaryExpression { - public BinaryExpression_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PLUS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_2 : BinaryExpression { - public BinaryExpression_2(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((MINUS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_3 : BinaryExpression { - public BinaryExpression_3(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STAR)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_4 : BinaryExpression { - public BinaryExpression_4(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((SLASH)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_5 : BinaryExpression { - public BinaryExpression_5(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((PERCENT)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_6 : BinaryExpression { - public BinaryExpression_6(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((AMP)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_7 : BinaryExpression { - public BinaryExpression_7(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STROKE)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_8 : BinaryExpression { - public BinaryExpression_8(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((CARET)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_9 : BinaryExpression { - public BinaryExpression_9(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((RIGHT_ANGLE)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_10 : BinaryExpression { - public BinaryExpression_10(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LEFT_ANGLE)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_11 : BinaryExpression { - public BinaryExpression_11(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EQUALS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_12 : BinaryExpression { - public BinaryExpression_12(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((EXCLAMATION_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_13 : BinaryExpression { - public BinaryExpression_13(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LESS_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_14 : BinaryExpression { - public BinaryExpression_14(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((GREATER_EQUALS)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_15 : BinaryExpression { - public BinaryExpression_15(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((AMP_AMP)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_16 : BinaryExpression { - public BinaryExpression_16(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((STROKE_STROKE)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_17 : BinaryExpression { - public BinaryExpression_17(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((LEFT_SHIFT)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class BinaryExpression_18 : BinaryExpression { - public BinaryExpression_18(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(2).m_value)) - , - ((Expression)(yyq.StackAt(0).m_value)) - , - ((RIGHT_SHIFT)(yyq.StackAt(1).m_value)) - .yytext){}} - -public class UnaryExpression_1 : UnaryExpression { - public UnaryExpression_1(Parser yyq):base(yyq, - ((EXCLAMATION)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class UnaryExpression_2 : UnaryExpression { - public UnaryExpression_2(Parser yyq):base(yyq, - ((MINUS)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class UnaryExpression_3 : UnaryExpression { - public UnaryExpression_3(Parser yyq):base(yyq, - ((TILDE)(yyq.StackAt(1).m_value)) - .yytext, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class ParenthesisExpression_1 : ParenthesisExpression { - public ParenthesisExpression_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} - -public class ParenthesisExpression_2 : ParenthesisExpression { - public ParenthesisExpression_2(Parser yyq):base(yyq, - ((SimpleAssignment)(yyq.StackAt(1).m_value)) - ){}} - -public class TypecastExpression_1 : TypecastExpression { - public TypecastExpression_1(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, - ((Constant)(yyq.StackAt(0).m_value)) - ){}} - -public class TypecastExpression_2 : TypecastExpression { - public TypecastExpression_2(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, new IdentExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext)){}} - -public class TypecastExpression_3 : TypecastExpression { - public TypecastExpression_3(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(4).m_value)) - .yytext, new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(2).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(0).m_value)) - .yytext)){}} - -public class TypecastExpression_4 : TypecastExpression { - public TypecastExpression_4(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(3).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} - -public class TypecastExpression_5 : TypecastExpression { - public TypecastExpression_5(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((INCREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} - -public class TypecastExpression_6 : TypecastExpression { - public TypecastExpression_6(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(3).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext, - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} - -public class TypecastExpression_7 : TypecastExpression { - public TypecastExpression_7(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(5).m_value)) - .yytext, new IncrementDecrementExpression(((LSLSyntax -)yyq), new IdentDotExpression(((LSLSyntax -)yyq), - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((IDENT)(yyq.StackAt(1).m_value)) - .yytext), - ((DECREMENT)(yyq.StackAt(0).m_value)) - .yytext, true)){}} - -public class TypecastExpression_8 : TypecastExpression { - public TypecastExpression_8(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(2).m_value)) - .yytext, - ((FunctionCall)(yyq.StackAt(0).m_value)) - ){}} - -public class TypecastExpression_9 : TypecastExpression { - public TypecastExpression_9(Parser yyq):base(yyq, - ((Typename)(yyq.StackAt(4).m_value)) - .yytext, - ((Expression)(yyq.StackAt(1).m_value)) - ){}} - -public class FunctionCall_1 : FunctionCall { - public FunctionCall_1(Parser yyq):base(yyq, - ((IDENT)(yyq.StackAt(3).m_value)) - .yytext, - ((ArgumentList)(yyq.StackAt(1).m_value)) - ){}} - -public class ArgumentList_1 : ArgumentList { - public ArgumentList_1(Parser yyq):base(yyq, - ((Argument)(yyq.StackAt(0).m_value)) - ){}} - -public class ArgumentList_2 : ArgumentList { - public ArgumentList_2(Parser yyq):base(yyq, - ((ArgumentList)(yyq.StackAt(2).m_value)) - , - ((Argument)(yyq.StackAt(0).m_value)) - ){}} - -public class ExpressionArgument_1 : ExpressionArgument { - public ExpressionArgument_1(Parser yyq):base(yyq, - ((Expression)(yyq.StackAt(0).m_value)) - ){}} - -public class Typename_1 : Typename { - public Typename_1(Parser yyq):base(yyq, - ((INTEGER_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_2 : Typename { - public Typename_2(Parser yyq):base(yyq, - ((FLOAT_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_3 : Typename { - public Typename_3(Parser yyq):base(yyq, - ((STRING_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_4 : Typename { - public Typename_4(Parser yyq):base(yyq, - ((KEY_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_5 : Typename { - public Typename_5(Parser yyq):base(yyq, - ((VECTOR_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_6 : Typename { - public Typename_6(Parser yyq):base(yyq, - ((ROTATION_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Typename_7 : Typename { - public Typename_7(Parser yyq):base(yyq, - ((LIST_TYPE)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_1 : Event { - public Event_1(Parser yyq):base(yyq, - ((DATASERVER_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_2 : Event { - public Event_2(Parser yyq):base(yyq, - ((EMAIL_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_3 : Event { - public Event_3(Parser yyq):base(yyq, - ((HTTP_RESPONSE_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_4 : Event { - public Event_4(Parser yyq):base(yyq, - ((LINK_MESSAGE_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_5 : Event { - public Event_5(Parser yyq):base(yyq, - ((LISTEN_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_6 : Event { - public Event_6(Parser yyq):base(yyq, - ((MONEY_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_7 : Event { - public Event_7(Parser yyq):base(yyq, - ((REMOTE_DATA_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_8 : Event { - public Event_8(Parser yyq):base(yyq, - ((HTTP_REQUEST_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class Event_9 : Event { - public Event_9(Parser yyq):base(yyq, - ((TRANSACTION_RESULT_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_1 : VoidArgEvent { - public VoidArgEvent_1(Parser yyq):base(yyq, - ((STATE_ENTRY_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_2 : VoidArgEvent { - public VoidArgEvent_2(Parser yyq):base(yyq, - ((STATE_EXIT_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_3 : VoidArgEvent { - public VoidArgEvent_3(Parser yyq):base(yyq, - ((MOVING_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_4 : VoidArgEvent { - public VoidArgEvent_4(Parser yyq):base(yyq, - ((MOVING_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_5 : VoidArgEvent { - public VoidArgEvent_5(Parser yyq):base(yyq, - ((NO_SENSOR_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_6 : VoidArgEvent { - public VoidArgEvent_6(Parser yyq):base(yyq, - ((NOT_AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_7 : VoidArgEvent { - public VoidArgEvent_7(Parser yyq):base(yyq, - ((NOT_AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VoidArgEvent_8 : VoidArgEvent { - public VoidArgEvent_8(Parser yyq):base(yyq, - ((TIMER_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class KeyArgEvent_1 : KeyArgEvent { - public KeyArgEvent_1(Parser yyq):base(yyq, - ((ATTACH_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class KeyArgEvent_2 : KeyArgEvent { - public KeyArgEvent_2(Parser yyq):base(yyq, - ((OBJECT_REZ_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_1 : IntArgEvent { - public IntArgEvent_1(Parser yyq):base(yyq, - ((CHANGED_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_2 : IntArgEvent { - public IntArgEvent_2(Parser yyq):base(yyq, - ((COLLISION_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_3 : IntArgEvent { - public IntArgEvent_3(Parser yyq):base(yyq, - ((COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_4 : IntArgEvent { - public IntArgEvent_4(Parser yyq):base(yyq, - ((COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_5 : IntArgEvent { - public IntArgEvent_5(Parser yyq):base(yyq, - ((ON_REZ_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_6 : IntArgEvent { - public IntArgEvent_6(Parser yyq):base(yyq, - ((RUN_TIME_PERMISSIONS_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_7 : IntArgEvent { - public IntArgEvent_7(Parser yyq):base(yyq, - ((SENSOR_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_8 : IntArgEvent { - public IntArgEvent_8(Parser yyq):base(yyq, - ((TOUCH_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_9 : IntArgEvent { - public IntArgEvent_9(Parser yyq):base(yyq, - ((TOUCH_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntArgEvent_10 : IntArgEvent { - public IntArgEvent_10(Parser yyq):base(yyq, - ((TOUCH_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VectorArgEvent_1 : VectorArgEvent { - public VectorArgEvent_1(Parser yyq):base(yyq, - ((LAND_COLLISION_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VectorArgEvent_2 : VectorArgEvent { - public VectorArgEvent_2(Parser yyq):base(yyq, - ((LAND_COLLISION_END_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class VectorArgEvent_3 : VectorArgEvent { - public VectorArgEvent_3(Parser yyq):base(yyq, - ((LAND_COLLISION_START_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntRotRotArgEvent_1 : IntRotRotArgEvent { - public IntRotRotArgEvent_1(Parser yyq):base(yyq, - ((AT_ROT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class IntVecVecArgEvent_1 : IntVecVecArgEvent { - public IntVecVecArgEvent_1(Parser yyq):base(yyq, - ((AT_TARGET_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} - -public class KeyIntIntArgEvent_1 : KeyIntIntArgEvent { - public KeyIntIntArgEvent_1(Parser yyq):base(yyq, - ((CONTROL_EVENT)(yyq.StackAt(0).m_value)) - .yytext){}} -public class yyLSLSyntax -: YyParser { - public override object Action(Parser yyq,SYMBOL yysym, int yyact) { - switch(yyact) { - case -1: break; //// keep compiler happy -} return null; } - -public class ArgumentDeclarationList_3 : ArgumentDeclarationList { - public ArgumentDeclarationList_3(Parser yyq):base(yyq){}} - -public class ArgumentList_3 : ArgumentList { - public ArgumentList_3(Parser yyq):base(yyq){}} - -public class ArgumentList_4 : ArgumentList { - public ArgumentList_4(Parser yyq):base(yyq){}} - -public class ArgumentDeclarationList_4 : ArgumentDeclarationList { - public ArgumentDeclarationList_4(Parser yyq):base(yyq){}} - -public class ArgumentDeclarationList_5 : ArgumentDeclarationList { - public ArgumentDeclarationList_5(Parser yyq):base(yyq){}} -public yyLSLSyntax -():base() { arr = new int[] { -101,4,6,52,0, -46,0,53,0,102, -20,103,4,28,76, -0,83,0,76,0, -80,0,114,0,111, -0,103,0,114,0, -97,0,109,0,82, -0,111,0,111,0, -116,0,1,97,1, -2,104,18,1,2845, -102,2,0,105,5, -395,1,1224,106,18, -1,1224,107,20,108, -4,32,83,0,105, -0,109,0,112,0, -108,0,101,0,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,1, -138,1,2,2,0, -1,2043,109,18,1, -2043,110,20,111,4, -18,83,0,69,0, -77,0,73,0,67, -0,79,0,76,0, -79,0,78,0,1, -11,1,1,2,0, -1,2755,112,18,1, -2755,113,20,114,4, -22,82,0,73,0, -71,0,72,0,84, -0,95,0,66,0, -82,0,65,0,67, -0,69,0,1,13, -1,1,2,0,1, -1834,115,18,1,1834, -116,20,117,4,20, -76,0,69,0,70, -0,84,0,95,0, -80,0,65,0,82, -0,69,0,78,0, -1,16,1,1,2, -0,1,1833,118,18, -1,1833,119,20,120, -4,10,87,0,72, -0,73,0,76,0, -69,0,1,45,1, -1,2,0,1,1832, -121,18,1,1832,122, -20,123,4,18,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,1,135,1, -2,2,0,1,1804, -124,18,1,1804,125, -20,126,4,4,68, -0,79,0,1,44, -1,1,2,0,1, -1803,127,18,1,1803, -122,2,0,1,883, -128,18,1,883,129, -20,130,4,20,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, -156,1,2,2,0, -1,461,131,18,1, -461,132,20,133,4, -24,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -1,149,1,2,2, -0,1,2703,134,18, -1,2703,135,20,136, -4,18,83,0,116, -0,97,0,116,0, -101,0,66,0,111, -0,100,0,121,0, -1,103,1,2,2, -0,1,1775,137,18, -1,1775,138,20,139, -4,22,82,0,73, -0,71,0,72,0, -84,0,95,0,80, -0,65,0,82,0, -69,0,78,0,1, -17,1,1,2,0, -1,1773,140,18,1, -1773,141,20,142,4, -32,70,0,111,0, -114,0,76,0,111, -0,111,0,112,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,147, -1,2,2,0,1, -1931,143,18,1,1931, -122,2,0,1,1756, -144,18,1,1756,110, -2,0,1,827,145, -18,1,827,129,2, -0,1,2541,146,18, -1,2541,147,20,148, -4,10,67,0,79, -0,77,0,77,0, -65,0,1,14,1, -1,2,0,1,2659, -149,18,1,2659,150, -20,151,4,20,76, -0,69,0,70,0, -84,0,95,0,66, -0,82,0,65,0, -67,0,69,0,1, -12,1,1,2,0, -1,2658,152,18,1, -2658,153,20,154,4, -26,68,0,69,0, -70,0,65,0,85, -0,76,0,84,0, -95,0,83,0,84, -0,65,0,84,0, -69,0,1,47,1, -1,2,0,1,2657, -155,18,1,2657,156, -20,157,4,20,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,1, -104,1,2,2,0, -1,1737,158,18,1, -1737,129,2,0,1, -377,159,18,1,377, -160,20,161,4,10, -73,0,68,0,69, -0,78,0,84,0, -1,93,1,1,2, -0,1,2654,162,18, -1,2654,163,20,164, -4,32,73,0,110, -0,116,0,65,0, -114,0,103,0,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,1, -107,1,2,2,0, -1,2033,165,18,1, -2033,166,20,167,4, -22,73,0,102,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,143, -1,2,2,0,1, -2652,168,18,1,2652, -169,20,170,4,44, -73,0,110,0,116, -0,82,0,111,0, -116,0,82,0,111, -0,116,0,65,0, -114,0,103,0,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,1, -109,1,2,2,0, -1,2651,171,18,1, -2651,172,20,173,4, -44,73,0,110,0, -116,0,86,0,101, -0,99,0,86,0, -101,0,99,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -1,110,1,2,2, -0,1,1731,174,18, -1,1731,110,2,0, -1,1730,175,18,1, -1730,107,2,0,1, -2648,176,18,1,2648, -156,2,0,1,2647, -177,18,1,2647,178, -20,179,4,34,86, -0,111,0,105,0, -100,0,65,0,114, -0,103,0,83,0, -116,0,97,0,116, -0,101,0,69,0, -118,0,101,0,110, -0,116,0,1,105, -1,2,2,0,1, -2646,180,18,1,2646, -181,20,182,4,32, -75,0,101,0,121, -0,65,0,114,0, -103,0,83,0,116, -0,97,0,116,0, -101,0,69,0,118, -0,101,0,110,0, -116,0,1,106,1, -2,2,0,1,2645, -183,18,1,2645,163, -2,0,1,2644,184, -18,1,2644,185,20, -186,4,38,86,0, -101,0,99,0,116, -0,111,0,114,0, -65,0,114,0,103, -0,83,0,116,0, -97,0,116,0,101, -0,69,0,118,0, -101,0,110,0,116, -0,1,108,1,2, -2,0,1,2643,187, -18,1,2643,169,2, -0,1,2642,188,18, -1,2642,172,2,0, -1,2641,189,18,1, -2641,190,20,191,4, -44,75,0,101,0, -121,0,73,0,110, -0,116,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -1,111,1,2,2, -0,1,2767,192,18, -1,2767,193,20,194, -4,10,83,0,116, -0,97,0,116,0, -101,0,1,102,1, -2,2,0,1,2577, -195,18,1,2577,116, -2,0,1,1701,196, -18,1,1701,129,2, -0,1,1695,197,18, -1,1695,147,2,0, -1,1694,198,18,1, -1694,141,2,0,1, -2597,199,18,1,2597, -135,2,0,1,2595, -200,18,1,2595,201, -20,202,4,34,67, -0,111,0,109,0, -112,0,111,0,117, -0,110,0,100,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,133, -1,2,2,0,1, -2593,203,18,1,2593, -138,2,0,1,2591, -204,18,1,2591,205, -20,206,4,46,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -1,112,1,2,2, -0,1,1665,207,18, -1,1665,129,2,0, -1,2582,208,18,1, -2582,116,2,0,1, -2581,209,18,1,2581, -210,20,211,4,10, -69,0,118,0,101, -0,110,0,116,0, -1,125,1,2,2, -0,1,2580,212,18, -1,2580,201,2,0, -1,1659,213,18,1, -1659,116,2,0,1, -1658,214,18,1,1658, -215,20,216,4,6, -70,0,79,0,82, -0,1,46,1,1, -2,0,1,1657,217, -18,1,1657,110,2, -0,1,2575,218,18, -1,2575,201,2,0, -1,2573,219,18,1, -2573,138,2,0,1, -2572,220,18,1,2572, -221,20,222,4,52, -75,0,101,0,121, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,113,1, -2,2,0,1,2571, -223,18,1,2571,224, -20,225,4,28,75, -0,101,0,121,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,1,120,1, -2,2,0,1,2569, -226,18,1,2569,116, -2,0,1,2568,227, -18,1,2568,228,20, -229,4,22,75,0, -101,0,121,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -1,127,1,2,2, -0,1,2567,230,18, -1,2567,201,2,0, -1,2565,231,18,1, -2565,138,2,0,1, -2564,232,18,1,2564, -233,20,234,4,52, -73,0,110,0,116, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,114,1, -2,2,0,1,2563, -235,18,1,2563,236, -20,237,4,28,73, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,1,121,1, -2,2,0,1,2561, -238,18,1,2561,116, -2,0,1,2560,239, -18,1,2560,240,20, -241,4,22,73,0, -110,0,116,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -1,128,1,2,2, -0,1,2559,242,18, -1,2559,201,2,0, -1,2557,243,18,1, -2557,138,2,0,1, -2556,244,18,1,2556, -245,20,246,4,58, -86,0,101,0,99, -0,116,0,111,0, -114,0,65,0,114, -0,103,0,117,0, -109,0,101,0,110, -0,116,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -76,0,105,0,115, -0,116,0,1,115, -1,2,2,0,1, -2555,247,18,1,2555, -248,20,249,4,28, -86,0,101,0,99, -0,68,0,101,0, -99,0,108,0,97, -0,114,0,97,0, -116,0,105,0,111, -0,110,0,1,122, -1,2,2,0,1, -2649,250,18,1,2649, -113,2,0,1,151, -251,18,1,151,252, -20,253,4,26,69, -0,81,0,85,0, -65,0,76,0,83, -0,95,0,69,0, -81,0,85,0,65, -0,76,0,83,0, -1,29,1,1,2, -0,1,1123,254,18, -1,1123,129,2,0, -1,1939,255,18,1, -1939,129,2,0,1, -2653,256,18,1,2653, -185,2,0,1,2549, -257,18,1,2549,138, -2,0,1,2548,258, -18,1,2548,259,20, -260,4,64,73,0, -110,0,116,0,82, -0,111,0,116,0, -82,0,111,0,116, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,116,1, -2,2,0,1,1628, -261,18,1,1628,129, -2,0,1,2545,262, -18,1,2545,147,2, -0,1,2544,263,18, -1,2544,264,20,265, -4,28,82,0,111, -0,116,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -1,123,1,2,2, -0,1,2543,266,18, -1,2543,160,2,0, -1,2542,267,18,1, -2542,268,20,269,4, -26,82,0,79,0, -84,0,65,0,84, -0,73,0,79,0, -78,0,95,0,84, -0,89,0,80,0, -69,0,1,56,1, -1,2,0,1,1622, -270,18,1,1622,271, -20,272,4,12,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,15,1,1, -2,0,1,1621,273, -18,1,1621,274,20, -275,4,22,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -1,119,1,2,2, -0,1,1620,276,18, -1,1620,107,2,0, -1,2538,277,18,1, -2538,116,2,0,1, -2537,278,18,1,2537, -279,20,280,4,34, -73,0,110,0,116, -0,82,0,111,0, -116,0,82,0,111, -0,116,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,1, -130,1,2,2,0, -1,2536,281,18,1, -2536,201,2,0,1, -2534,282,18,1,2534, -138,2,0,1,2533, -283,18,1,2533,284, -20,285,4,64,73, -0,110,0,116,0, -86,0,101,0,99, -0,86,0,101,0, -99,0,65,0,114, -0,103,0,117,0, -109,0,101,0,110, -0,116,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -76,0,105,0,115, -0,116,0,1,117, -1,2,2,0,1, -2532,286,18,1,2532, -248,2,0,1,2530, -287,18,1,2530,147, -2,0,1,2529,288, -18,1,2529,248,2, -0,1,2528,289,18, -1,2528,160,2,0, -1,2527,290,18,1, -2527,291,20,292,4, -22,86,0,69,0, -67,0,84,0,79, -0,82,0,95,0, -84,0,89,0,80, -0,69,0,1,55, -1,1,2,0,1, -2526,293,18,1,2526, -147,2,0,1,2525, -294,18,1,2525,236, -2,0,1,2523,295, -18,1,2523,116,2, -0,1,2522,296,18, -1,2522,297,20,298, -4,34,73,0,110, -0,116,0,86,0, -101,0,99,0,86, -0,101,0,99,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,1,131,1,2, -2,0,1,2521,299, -18,1,2521,201,2, -0,1,2519,300,18, -1,2519,138,2,0, -1,2518,301,18,1, -2518,302,20,303,4, -64,75,0,101,0, -121,0,73,0,110, -0,116,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -1,118,1,2,2, -0,1,2517,304,18, -1,2517,236,2,0, -1,2515,305,18,1, -2515,147,2,0,1, -2514,306,18,1,2514, -236,2,0,1,2513, -307,18,1,2513,160, -2,0,1,2512,308, -18,1,2512,309,20, -310,4,24,73,0, -78,0,84,0,69, -0,71,0,69,0, -82,0,95,0,84, -0,89,0,80,0, -69,0,1,51,1, -1,2,0,1,2511, -311,18,1,2511,147, -2,0,1,1591,312, -18,1,1591,129,2, -0,1,2509,313,18, -1,2509,160,2,0, -1,2508,314,18,1, -2508,315,20,316,4, -16,75,0,69,0, -89,0,95,0,84, -0,89,0,80,0, -69,0,1,54,1, -1,2,0,1,2507, -317,18,1,2507,116, -2,0,1,2506,318, -18,1,2506,319,20, -320,4,34,75,0, -101,0,121,0,73, -0,110,0,116,0, -73,0,110,0,116, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,1,132,1, -2,2,0,1,2505, -321,18,1,2505,322, -20,323,4,32,68, -0,65,0,84,0, -65,0,83,0,69, -0,82,0,86,0, -69,0,82,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,66,1,1, -2,0,1,1585,324, -18,1,1585,325,20, -326,4,12,82,0, -69,0,84,0,85, -0,82,0,78,0, -1,50,1,1,2, -0,1,2503,327,18, -1,2503,328,20,329, -4,38,72,0,84, -0,84,0,80,0, -95,0,82,0,69, -0,83,0,80,0, -79,0,78,0,83, -0,69,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,68,1,1,2, -0,1,2502,330,18, -1,2502,331,20,332, -4,36,76,0,73, -0,78,0,75,0, -95,0,77,0,69, -0,83,0,83,0, -65,0,71,0,69, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,72, -1,1,2,0,1, -2501,333,18,1,2501, -334,20,335,4,24, -76,0,73,0,83, -0,84,0,69,0, -78,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -73,1,1,2,0, -1,2500,336,18,1, -2500,337,20,338,4, -22,77,0,79,0, -78,0,69,0,89, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,74, -1,1,2,0,1, -2499,339,18,1,2499, -340,20,341,4,34, -82,0,69,0,77, -0,79,0,84,0, -69,0,95,0,68, -0,65,0,84,0, -65,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -82,1,1,2,0, -1,2498,342,18,1, -2498,343,20,344,4, -36,72,0,84,0, -84,0,80,0,95, -0,82,0,69,0, -81,0,85,0,69, -0,83,0,84,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,91,1, -1,2,0,1,2497, -345,18,1,2497,346, -20,347,4,48,84, -0,82,0,65,0, -78,0,83,0,65, -0,67,0,84,0, -73,0,79,0,78, -0,95,0,82,0, -69,0,83,0,85, -0,76,0,84,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,92,1, -1,2,0,1,2496, -348,18,1,2496,349, -20,350,4,34,83, -0,84,0,65,0, -84,0,69,0,95, -0,69,0,78,0, -84,0,82,0,89, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,85, -1,1,2,0,1, -2495,351,18,1,2495, -352,20,353,4,32, -83,0,84,0,65, -0,84,0,69,0, -95,0,69,0,88, -0,73,0,84,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,86,1, -1,2,0,1,2494, -354,18,1,2494,355, -20,356,4,32,77, -0,79,0,86,0, -73,0,78,0,71, -0,95,0,69,0, -78,0,68,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,75,1,1, -2,0,1,1574,357, -18,1,1574,110,2, -0,1,2492,358,18, -1,2492,359,20,360, -4,30,78,0,79, -0,95,0,83,0, -69,0,78,0,83, -0,79,0,82,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,77,1, -1,2,0,1,2491, -361,18,1,2491,362, -20,363,4,46,78, -0,79,0,84,0, -95,0,65,0,84, -0,95,0,82,0, -79,0,84,0,95, -0,84,0,65,0, -82,0,71,0,69, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,78,1,1,2, -0,1,2490,364,18, -1,2490,365,20,366, -4,38,78,0,79, -0,84,0,95,0, -65,0,84,0,95, -0,84,0,65,0, -82,0,71,0,69, -0,84,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,79,1,1,2, -0,1,2489,367,18, -1,2489,368,20,369, -4,22,84,0,73, -0,77,0,69,0, -82,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -87,1,1,2,0, -1,2488,370,18,1, -2488,371,20,372,4, -24,65,0,84,0, -84,0,65,0,67, -0,72,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,60,1,1,2, -0,1,2487,373,18, -1,2487,374,20,375, -4,32,79,0,66, -0,74,0,69,0, -67,0,84,0,95, -0,82,0,69,0, -90,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -80,1,1,2,0, -1,2486,376,18,1, -2486,377,20,378,4, -26,67,0,72,0, -65,0,78,0,71, -0,69,0,68,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,61,1, -1,2,0,1,2485, -379,18,1,2485,380, -20,381,4,30,67, -0,79,0,76,0, -76,0,73,0,83, -0,73,0,79,0, -78,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -62,1,1,2,0, -1,2484,382,18,1, -2484,383,20,384,4, -38,67,0,79,0, -76,0,76,0,73, -0,83,0,73,0, -79,0,78,0,95, -0,69,0,78,0, -68,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -63,1,1,2,0, -1,2483,385,18,1, -2483,386,20,387,4, -42,67,0,79,0, -76,0,76,0,73, -0,83,0,73,0, -79,0,78,0,95, -0,83,0,84,0, -65,0,82,0,84, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,64, -1,1,2,0,1, -2482,388,18,1,2482, -389,20,390,4,24, -79,0,78,0,95, -0,82,0,69,0, -90,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -81,1,1,2,0, -1,2481,391,18,1, -2481,392,20,393,4, -52,82,0,85,0, -78,0,95,0,84, -0,73,0,77,0, -69,0,95,0,80, -0,69,0,82,0, -77,0,73,0,83, -0,83,0,73,0, -79,0,78,0,83, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,83, -1,1,2,0,1, -2480,394,18,1,2480, -395,20,396,4,24, -83,0,69,0,78, -0,83,0,79,0, -82,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -84,1,1,2,0, -1,2479,397,18,1, -2479,398,20,399,4, -22,84,0,79,0, -85,0,67,0,72, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,88, -1,1,2,0,1, -2478,400,18,1,2478, -401,20,402,4,30, -84,0,79,0,85, -0,67,0,72,0, -95,0,69,0,78, -0,68,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,90,1,1,2, -0,1,2477,403,18, -1,2477,404,20,405, -4,34,84,0,79, -0,85,0,67,0, -72,0,95,0,83, -0,84,0,65,0, -82,0,84,0,95, -0,69,0,86,0, -69,0,78,0,84, -0,1,89,1,1, -2,0,1,2476,406, -18,1,2476,407,20, -408,4,40,76,0, -65,0,78,0,68, -0,95,0,67,0, -79,0,76,0,76, -0,73,0,83,0, -73,0,79,0,78, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,69, -1,1,2,0,1, -2475,409,18,1,2475, -410,20,411,4,48, -76,0,65,0,78, -0,68,0,95,0, -67,0,79,0,76, -0,76,0,73,0, -83,0,73,0,79, -0,78,0,95,0, -69,0,78,0,68, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,70, -1,1,2,0,1, -1555,412,18,1,1555, -129,2,0,1,2473, -413,18,1,2473,414, -20,415,4,38,65, -0,84,0,95,0, -82,0,79,0,84, -0,95,0,84,0, -65,0,82,0,71, -0,69,0,84,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,58,1, -1,2,0,1,2472, -416,18,1,2472,417, -20,418,4,30,65, -0,84,0,95,0, -84,0,65,0,82, -0,71,0,69,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -59,1,1,2,0, -1,2471,419,18,1, -2471,420,20,421,4, -26,67,0,79,0, -78,0,84,0,82, -0,79,0,76,0, -95,0,69,0,86, -0,69,0,78,0, -84,0,1,65,1, -1,2,0,1,2470, -422,18,1,2470,150, -2,0,1,2469,423, -18,1,2469,160,2, -0,1,2468,424,18, -1,2468,425,20,426, -4,10,83,0,84, -0,65,0,84,0, -69,0,1,48,1, -1,2,0,1,2467, -427,18,1,2467,274, -2,0,1,2466,428, -18,1,2466,201,2, -0,1,2464,429,18, -1,2464,113,2,0, -1,2462,430,18,1, -2462,122,2,0,1, -2459,431,18,1,2459, -113,2,0,1,2458, -432,18,1,2458,122, -2,0,1,1113,433, -18,1,1113,434,20, -435,4,12,80,0, -69,0,82,0,73, -0,79,0,68,0, -1,24,1,1,2, -0,1,1932,436,18, -1,1932,437,20,438, -4,4,73,0,70, -0,1,42,1,1, -2,0,1,2553,439, -18,1,2553,116,2, -0,1,1521,440,18, -1,1521,129,2,0, -1,1515,441,18,1, -1515,271,2,0,1, -1514,442,18,1,1514, -107,2,0,1,2576, -443,18,1,2576,444, -20,445,4,24,86, -0,111,0,105,0, -100,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,1,126, -1,2,2,0,1, -2074,446,18,1,2074, -107,2,0,1,2413, -447,18,1,2413,448, -20,449,4,26,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -1,134,1,2,2, -0,1,1485,450,18, -1,1485,129,2,0, -1,1479,451,18,1, -1479,452,20,453,4, -22,80,0,76,0, -85,0,83,0,95, -0,69,0,81,0, -85,0,65,0,76, -0,83,0,1,6, -1,1,2,0,1, -1478,454,18,1,1478, -107,2,0,1,378, -455,18,1,378,434, -2,0,1,2318,456, -18,1,2318,110,2, -0,1,1449,457,18, -1,1449,129,2,0, -1,2364,458,18,1, -2364,122,2,0,1, -525,459,18,1,525, -460,20,461,4,22, -82,0,73,0,71, -0,72,0,84,0, -95,0,65,0,78, -0,71,0,76,0, -69,0,1,26,1, -1,2,0,1,1443, -462,18,1,1443,463, -20,464,4,24,77, -0,73,0,78,0, -85,0,83,0,95, -0,69,0,81,0, -85,0,65,0,76, -0,83,0,1,7, -1,1,2,0,1, -1442,465,18,1,1442, -107,2,0,1,515, -466,18,1,515,129, -2,0,1,2650,467, -18,1,2650,190,2, -0,1,509,468,18, -1,509,147,2,0, -1,2552,469,18,1, -2552,470,20,471,4, -28,86,0,101,0, -99,0,116,0,111, -0,114,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,1, -129,1,2,2,0, -1,2042,472,18,1, -2042,473,20,474,4, -20,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,1,137,1,2, -2,0,1,2337,475, -18,1,2337,138,2, -0,1,2335,476,18, -1,2335,141,2,0, -1,1413,477,18,1, -1413,129,2,0,1, -1407,478,18,1,1407, -479,20,480,4,22, -83,0,84,0,65, -0,82,0,95,0, -69,0,81,0,85, -0,65,0,76,0, -83,0,1,8,1, -1,2,0,1,1406, -481,18,1,1406,107, -2,0,1,2779,482, -18,1,2779,205,2, -0,1,481,483,18, -1,481,484,20,485, -4,16,65,0,114, -0,103,0,117,0, -109,0,101,0,110, -0,116,0,1,150, -1,2,2,0,1, -480,486,18,1,480, -487,20,488,4,26, -82,0,73,0,71, -0,72,0,84,0, -95,0,66,0,82, -0,65,0,67,0, -75,0,69,0,84, -0,1,28,1,1, -2,0,1,479,489, -18,1,479,490,20, -491,4,32,73,0, -78,0,84,0,69, -0,71,0,69,0, -82,0,95,0,67, -0,79,0,78,0, -83,0,84,0,65, -0,78,0,84,0, -1,94,1,1,2, -0,1,478,492,18, -1,478,493,20,494, -4,40,72,0,69, -0,88,0,95,0, -73,0,78,0,84, -0,69,0,71,0, -69,0,82,0,95, -0,67,0,79,0, -78,0,83,0,84, -0,65,0,78,0, -84,0,1,95,1, -1,2,0,1,477, -495,18,1,477,496, -20,497,4,28,70, -0,76,0,79,0, -65,0,84,0,95, -0,67,0,79,0, -78,0,83,0,84, -0,65,0,78,0, -84,0,1,96,1, -1,2,0,1,476, -498,18,1,476,499, -20,500,4,30,83, -0,84,0,82,0, -73,0,78,0,71, -0,95,0,67,0, -79,0,78,0,83, -0,84,0,65,0, -78,0,84,0,1, -3,1,1,2,0, -1,2822,501,18,1, -2822,110,2,0,1, -464,502,18,1,464, -484,2,0,1,462, -503,18,1,462,147, -2,0,1,2299,504, -18,1,2299,129,2, -0,1,459,505,18, -1,459,506,20,507, -4,24,76,0,69, -0,70,0,84,0, -95,0,66,0,82, -0,65,0,67,0, -75,0,69,0,84, -0,1,27,1,1, -2,0,1,1377,508, -18,1,1377,129,2, -0,1,2293,509,18, -1,2293,110,2,0, -1,1371,510,18,1, -1371,511,20,512,4, -24,83,0,76,0, -65,0,83,0,72, -0,95,0,69,0, -81,0,85,0,65, -0,76,0,83,0, -1,9,1,1,2, -0,1,1370,513,18, -1,1370,107,2,0, -1,447,514,18,1, -447,460,2,0,1, -2281,515,18,1,2281, -107,2,0,1,437, -516,18,1,437,129, -2,0,1,431,517, -18,1,431,147,2, -0,1,1341,518,18, -1,1341,129,2,0, -1,2842,519,18,1, -2842,520,20,521,4, -50,71,0,108,0, -111,0,98,0,97, -0,108,0,86,0, -97,0,114,0,105, -0,97,0,98,0, -108,0,101,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,1,99,1,2, -2,0,1,1335,522, -18,1,1335,523,20, -524,4,28,80,0, -69,0,82,0,67, -0,69,0,78,0, -84,0,95,0,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,10,1,1, -2,0,1,2547,525, -18,1,2547,264,2, -0,1,1332,526,18, -1,1332,107,2,0, -1,412,527,18,1, -412,129,2,0,1, -2037,528,18,1,2037, -110,2,0,1,1012, -529,18,1,1012,129, -2,0,1,1840,530, -18,1,1840,129,2, -0,1,406,531,18, -1,406,147,2,0, -1,2227,532,18,1, -2227,122,2,0,1, -387,533,18,1,387, -129,2,0,1,1303, -534,18,1,1303,129, -2,0,1,381,535, -18,1,381,536,20, -537,4,20,76,0, -69,0,70,0,84, -0,95,0,65,0, -78,0,71,0,76, -0,69,0,1,25, -1,1,2,0,1, -380,538,18,1,380, -539,20,540,4,16, -67,0,111,0,110, -0,115,0,116,0, -97,0,110,0,116, -0,1,152,1,2, -2,0,1,379,541, -18,1,379,160,2, -0,1,1297,542,18, -1,1297,271,2,0, -1,1296,543,18,1, -1296,107,2,0,1, -376,544,18,1,376, -545,20,546,4,18, -73,0,78,0,67, -0,82,0,69,0, -77,0,69,0,78, -0,84,0,1,4, -1,1,2,0,1, -375,547,18,1,375, -160,2,0,1,374, -548,18,1,374,434, -2,0,1,373,549, -18,1,373,160,2, -0,1,372,550,18, -1,372,551,20,552, -4,18,68,0,69, -0,67,0,82,0, -69,0,77,0,69, -0,78,0,84,0, -1,5,1,1,2, -0,1,371,553,18, -1,371,554,20,555, -4,24,70,0,117, -0,110,0,99,0, -116,0,105,0,111, -0,110,0,67,0, -97,0,108,0,108, -0,1,148,1,2, -2,0,1,2792,556, -18,1,2792,129,2, -0,1,2198,557,18, -1,2198,138,2,0, -1,2197,558,18,1, -2197,107,2,0,1, -352,559,18,1,352, -129,2,0,1,1267, -560,18,1,1267,129, -2,0,1,346,561, -18,1,346,562,20, -563,4,8,80,0, -76,0,85,0,83, -0,1,18,1,1, -2,0,1,1261,564, -18,1,1261,452,2, -0,1,1260,565,18, -1,1260,107,2,0, -1,328,566,18,1, -328,129,2,0,1, -322,567,18,1,322, -568,20,569,4,10, -77,0,73,0,78, -0,85,0,83,0, -1,19,1,1,2, -0,1,2846,570,18, -1,2846,571,23,572, -4,6,69,0,79, -0,70,0,1,2, -1,6,2,0,1, -1231,573,18,1,1231, -129,2,0,1,1225, -574,18,1,1225,463, -2,0,1,305,575, -18,1,305,129,2, -0,1,2041,576,18, -1,2041,110,2,0, -1,2656,577,18,1, -2656,178,2,0,1, -299,578,18,1,299, -579,20,580,4,8, -83,0,84,0,65, -0,82,0,1,20, -1,1,2,0,1, -2136,581,18,1,2136, -122,2,0,1,2764, -582,18,1,2764,583, -20,584,4,12,83, -0,116,0,97,0, -116,0,101,0,115, -0,1,101,1,2, -2,0,1,283,585, -18,1,283,129,2, -0,1,277,586,18, -1,277,587,20,588, -4,10,83,0,76, -0,65,0,83,0, -72,0,1,21,1, -1,2,0,1,1195, -589,18,1,1195,129, -2,0,1,1189,590, -18,1,1189,479,2, -0,1,1188,591,18, -1,1188,107,2,0, -1,2106,592,18,1, -2106,593,20,594,4, -8,69,0,76,0, -83,0,69,0,1, -43,1,1,2,0, -1,2105,595,18,1, -2105,122,2,0,1, -1550,596,18,1,1550, -107,2,0,1,262, -597,18,1,262,129, -2,0,1,2493,598, -18,1,2493,599,20, -600,4,36,77,0, -79,0,86,0,73, -0,78,0,71,0, -95,0,83,0,84, -0,65,0,82,0, -84,0,95,0,69, -0,86,0,69,0, -78,0,84,0,1, -76,1,1,2,0, -1,256,601,18,1, -256,602,20,603,4, -14,80,0,69,0, -82,0,67,0,69, -0,78,0,84,0, -1,22,1,1,2, -0,1,242,604,18, -1,242,129,2,0, -1,1159,605,18,1, -1159,129,2,0,1, -2075,606,18,1,2075, -138,2,0,1,236, -607,18,1,236,608, -20,609,4,6,65, -0,77,0,80,0, -1,33,1,1,2, -0,1,2823,610,18, -1,2823,611,20,612, -4,34,71,0,108, -0,111,0,98,0, -97,0,108,0,68, -0,101,0,102,0, -105,0,110,0,105, -0,116,0,105,0, -111,0,110,0,115, -0,1,98,1,2, -2,0,1,1153,613, -18,1,1153,511,2, -0,1,1152,614,18, -1,1152,107,2,0, -1,223,615,18,1, -223,129,2,0,1, -217,616,18,1,217, -617,20,618,4,12, -83,0,84,0,82, -0,79,0,75,0, -69,0,1,34,1, -1,2,0,1,2036, -619,18,1,2036,620, -20,621,4,26,74, -0,117,0,109,0, -112,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,141,1,2,2, -0,1,2045,622,18, -1,2045,110,2,0, -1,2044,623,18,1, -2044,624,20,625,4, -28,69,0,109,0, -112,0,116,0,121, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,1, -136,1,2,2,0, -1,205,626,18,1, -205,129,2,0,1, -1001,627,18,1,1001, -554,2,0,1,1901, -628,18,1,1901,138, -2,0,1,2040,629, -18,1,2040,630,20, -631,4,30,82,0, -101,0,116,0,117, -0,114,0,110,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,139, -1,2,2,0,1, -2039,632,18,1,2039, -110,2,0,1,2038, -633,18,1,2038,634, -20,635,4,18,74, -0,117,0,109,0, -112,0,76,0,97, -0,98,0,101,0, -108,0,1,140,1, -2,2,0,1,199, -636,18,1,199,637, -20,638,4,10,67, -0,65,0,82,0, -69,0,84,0,1, -35,1,1,2,0, -1,1117,639,18,1, -1117,523,2,0,1, -2035,640,18,1,2035, -110,2,0,1,2034, -641,18,1,2034,642, -20,643,4,22,83, -0,116,0,97,0, -116,0,101,0,67, -0,104,0,97,0, -110,0,103,0,101, -0,1,142,1,2, -2,0,1,1114,644, -18,1,1114,160,2, -0,1,2032,645,18, -1,2032,646,20,647, -4,28,87,0,104, -0,105,0,108,0, -101,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,144,1,2,2, -0,1,2031,648,18, -1,2031,649,20,650, -4,32,68,0,111, -0,87,0,104,0, -105,0,108,0,101, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,1, -145,1,2,2,0, -1,2030,651,18,1, -2030,652,20,653,4, -14,70,0,111,0, -114,0,76,0,111, -0,111,0,112,0, -1,146,1,2,2, -0,1,2029,654,18, -1,2029,201,2,0, -1,2028,655,18,1, -2028,160,2,0,1, -2027,656,18,1,2027, -657,20,658,4,4, -65,0,84,0,1, -23,1,1,2,0, -1,188,659,18,1, -188,129,2,0,1, -2025,660,18,1,2025, -661,20,662,4,8, -74,0,85,0,77, -0,80,0,1,49, -1,1,2,0,1, -2024,663,18,1,2024, -160,2,0,1,2023, -664,18,1,2023,153, -2,0,1,2022,665, -18,1,2022,425,2, -0,1,2021,666,18, -1,2021,122,2,0, -1,182,667,18,1, -182,460,2,0,1, -1096,668,18,1,1096, -138,2,0,1,1094, -669,18,1,1094,132, -2,0,1,172,670, -18,1,172,129,2, -0,1,166,671,18, -1,166,536,2,0, -1,157,672,18,1, -157,129,2,0,1, -1990,673,18,1,1990, -593,2,0,1,1989, -674,18,1,1989,122, -2,0,1,2504,675, -18,1,2504,676,20, -677,4,22,69,0, -77,0,65,0,73, -0,76,0,95,0, -69,0,86,0,69, -0,78,0,84,0, -1,67,1,1,2, -0,1,143,678,18, -1,143,129,2,0, -1,137,679,18,1, -137,680,20,681,4, -36,69,0,88,0, -67,0,76,0,65, -0,77,0,65,0, -84,0,73,0,79, -0,78,0,95,0, -69,0,81,0,85, -0,65,0,76,0, -83,0,1,30,1, -1,2,0,1,130, -682,18,1,130,129, -2,0,1,1048,683, -18,1,1048,129,2, -0,1,124,684,18, -1,124,685,20,686, -4,22,76,0,69, -0,83,0,83,0, -95,0,69,0,81, -0,85,0,65,0, -76,0,83,0,1, -31,1,1,2,0, -1,2540,687,18,1, -2540,236,2,0,1, -1958,688,18,1,1958, -138,2,0,1,118, -689,18,1,118,129, -2,0,1,112,690, -18,1,112,691,20, -692,4,28,71,0, -82,0,69,0,65, -0,84,0,69,0, -82,0,95,0,69, -0,81,0,85,0, -65,0,76,0,83, -0,1,32,1,1, -2,0,1,107,693, -18,1,107,129,2, -0,1,102,694,18, -1,102,695,20,696, -4,22,69,0,88, -0,67,0,76,0, -65,0,77,0,65, -0,84,0,73,0, -79,0,78,0,1, -37,1,1,2,0, -1,1882,697,18,1, -1882,129,2,0,1, -2026,698,18,1,2026, -160,2,0,1,2551, -699,18,1,2551,201, -2,0,1,2655,700, -18,1,2655,181,2, -0,1,97,701,18, -1,97,702,20,703, -4,14,65,0,77, -0,80,0,95,0, -65,0,77,0,80, -0,1,38,1,1, -2,0,1,1933,704, -18,1,1933,116,2, -0,1,1013,705,18, -1,1013,138,2,0, -1,93,706,18,1, -93,129,2,0,1, -1011,707,18,1,1011, -138,2,0,1,1010, -708,18,1,1010,107, -2,0,1,89,709, -18,1,89,568,2, -0,1,2845,104,1, -2844,710,18,1,2844, -520,2,0,1,2843, -711,18,1,2843,712, -20,713,4,48,71, -0,108,0,111,0, -98,0,97,0,108, -0,70,0,117,0, -110,0,99,0,116, -0,105,0,111,0, -110,0,68,0,101, -0,102,0,105,0, -110,0,105,0,116, -0,105,0,111,0, -110,0,1,100,1, -2,2,0,1,85, -714,18,1,85,715, -20,716,4,26,83, -0,84,0,82,0, -79,0,75,0,69, -0,95,0,83,0, -84,0,82,0,79, -0,75,0,69,0, -1,39,1,1,2, -0,1,2841,717,18, -1,2841,712,2,0, -1,1002,718,18,1, -1002,539,2,0,1, -82,719,18,1,82, -129,2,0,1,79, -720,18,1,79,721, -20,722,4,10,84, -0,73,0,76,0, -68,0,69,0,1, -36,1,1,2,0, -1,1859,723,18,1, -1859,138,2,0,1, -2834,724,18,1,2834, -583,2,0,1,76, -725,18,1,76,726, -20,727,4,20,76, -0,69,0,70,0, -84,0,95,0,83, -0,72,0,73,0, -70,0,84,0,1, -40,1,1,2,0, -1,2474,728,18,1, -2474,729,20,730,4, -52,76,0,65,0, -78,0,68,0,95, -0,67,0,79,0, -76,0,76,0,73, -0,83,0,73,0, -79,0,78,0,95, -0,83,0,84,0, -65,0,82,0,84, -0,95,0,69,0, -86,0,69,0,78, -0,84,0,1,71, -1,1,2,0,1, -74,731,18,1,74, -138,2,0,1,73, -732,18,1,73,129, -2,0,1,2578,733, -18,1,2578,138,2, -0,1,71,734,18, -1,71,116,2,0, -1,70,735,18,1, -70,545,2,0,1, -69,736,18,1,69, -551,2,0,1,68, -737,18,1,68,545, -2,0,1,67,738, -18,1,67,551,2, -0,1,66,739,18, -1,66,160,2,0, -1,65,740,18,1, -65,434,2,0,1, -63,741,18,1,63, -160,2,0,1,62, -742,18,1,62,138, -2,0,1,61,743, -18,1,61,744,20, -745,4,16,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,1, -124,1,2,2,0, -1,2811,746,18,1, -2811,110,2,0,1, -52,747,18,1,52, -116,2,0,1,51, -748,18,1,51,545, -2,0,1,50,749, -18,1,50,551,2, -0,1,49,750,18, -1,49,545,2,0, -1,48,751,18,1, -48,551,2,0,1, -47,752,18,1,47, -160,2,0,1,46, -753,18,1,46,434, -2,0,1,44,754, -18,1,44,160,2, -0,1,43,755,18, -1,43,756,20,757, -4,22,82,0,73, -0,71,0,72,0, -84,0,95,0,83, -0,72,0,73,0, -70,0,84,0,1, -41,1,1,2,0, -1,42,758,18,1, -42,129,2,0,1, -41,759,18,1,41, -116,2,0,1,40, -760,18,1,40,160, -2,0,1,2510,761, -18,1,2510,224,2, -0,1,1876,762,18, -1,1876,116,2,0, -1,1875,763,18,1, -1875,119,2,0,1, -1873,764,18,1,1873, -110,2,0,1,1872, -765,18,1,1872,138, -2,0,1,1871,766, -18,1,1871,107,2, -0,1,32,767,18, -1,32,150,2,0, -1,31,768,18,1, -31,138,2,0,1, -30,769,18,1,30, -274,2,0,1,2786, -770,18,1,2786,271, -2,0,1,2785,771, -18,1,2785,274,2, -0,1,2783,772,18, -1,2783,201,2,0, -1,2781,773,18,1, -2781,138,2,0,1, -942,774,18,1,942, -129,2,0,1,1860, -775,18,1,1860,110, -2,0,1,21,776, -18,1,21,147,2, -0,1,20,777,18, -1,20,205,2,0, -1,19,778,18,1, -19,160,2,0,1, -18,779,18,1,18, -744,2,0,1,2770, -780,18,1,2770,116, -2,0,1,2769,781, -18,1,2769,160,2, -0,1,2768,782,18, -1,2768,193,2,0, -1,10,783,18,1, -10,116,2,0,1, -9,784,18,1,9, -160,2,0,1,8, -785,18,1,8,744, -2,0,1,7,786, -18,1,7,309,2, -0,1,6,787,18, -1,6,788,20,789, -4,20,70,0,76, -0,79,0,65,0, -84,0,95,0,84, -0,89,0,80,0, -69,0,1,52,1, -1,2,0,1,5, -790,18,1,5,791, -20,792,4,22,83, -0,84,0,82,0, -73,0,78,0,71, -0,95,0,84,0, -89,0,80,0,69, -0,1,53,1,1, -2,0,1,4,793, -18,1,4,315,2, -0,1,3,794,18, -1,3,291,2,0, -1,2,795,18,1, -2,268,2,0,1, -1,796,18,1,1, -797,20,798,4,18, -76,0,73,0,83, -0,84,0,95,0, -84,0,89,0,80, -0,69,0,1,57, -1,1,2,0,1, -0,799,18,1,0, -0,2,0,800,5, -0,801,5,381,1, -383,802,19,803,4, -50,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,95,0,53, -0,1,383,804,5, -3,1,2582,805,16, -0,204,1,2770,806, -16,0,482,1,10, -807,16,0,777,1, -382,808,19,809,4, -50,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,95,0,52, -0,1,382,804,1, -381,810,19,811,4, -28,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -95,0,52,0,1, -381,812,5,2,1, -41,813,16,0,669, -1,459,814,16,0, -131,1,380,815,19, -816,4,28,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,76, -0,105,0,115,0, -116,0,95,0,51, -0,1,380,812,1, -379,817,19,818,4, -50,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,95,0,51, -0,1,379,804,1, -378,819,19,820,4, -38,75,0,101,0, -121,0,73,0,110, -0,116,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,49,0,1, -378,821,5,4,1, -2659,822,16,0,318, -1,2470,823,16,0, -318,1,2703,824,16, -0,318,1,2597,825, -16,0,318,1,377, -826,19,827,4,38, -73,0,110,0,116, -0,86,0,101,0, -99,0,86,0,101, -0,99,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,377, -828,5,4,1,2659, -829,16,0,296,1, -2470,830,16,0,296, -1,2703,831,16,0, -296,1,2597,832,16, -0,296,1,376,833, -19,834,4,38,73, -0,110,0,116,0, -82,0,111,0,116, -0,82,0,111,0, -116,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -49,0,1,376,835, -5,4,1,2659,836, -16,0,278,1,2470, -837,16,0,278,1, -2703,838,16,0,278, -1,2597,839,16,0, -278,1,375,840,19, -841,4,32,86,0, -101,0,99,0,116, -0,111,0,114,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,51,0, -1,375,842,5,4, -1,2659,843,16,0, -469,1,2470,844,16, -0,469,1,2703,845, -16,0,469,1,2597, -846,16,0,469,1, -374,847,19,848,4, -32,86,0,101,0, -99,0,116,0,111, -0,114,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,50,0,1,374, -842,1,373,849,19, -850,4,32,86,0, -101,0,99,0,116, -0,111,0,114,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,49,0, -1,373,842,1,372, -851,19,852,4,28, -73,0,110,0,116, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,49, -0,48,0,1,372, -853,5,4,1,2659, -854,16,0,239,1, -2470,855,16,0,239, -1,2703,856,16,0, -239,1,2597,857,16, -0,239,1,371,858, -19,859,4,26,73, -0,110,0,116,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,57,0, -1,371,853,1,370, -860,19,861,4,26, -73,0,110,0,116, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,56, -0,1,370,853,1, -369,862,19,863,4, -26,73,0,110,0, -116,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -55,0,1,369,853, -1,368,864,19,865, -4,26,73,0,110, -0,116,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,54,0,1,368, -853,1,367,866,19, -867,4,26,73,0, -110,0,116,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,53,0,1, -367,853,1,366,868, -19,869,4,26,73, -0,110,0,116,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,52,0, -1,366,853,1,365, -870,19,871,4,26, -73,0,110,0,116, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,51, -0,1,365,853,1, -364,872,19,873,4, -26,73,0,110,0, -116,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -50,0,1,364,853, -1,363,874,19,875, -4,26,73,0,110, -0,116,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,363, -853,1,362,876,19, -877,4,26,75,0, -101,0,121,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,50,0,1, -362,878,5,4,1, -2659,879,16,0,227, -1,2470,880,16,0, -227,1,2703,881,16, -0,227,1,2597,882, -16,0,227,1,361, -883,19,884,4,26, -75,0,101,0,121, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,49, -0,1,361,878,1, -360,885,19,886,4, -28,86,0,111,0, -105,0,100,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,56,0,1, -360,887,5,4,1, -2659,888,16,0,443, -1,2470,889,16,0, -443,1,2703,890,16, -0,443,1,2597,891, -16,0,443,1,359, -892,19,893,4,28, -86,0,111,0,105, -0,100,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,55,0,1,359, -887,1,358,894,19, -895,4,28,86,0, -111,0,105,0,100, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,54, -0,1,358,887,1, -357,896,19,897,4, -28,86,0,111,0, -105,0,100,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,53,0,1, -357,887,1,356,898, -19,899,4,28,86, -0,111,0,105,0, -100,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -52,0,1,356,887, -1,355,900,19,901, -4,28,86,0,111, -0,105,0,100,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,51,0, -1,355,887,1,354, -902,19,903,4,28, -86,0,111,0,105, -0,100,0,65,0, -114,0,103,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,50,0,1,354, -887,1,353,904,19, -905,4,28,86,0, -111,0,105,0,100, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,95,0,49, -0,1,353,887,1, -352,906,19,907,4, -14,69,0,118,0, -101,0,110,0,116, -0,95,0,57,0, -1,352,908,5,4, -1,2659,909,16,0, -209,1,2470,910,16, -0,209,1,2703,911, -16,0,209,1,2597, -912,16,0,209,1, -351,913,19,914,4, -14,69,0,118,0, -101,0,110,0,116, -0,95,0,56,0, -1,351,908,1,350, -915,19,916,4,14, -69,0,118,0,101, -0,110,0,116,0, -95,0,55,0,1, -350,908,1,349,917, -19,918,4,14,69, -0,118,0,101,0, -110,0,116,0,95, -0,54,0,1,349, -908,1,348,919,19, -920,4,14,69,0, -118,0,101,0,110, -0,116,0,95,0, -53,0,1,348,908, -1,347,921,19,922, -4,14,69,0,118, -0,101,0,110,0, -116,0,95,0,52, -0,1,347,908,1, -346,923,19,924,4, -14,69,0,118,0, -101,0,110,0,116, -0,95,0,51,0, -1,346,908,1,345, -925,19,926,4,14, -69,0,118,0,101, -0,110,0,116,0, -95,0,50,0,1, -345,908,1,344,927, -19,928,4,14,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,344, -908,1,343,929,19, -930,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,55,0,1,343, -931,5,18,1,1775, -932,16,0,779,1, -2106,933,16,0,779, -1,32,934,16,0, -779,1,1990,935,16, -0,779,1,1804,936, -16,0,779,1,2582, -937,16,0,779,1, -21,938,16,0,779, -1,2198,939,16,0, -779,1,1901,940,16, -0,779,1,10,941, -16,0,779,1,2823, -942,16,0,785,1, -2770,943,16,0,779, -1,1958,944,16,0, -779,1,52,945,16, -0,743,1,2337,946, -16,0,779,1,2075, -947,16,0,779,1, -2413,948,16,0,779, -1,0,949,16,0, -785,1,342,950,19, -951,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,54,0,1,342, -931,1,341,952,19, -953,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,53,0,1,341, -931,1,340,954,19, -955,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,52,0,1,340, -931,1,339,956,19, -957,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,51,0,1,339, -931,1,338,958,19, -959,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,50,0,1,338, -931,1,337,960,19, -961,4,20,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,95, -0,49,0,1,337, -931,1,336,962,19, -963,4,40,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,95, -0,49,0,1,336, -964,5,3,1,41, -965,16,0,483,1, -459,966,16,0,483, -1,462,967,16,0, -502,1,335,968,19, -969,4,28,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,76, -0,105,0,115,0, -116,0,95,0,50, -0,1,335,812,1, -334,970,19,971,4, -28,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -95,0,49,0,1, -334,812,1,333,972, -19,973,4,28,70, -0,117,0,110,0, -99,0,116,0,105, -0,111,0,110,0, -67,0,97,0,108, -0,108,0,95,0, -49,0,1,333,974, -5,68,1,1371,975, -16,0,553,1,1958, -976,16,0,553,1, -381,977,16,0,553, -1,217,978,16,0, -553,1,1756,979,16, -0,553,1,509,980, -16,0,553,1,2337, -981,16,0,553,1, -1153,982,16,0,553, -1,166,983,16,0, -553,1,1933,984,16, -0,553,1,2198,985, -16,0,553,1,1731, -986,16,0,553,1, -1335,987,16,0,553, -1,2318,988,16,0, -553,1,346,989,16, -0,553,1,182,990, -16,0,553,1,137, -991,16,0,553,1, -2106,992,16,0,553, -1,1775,993,16,0, -553,1,1117,994,16, -0,553,1,525,995, -16,0,553,1,1901, -996,16,0,553,1, -2293,997,16,0,553, -1,322,998,16,0, -553,1,124,999,16, -0,553,1,1695,1000, -16,0,553,1,299, -1001,16,0,553,1, -1297,1002,16,0,553, -1,151,1003,16,0, -553,1,112,1004,16, -0,553,1,2075,1005, -16,0,553,1,1876, -1006,16,0,553,1, -102,1007,16,0,553, -1,1479,1008,16,0, -553,1,97,1009,16, -0,553,1,1225,1010, -16,0,553,1,89, -1011,16,0,553,1, -85,1012,16,0,553, -1,1659,1013,16,0, -553,1,277,1014,16, -0,553,1,1261,1015, -16,0,553,1,76, -1016,16,0,553,1, -1515,1017,16,0,553, -1,71,1018,16,0, -553,1,462,1019,16, -0,553,1,459,1020, -16,0,553,1,1443, -1021,16,0,553,1, -62,1022,16,0,627, -1,1834,1023,16,0, -553,1,256,1024,16, -0,553,1,447,1025, -16,0,553,1,52, -1026,16,0,553,1, -2413,1027,16,0,553, -1,1622,1028,16,0, -553,1,43,1029,16, -0,553,1,41,1030, -16,0,553,1,236, -1031,16,0,553,1, -431,1032,16,0,553, -1,32,1033,16,0, -553,1,1804,1034,16, -0,553,1,1407,1035, -16,0,553,1,79, -1036,16,0,553,1, -1990,1037,16,0,553, -1,2786,1038,16,0, -553,1,406,1039,16, -0,553,1,1585,1040, -16,0,553,1,1189, -1041,16,0,553,1, -199,1042,16,0,553, -1,332,1043,19,1044, -4,40,84,0,121, -0,112,0,101,0, -99,0,97,0,115, -0,116,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -57,0,1,332,1045, -5,67,1,1371,1046, -16,0,508,1,1958, -1047,16,0,412,1, -381,1048,16,0,533, -1,217,1049,16,0, -615,1,1756,1050,16, -0,207,1,509,1051, -16,0,466,1,2337, -1052,16,0,412,1, -1153,1053,16,0,605, -1,166,1054,16,0, -670,1,1933,1055,16, -0,255,1,2198,1056, -16,0,412,1,1731, -1057,16,0,158,1, -1335,1058,16,0,518, -1,2318,1059,16,0, -207,1,346,1060,16, -0,559,1,182,1061, -16,0,659,1,137, -1062,16,0,678,1, -2106,1063,16,0,412, -1,1775,1064,16,0, -412,1,1117,1065,16, -0,254,1,525,1066, -16,0,659,1,1901, -1067,16,0,412,1, -2293,1068,16,0,504, -1,322,1069,16,0, -566,1,124,1070,16, -0,682,1,1695,1071, -16,0,196,1,299, -1072,16,0,575,1, -1297,1073,16,0,534, -1,151,1074,16,0, -672,1,112,1075,16, -0,689,1,2075,1076, -16,0,412,1,1876, -1077,16,0,697,1, -102,1078,16,0,693, -1,1479,1079,16,0, -450,1,97,1080,16, -0,145,1,1225,1081, -16,0,573,1,89, -1082,16,0,706,1, -85,1083,16,0,128, -1,1659,1084,16,0, -207,1,277,1085,16, -0,585,1,1261,1086, -16,0,560,1,76, -1087,16,0,774,1, -1515,1088,16,0,440, -1,71,1089,16,0, -732,1,462,1090,16, -0,758,1,459,1091, -16,0,758,1,1443, -1092,16,0,457,1, -1834,1093,16,0,530, -1,256,1094,16,0, -597,1,447,1095,16, -0,659,1,52,1096, -16,0,529,1,2413, -1097,16,0,412,1, -1622,1098,16,0,261, -1,43,1099,16,0, -683,1,41,1100,16, -0,758,1,236,1101, -16,0,604,1,431, -1102,16,0,516,1, -32,1103,16,0,412, -1,1804,1104,16,0, -412,1,1407,1105,16, -0,477,1,79,1106, -16,0,719,1,1990, -1107,16,0,412,1, -2786,1108,16,0,556, -1,406,1109,16,0, -527,1,1585,1110,16, -0,312,1,1189,1111, -16,0,589,1,199, -1112,16,0,626,1, -331,1113,19,1114,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,56, -0,1,331,1045,1, -330,1115,19,1116,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,55, -0,1,330,1045,1, -329,1117,19,1118,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,54, -0,1,329,1045,1, -328,1119,19,1120,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,53, -0,1,328,1045,1, -327,1121,19,1122,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,52, -0,1,327,1045,1, -326,1123,19,1124,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,51, -0,1,326,1045,1, -325,1125,19,1126,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,50, -0,1,325,1045,1, -324,1127,19,1128,4, -40,84,0,121,0, -112,0,101,0,99, -0,97,0,115,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,49, -0,1,324,1045,1, -323,1129,19,1130,4, -46,80,0,97,0, -114,0,101,0,110, -0,116,0,104,0, -101,0,115,0,105, -0,115,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -50,0,1,323,1045, -1,322,1131,19,1132, -4,46,80,0,97, -0,114,0,101,0, -110,0,116,0,104, -0,101,0,115,0, -105,0,115,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,49,0,1,322, -1045,1,321,1133,19, -1134,4,34,85,0, -110,0,97,0,114, -0,121,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -51,0,1,321,1045, -1,320,1135,19,1136, -4,34,85,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,50, -0,1,320,1045,1, -319,1137,19,1138,4, -34,85,0,110,0, -97,0,114,0,121, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,95,0,49,0, -1,319,1045,1,318, -1139,19,1140,4,38, -66,0,105,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,49, -0,56,0,1,318, -1045,1,317,1141,19, -1142,4,38,66,0, -105,0,110,0,97, -0,114,0,121,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,49,0,55, -0,1,317,1045,1, -316,1143,19,1144,4, -38,66,0,105,0, -110,0,97,0,114, -0,121,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -49,0,54,0,1, -316,1045,1,315,1145, -19,1146,4,38,66, -0,105,0,110,0, -97,0,114,0,121, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,95,0,49,0, -53,0,1,315,1045, -1,314,1147,19,1148, -4,38,66,0,105, -0,110,0,97,0, -114,0,121,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,49,0,52,0, -1,314,1045,1,313, -1149,19,1150,4,38, -66,0,105,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,49, -0,51,0,1,313, -1045,1,312,1151,19, -1152,4,38,66,0, -105,0,110,0,97, -0,114,0,121,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,49,0,50, -0,1,312,1045,1, -311,1153,19,1154,4, -38,66,0,105,0, -110,0,97,0,114, -0,121,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -49,0,49,0,1, -311,1045,1,310,1155, -19,1156,4,38,66, -0,105,0,110,0, -97,0,114,0,121, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,95,0,49,0, -48,0,1,310,1045, -1,309,1157,19,1158, -4,36,66,0,105, -0,110,0,97,0, -114,0,121,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,57,0,1,309, -1045,1,308,1159,19, -1160,4,36,66,0, -105,0,110,0,97, -0,114,0,121,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,56,0,1, -308,1045,1,307,1161, -19,1162,4,36,66, -0,105,0,110,0, -97,0,114,0,121, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,95,0,55,0, -1,307,1045,1,306, -1163,19,1164,4,36, -66,0,105,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,54, -0,1,306,1045,1, -305,1165,19,1166,4, -36,66,0,105,0, -110,0,97,0,114, -0,121,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,95,0, -53,0,1,305,1045, -1,304,1167,19,1168, -4,36,66,0,105, -0,110,0,97,0, -114,0,121,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,52,0,1,304, -1045,1,303,1169,19, -1170,4,36,66,0, -105,0,110,0,97, -0,114,0,121,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,51,0,1, -303,1045,1,302,1171, -19,1172,4,36,66, -0,105,0,110,0, -97,0,114,0,121, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,95,0,50,0, -1,302,1045,1,301, -1173,19,1174,4,36, -66,0,105,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,95,0,49, -0,1,301,1045,1, -300,1175,19,1176,4, -48,70,0,117,0, -110,0,99,0,116, -0,105,0,111,0, -110,0,67,0,97, -0,108,0,108,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,49,0,1, -300,1045,1,299,1177, -19,1178,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,56,0,1, -299,1045,1,298,1179, -19,1180,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,55,0,1, -298,1045,1,297,1181, -19,1182,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,54,0,1, -297,1045,1,296,1183, -19,1184,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,53,0,1, -296,1045,1,295,1185, -19,1186,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,52,0,1, -295,1045,1,294,1187, -19,1188,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,51,0,1, -294,1045,1,293,1189, -19,1190,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,50,0,1, -293,1045,1,292,1191, -19,1192,4,60,73, -0,110,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,114,0, -101,0,109,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,49,0,1, -292,1045,1,291,1193, -19,1194,4,40,73, -0,100,0,101,0, -110,0,116,0,68, -0,111,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -95,0,49,0,1, -291,1045,1,290,1195, -19,1196,4,34,73, -0,100,0,101,0, -110,0,116,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,49,0,1,290, -1045,1,289,1197,19, -1198,4,40,67,0, -111,0,110,0,115, -0,116,0,97,0, -110,0,116,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,95, -0,49,0,1,289, -1045,1,288,1199,19, -1200,4,36,82,0, -111,0,116,0,97, -0,116,0,105,0, -111,0,110,0,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,49,0,1, -288,1201,5,68,1, -1371,1202,16,0,538, -1,1958,1203,16,0, -538,1,381,1204,16, -0,538,1,217,1205, -16,0,538,1,1756, -1206,16,0,538,1, -509,1207,16,0,538, -1,2337,1208,16,0, -538,1,1153,1209,16, -0,538,1,166,1210, -16,0,538,1,1933, -1211,16,0,538,1, -2198,1212,16,0,538, -1,1731,1213,16,0, -538,1,1335,1214,16, -0,538,1,2318,1215, -16,0,538,1,346, -1216,16,0,538,1, -182,1217,16,0,538, -1,137,1218,16,0, -538,1,2106,1219,16, -0,538,1,1775,1220, -16,0,538,1,1117, -1221,16,0,538,1, -525,1222,16,0,538, -1,1901,1223,16,0, -538,1,2293,1224,16, -0,538,1,322,1225, -16,0,538,1,124, -1226,16,0,538,1, -1695,1227,16,0,538, -1,299,1228,16,0, -538,1,1297,1229,16, -0,538,1,151,1230, -16,0,538,1,112, -1231,16,0,538,1, -2075,1232,16,0,538, -1,1876,1233,16,0, -538,1,102,1234,16, -0,538,1,1479,1235, -16,0,538,1,97, -1236,16,0,538,1, -1225,1237,16,0,538, -1,89,1238,16,0, -538,1,85,1239,16, -0,538,1,1659,1240, -16,0,538,1,277, -1241,16,0,538,1, -1261,1242,16,0,538, -1,76,1243,16,0, -538,1,1515,1244,16, -0,538,1,71,1245, -16,0,538,1,462, -1246,16,0,538,1, -459,1247,16,0,538, -1,1443,1248,16,0, -538,1,62,1249,16, -0,718,1,1834,1250, -16,0,538,1,256, -1251,16,0,538,1, -447,1252,16,0,538, -1,52,1253,16,0, -538,1,2413,1254,16, -0,538,1,1622,1255, -16,0,538,1,43, -1256,16,0,538,1, -41,1257,16,0,538, -1,236,1258,16,0, -538,1,431,1259,16, -0,538,1,32,1260, -16,0,538,1,1804, -1261,16,0,538,1, -1407,1262,16,0,538, -1,79,1263,16,0, -538,1,1990,1264,16, -0,538,1,2786,1265, -16,0,538,1,406, -1266,16,0,538,1, -1585,1267,16,0,538, -1,1189,1268,16,0, -538,1,199,1269,16, -0,538,1,287,1270, -19,1271,4,32,86, -0,101,0,99,0, -116,0,111,0,114, -0,67,0,111,0, -110,0,115,0,116, -0,97,0,110,0, -116,0,95,0,49, -0,1,287,1201,1, -286,1272,19,1273,4, -28,76,0,105,0, -115,0,116,0,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,49,0,1, -286,1201,1,285,1274, -19,1275,4,20,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,52,0,1, -285,1201,1,284,1276, -19,1277,4,20,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,51,0,1, -284,1201,1,283,1278, -19,1279,4,20,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,50,0,1, -283,1201,1,282,1280, -19,1281,4,20,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -95,0,49,0,1, -282,1201,1,281,1282, -19,1283,4,34,82, -0,101,0,116,0, -117,0,114,0,110, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,50,0,1,281, -1284,5,11,1,2413, -1285,16,0,629,1, -2106,1286,16,0,629, -1,1901,1287,16,0, -629,1,1990,1288,16, -0,629,1,2337,1289, -16,0,629,1,1775, -1290,16,0,629,1, -2198,1291,16,0,629, -1,1958,1292,16,0, -629,1,1804,1293,16, -0,629,1,2075,1294, -16,0,629,1,32, -1295,16,0,629,1, -280,1296,19,1297,4, -34,82,0,101,0, -116,0,117,0,114, -0,110,0,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -1,280,1284,1,279, -1298,19,1299,4,38, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,52,0,1,279, -1300,5,31,1,1153, -1301,16,0,591,1, -1775,1302,16,0,276, -1,1407,1303,16,0, -465,1,1225,1304,16, -0,565,1,1756,1305, -16,0,515,1,1933, -1306,16,0,446,1, -2198,1307,16,0,276, -1,2106,1308,16,0, -276,1,1659,1309,16, -0,515,1,1479,1310, -16,0,442,1,1834, -1311,16,0,766,1, -52,1312,16,0,708, -1,1297,1313,16,0, -526,1,1117,1314,16, -0,614,1,1958,1315, -16,0,276,1,1695, -1316,16,0,175,1, -1371,1317,16,0,481, -1,1189,1318,16,0, -106,1,1990,1319,16, -0,276,1,2075,1320, -16,0,276,1,1804, -1321,16,0,276,1, -2337,1322,16,0,276, -1,1443,1323,16,0, -454,1,1901,1324,16, -0,276,1,1261,1325, -16,0,543,1,2413, -1326,16,0,276,1, -32,1327,16,0,276, -1,1876,1328,16,0, -558,1,2318,1329,16, -0,515,1,1515,1330, -16,0,596,1,1335, -1331,16,0,513,1, -278,1332,19,1333,4, -38,83,0,105,0, -109,0,112,0,108, -0,101,0,65,0, -115,0,115,0,105, -0,103,0,110,0, -109,0,101,0,110, -0,116,0,95,0, -50,0,51,0,1, -278,1300,1,277,1334, -19,1335,4,38,83, -0,105,0,109,0, -112,0,108,0,101, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,95,0,50,0, -50,0,1,277,1300, -1,276,1336,19,1337, -4,38,83,0,105, -0,109,0,112,0, -108,0,101,0,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,95, -0,50,0,49,0, -1,276,1300,1,275, -1338,19,1339,4,38, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,48,0,1,275, -1300,1,274,1340,19, -1341,4,38,83,0, -105,0,109,0,112, -0,108,0,101,0, -65,0,115,0,115, -0,105,0,103,0, -110,0,109,0,101, -0,110,0,116,0, -95,0,49,0,57, -0,1,274,1300,1, -273,1342,19,1343,4, -38,83,0,105,0, -109,0,112,0,108, -0,101,0,65,0, -115,0,115,0,105, -0,103,0,110,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,56,0,1, -273,1300,1,272,1344, -19,1345,4,38,83, -0,105,0,109,0, -112,0,108,0,101, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -55,0,1,272,1300, -1,271,1346,19,1347, -4,38,83,0,105, -0,109,0,112,0, -108,0,101,0,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,95, -0,49,0,54,0, -1,271,1300,1,270, -1348,19,1349,4,38, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,49, -0,53,0,1,270, -1300,1,269,1350,19, -1351,4,38,83,0, -105,0,109,0,112, -0,108,0,101,0, -65,0,115,0,115, -0,105,0,103,0, -110,0,109,0,101, -0,110,0,116,0, -95,0,49,0,52, -0,1,269,1300,1, -268,1352,19,1353,4, -38,83,0,105,0, -109,0,112,0,108, -0,101,0,65,0, -115,0,115,0,105, -0,103,0,110,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,51,0,1, -268,1300,1,267,1354, -19,1355,4,38,83, -0,105,0,109,0, -112,0,108,0,101, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -50,0,1,267,1300, -1,266,1356,19,1357, -4,38,83,0,105, -0,109,0,112,0, -108,0,101,0,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,95, -0,49,0,49,0, -1,266,1300,1,265, -1358,19,1359,4,38, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,49, -0,48,0,1,265, -1300,1,264,1360,19, -1361,4,36,83,0, -105,0,109,0,112, -0,108,0,101,0, -65,0,115,0,115, -0,105,0,103,0, -110,0,109,0,101, -0,110,0,116,0, -95,0,57,0,1, -264,1300,1,263,1362, -19,1363,4,36,83, -0,105,0,109,0, -112,0,108,0,101, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,95,0,56,0, -1,263,1300,1,262, -1364,19,1365,4,36, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,55, -0,1,262,1300,1, -261,1366,19,1367,4, -36,83,0,105,0, -109,0,112,0,108, -0,101,0,65,0, -115,0,115,0,105, -0,103,0,110,0, -109,0,101,0,110, -0,116,0,95,0, -54,0,1,261,1300, -1,260,1368,19,1369, -4,36,83,0,105, -0,109,0,112,0, -108,0,101,0,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,95, -0,53,0,1,260, -1300,1,259,1370,19, -1371,4,36,83,0, -105,0,109,0,112, -0,108,0,101,0, -65,0,115,0,115, -0,105,0,103,0, -110,0,109,0,101, -0,110,0,116,0, -95,0,52,0,1, -259,1300,1,258,1372, -19,1373,4,36,83, -0,105,0,109,0, -112,0,108,0,101, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,95,0,51,0, -1,258,1300,1,257, -1374,19,1375,4,36, -83,0,105,0,109, -0,112,0,108,0, -101,0,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,1,257,1300,1, -256,1376,19,1377,4, -36,83,0,105,0, -109,0,112,0,108, -0,101,0,65,0, -115,0,115,0,105, -0,103,0,110,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,1,256,1300, -1,255,1378,19,1379, -4,24,65,0,115, -0,115,0,105,0, -103,0,110,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,1,255,1380,5, -11,1,2413,1381,16, -0,472,1,2106,1382, -16,0,472,1,1901, -1383,16,0,472,1, -1990,1384,16,0,472, -1,2337,1385,16,0, -472,1,1775,1386,16, -0,472,1,2198,1387, -16,0,472,1,1958, -1388,16,0,472,1, -1804,1389,16,0,472, -1,2075,1390,16,0, -472,1,32,1391,16, -0,472,1,254,1392, -19,1393,4,24,65, -0,115,0,115,0, -105,0,103,0,110, -0,109,0,101,0, -110,0,116,0,95, -0,49,0,1,254, -1380,1,253,1394,19, -1395,4,36,70,0, -111,0,114,0,76, -0,111,0,111,0, -112,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -95,0,52,0,1, -253,1396,5,3,1, -1756,1397,16,0,140, -1,2318,1398,16,0, -476,1,1659,1399,16, -0,198,1,252,1400, -19,1401,4,36,70, -0,111,0,114,0, -76,0,111,0,111, -0,112,0,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,51,0, -1,252,1396,1,251, -1402,19,1403,4,36, -70,0,111,0,114, -0,76,0,111,0, -111,0,112,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,1,251,1396,1, -250,1404,19,1405,4, -36,70,0,111,0, -114,0,76,0,111, -0,111,0,112,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,1,250,1396, -1,249,1406,19,1407, -4,18,70,0,111, -0,114,0,76,0, -111,0,111,0,112, -0,95,0,50,0, -1,249,1408,5,11, -1,2413,1409,16,0, -651,1,2106,1410,16, -0,651,1,1901,1411, -16,0,651,1,1990, -1412,16,0,651,1, -2337,1413,16,0,651, -1,1775,1414,16,0, -651,1,2198,1415,16, -0,651,1,1958,1416, -16,0,651,1,1804, -1417,16,0,651,1, -2075,1418,16,0,651, -1,32,1419,16,0, -651,1,248,1420,19, -1421,4,18,70,0, -111,0,114,0,76, -0,111,0,111,0, -112,0,95,0,49, -0,1,248,1408,1, -247,1422,19,1423,4, -36,68,0,111,0, -87,0,104,0,105, -0,108,0,101,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -50,0,1,247,1424, -5,11,1,2413,1425, -16,0,648,1,2106, -1426,16,0,648,1, -1901,1427,16,0,648, -1,1990,1428,16,0, -648,1,2337,1429,16, -0,648,1,1775,1430, -16,0,648,1,2198, -1431,16,0,648,1, -1958,1432,16,0,648, -1,1804,1433,16,0, -648,1,2075,1434,16, -0,648,1,32,1435, -16,0,648,1,246, -1436,19,1437,4,36, -68,0,111,0,87, -0,104,0,105,0, -108,0,101,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,49, -0,1,246,1424,1, -245,1438,19,1439,4, -32,87,0,104,0, -105,0,108,0,101, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,50,0,1,245, -1440,5,11,1,2413, -1441,16,0,645,1, -2106,1442,16,0,645, -1,1901,1443,16,0, -645,1,1990,1444,16, -0,645,1,2337,1445, -16,0,645,1,1775, -1446,16,0,645,1, -2198,1447,16,0,645, -1,1958,1448,16,0, -645,1,1804,1449,16, -0,645,1,2075,1450, -16,0,645,1,32, -1451,16,0,645,1, -244,1452,19,1453,4, -32,87,0,104,0, -105,0,108,0,101, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,49,0,1,244, -1440,1,243,1454,19, -1455,4,26,73,0, -102,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -95,0,52,0,1, -243,1456,5,11,1, -2413,1457,16,0,165, -1,2106,1458,16,0, -165,1,1901,1459,16, -0,165,1,1990,1460, -16,0,165,1,2337, -1461,16,0,165,1, -1775,1462,16,0,165, -1,2198,1463,16,0, -165,1,1958,1464,16, -0,165,1,1804,1465, -16,0,165,1,2075, -1466,16,0,165,1, -32,1467,16,0,165, -1,242,1468,19,1469, -4,26,73,0,102, -0,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,51,0,1,242, -1456,1,241,1470,19, -1471,4,26,73,0, -102,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -95,0,50,0,1, -241,1456,1,240,1472, -19,1473,4,26,73, -0,102,0,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -1,240,1456,1,239, -1474,19,1475,4,26, -83,0,116,0,97, -0,116,0,101,0, -67,0,104,0,97, -0,110,0,103,0, -101,0,95,0,50, -0,1,239,1476,5, -11,1,2413,1477,16, -0,641,1,2106,1478, -16,0,641,1,1901, -1479,16,0,641,1, -1990,1480,16,0,641, -1,2337,1481,16,0, -641,1,1775,1482,16, -0,641,1,2198,1483, -16,0,641,1,1958, -1484,16,0,641,1, -1804,1485,16,0,641, -1,2075,1486,16,0, -641,1,32,1487,16, -0,641,1,238,1488, -19,1489,4,26,83, -0,116,0,97,0, -116,0,101,0,67, -0,104,0,97,0, -110,0,103,0,101, -0,95,0,49,0, -1,238,1476,1,237, -1490,19,1491,4,30, -74,0,117,0,109, -0,112,0,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -1,237,1492,5,11, -1,2413,1493,16,0, -619,1,2106,1494,16, -0,619,1,1901,1495, -16,0,619,1,1990, -1496,16,0,619,1, -2337,1497,16,0,619, -1,1775,1498,16,0, -619,1,2198,1499,16, -0,619,1,1958,1500, -16,0,619,1,1804, -1501,16,0,619,1, -2075,1502,16,0,619, -1,32,1503,16,0, -619,1,236,1504,19, -1505,4,22,74,0, -117,0,109,0,112, -0,76,0,97,0, -98,0,101,0,108, -0,95,0,49,0, -1,236,1506,5,11, -1,2413,1507,16,0, -633,1,2106,1508,16, -0,633,1,1901,1509, -16,0,633,1,1990, -1510,16,0,633,1, -2337,1511,16,0,633, -1,1775,1512,16,0, -633,1,2198,1513,16, -0,633,1,1958,1514, -16,0,633,1,1804, -1515,16,0,633,1, -2075,1516,16,0,633, -1,32,1517,16,0, -633,1,235,1518,19, -1519,4,24,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -51,0,1,235,1520, -5,11,1,2413,1521, -16,0,432,1,2106, -1522,16,0,581,1, -1901,1523,16,0,143, -1,1990,1524,16,0, -666,1,2337,1525,16, -0,458,1,1775,1526, -16,0,127,1,2198, -1527,16,0,532,1, -1958,1528,16,0,674, -1,1804,1529,16,0, -121,1,2075,1530,16, -0,595,1,32,1531, -16,0,430,1,234, -1532,19,1533,4,24, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,50,0,1, -234,1520,1,233,1534, -19,1535,4,24,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,49, -0,49,0,1,233, -1520,1,232,1536,19, -1537,4,24,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -48,0,1,232,1520, -1,231,1538,19,1539, -4,22,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -95,0,57,0,1, -231,1520,1,230,1540, -19,1541,4,22,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,56, -0,1,230,1520,1, -229,1542,19,1543,4, -22,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,55,0,1,229, -1520,1,228,1544,19, -1545,4,22,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,54,0, -1,228,1520,1,227, -1546,19,1547,4,22, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -53,0,1,227,1520, -1,226,1548,19,1549, -4,22,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -95,0,52,0,1, -226,1520,1,225,1550, -19,1551,4,22,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,51, -0,1,225,1520,1, -224,1552,19,1553,4, -22,83,0,116,0, -97,0,116,0,101, -0,109,0,101,0, -110,0,116,0,95, -0,50,0,1,224, -1520,1,223,1554,19, -1555,4,22,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,95,0,49,0, -1,223,1520,1,222, -1556,19,1557,4,32, -69,0,109,0,112, -0,116,0,121,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,1,222,1558, -5,11,1,2413,1559, -16,0,623,1,2106, -1560,16,0,623,1, -1901,1561,16,0,623, -1,1990,1562,16,0, -623,1,2337,1563,16, -0,623,1,1775,1564, -16,0,623,1,2198, -1565,16,0,623,1, -1958,1566,16,0,623, -1,1804,1567,16,0, -623,1,2075,1568,16, -0,623,1,32,1569, -16,0,623,1,221, -1570,19,1571,4,30, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,76,0, -105,0,115,0,116, -0,95,0,50,0, -1,221,1572,5,1, -1,32,1573,16,0, -447,1,220,1574,19, -1575,4,30,83,0, -116,0,97,0,116, -0,101,0,109,0, -101,0,110,0,116, -0,76,0,105,0, -115,0,116,0,95, -0,49,0,1,220, -1572,1,219,1576,19, -1577,4,38,67,0, -111,0,109,0,112, -0,111,0,117,0, -110,0,100,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,95,0,50, -0,1,219,1578,5, -21,1,1775,1579,16, -0,654,1,2106,1580, -16,0,654,1,2593, -1581,16,0,200,1, -32,1582,16,0,654, -1,31,1583,16,0, -428,1,1990,1584,16, -0,654,1,1804,1585, -16,0,654,1,2578, -1586,16,0,212,1, -2075,1587,16,0,654, -1,2573,1588,16,0, -218,1,1958,1589,16, -0,654,1,2534,1590, -16,0,281,1,2781, -1591,16,0,772,1, -2198,1592,16,0,654, -1,1901,1593,16,0, -654,1,2565,1594,16, -0,230,1,2549,1595, -16,0,699,1,2413, -1596,16,0,654,1, -2337,1597,16,0,654, -1,2557,1598,16,0, -242,1,2519,1599,16, -0,299,1,218,1600, -19,1601,4,38,67, -0,111,0,109,0, -112,0,111,0,117, -0,110,0,100,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,95,0, -49,0,1,218,1578, -1,217,1602,19,1603, -4,32,82,0,111, -0,116,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -95,0,49,0,1, -217,1604,5,2,1, -2545,1605,16,0,525, -1,2541,1606,16,0, -263,1,216,1607,19, -1608,4,32,86,0, -101,0,99,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,95,0,49,0, -1,216,1609,5,3, -1,2526,1610,16,0, -288,1,2553,1611,16, -0,247,1,2530,1612, -16,0,286,1,215, -1613,19,1614,4,32, -73,0,110,0,116, -0,68,0,101,0, -99,0,108,0,97, -0,114,0,97,0, -116,0,105,0,111, -0,110,0,95,0, -49,0,1,215,1615, -5,5,1,2561,1616, -16,0,235,1,2511, -1617,16,0,306,1, -2538,1618,16,0,687, -1,2523,1619,16,0, -294,1,2515,1620,16, -0,304,1,214,1621, -19,1622,4,32,75, -0,101,0,121,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,95,0,49, -0,1,214,1623,5, -2,1,2507,1624,16, -0,761,1,2569,1625, -16,0,223,1,213, -1626,19,1627,4,26, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,95,0,49, -0,1,213,1628,5, -17,1,1775,1629,16, -0,273,1,2106,1630, -16,0,273,1,32, -1631,16,0,273,1, -1990,1632,16,0,273, -1,1804,1633,16,0, -273,1,2582,1634,16, -0,427,1,21,1635, -16,0,769,1,2198, -1636,16,0,273,1, -1901,1637,16,0,273, -1,10,1638,16,0, -427,1,2823,1639,16, -0,771,1,2770,1640, -16,0,427,1,1958, -1641,16,0,273,1, -2337,1642,16,0,273, -1,2075,1643,16,0, -273,1,2413,1644,16, -0,273,1,0,1645, -16,0,771,1,212, -1646,19,1647,4,68, -75,0,101,0,121, -0,73,0,110,0, -116,0,73,0,110, -0,116,0,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,76,0,105,0, -115,0,116,0,95, -0,49,0,1,212, -1648,5,1,1,2507, -1649,16,0,301,1, -211,1650,19,1651,4, -68,73,0,110,0, -116,0,86,0,101, -0,99,0,86,0, -101,0,99,0,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -95,0,49,0,1, -211,1652,5,1,1, -2523,1653,16,0,283, -1,210,1654,19,1655, -4,68,73,0,110, -0,116,0,82,0, -111,0,116,0,82, -0,111,0,116,0, -65,0,114,0,103, -0,117,0,109,0, -101,0,110,0,116, -0,68,0,101,0, -99,0,108,0,97, -0,114,0,97,0, -116,0,105,0,111, -0,110,0,76,0, -105,0,115,0,116, -0,95,0,49,0, -1,210,1656,5,1, -1,2538,1657,16,0, -258,1,209,1658,19, -1659,4,62,86,0, -101,0,99,0,116, -0,111,0,114,0, -65,0,114,0,103, -0,117,0,109,0, -101,0,110,0,116, -0,68,0,101,0, -99,0,108,0,97, -0,114,0,97,0, -116,0,105,0,111, -0,110,0,76,0, -105,0,115,0,116, -0,95,0,49,0, -1,209,1660,5,1, -1,2553,1661,16,0, -244,1,208,1662,19, -1663,4,56,73,0, -110,0,116,0,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -95,0,49,0,1, -208,1664,5,1,1, -2561,1665,16,0,232, -1,207,1666,19,1667, -4,56,75,0,101, -0,121,0,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,76,0,105,0, -115,0,116,0,95, -0,49,0,1,207, -1668,5,1,1,2569, -1669,16,0,220,1, -206,1670,19,1671,4, -50,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,95,0,50, -0,1,206,804,1, -205,1672,19,1673,4, -50,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,95,0,49, -0,1,205,804,1, -204,1674,19,1675,4, -48,75,0,101,0, -121,0,73,0,110, -0,116,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,49,0,1, -204,1676,5,4,1, -2659,1677,16,0,467, -1,2470,1678,16,0, -467,1,2703,1679,16, -0,189,1,2597,1680, -16,0,189,1,203, -1681,19,1682,4,48, -73,0,110,0,116, -0,86,0,101,0, -99,0,86,0,101, -0,99,0,65,0, -114,0,103,0,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,203, -1683,5,4,1,2659, -1684,16,0,171,1, -2470,1685,16,0,171, -1,2703,1686,16,0, -188,1,2597,1687,16, -0,188,1,202,1688, -19,1689,4,48,73, -0,110,0,116,0, -82,0,111,0,116, -0,82,0,111,0, -116,0,65,0,114, -0,103,0,83,0, -116,0,97,0,116, -0,101,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -49,0,1,202,1690, -5,4,1,2659,1691, -16,0,168,1,2470, -1692,16,0,168,1, -2703,1693,16,0,187, -1,2597,1694,16,0, -187,1,201,1695,19, -1696,4,42,86,0, -101,0,99,0,116, -0,111,0,114,0, -65,0,114,0,103, -0,83,0,116,0, -97,0,116,0,101, -0,69,0,118,0, -101,0,110,0,116, -0,95,0,49,0, -1,201,1697,5,4, -1,2659,1698,16,0, -256,1,2470,1699,16, -0,256,1,2703,1700, -16,0,184,1,2597, -1701,16,0,184,1, -200,1702,19,1703,4, -36,73,0,110,0, -116,0,65,0,114, -0,103,0,83,0, -116,0,97,0,116, -0,101,0,69,0, -118,0,101,0,110, -0,116,0,95,0, -49,0,1,200,1704, -5,4,1,2659,1705, -16,0,162,1,2470, -1706,16,0,162,1, -2703,1707,16,0,183, -1,2597,1708,16,0, -183,1,199,1709,19, -1710,4,36,75,0, -101,0,121,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -95,0,49,0,1, -199,1711,5,4,1, -2659,1712,16,0,700, -1,2470,1713,16,0, -700,1,2703,1714,16, -0,180,1,2597,1715, -16,0,180,1,198, -1716,19,1717,4,38, -86,0,111,0,105, -0,100,0,65,0, -114,0,103,0,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,198, -1718,5,4,1,2659, -1719,16,0,577,1, -2470,1720,16,0,577, -1,2703,1721,16,0, -177,1,2597,1722,16, -0,177,1,197,1723, -19,1724,4,24,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,95, -0,49,0,1,197, -1725,5,4,1,2659, -1726,16,0,155,1, -2470,1727,16,0,155, -1,2703,1728,16,0, -176,1,2597,1729,16, -0,176,1,196,1730, -19,1731,4,24,83, -0,116,0,97,0, -116,0,101,0,66, -0,111,0,100,0, -121,0,95,0,49, -0,54,0,1,196, -1732,5,2,1,2470, -1733,16,0,199,1, -2659,1734,16,0,134, -1,195,1735,19,1736, -4,24,83,0,116, -0,97,0,116,0, -101,0,66,0,111, -0,100,0,121,0, -95,0,49,0,53, -0,1,195,1732,1, -194,1737,19,1738,4, -24,83,0,116,0, -97,0,116,0,101, -0,66,0,111,0, -100,0,121,0,95, -0,49,0,52,0, -1,194,1732,1,193, -1739,19,1740,4,24, -83,0,116,0,97, -0,116,0,101,0, -66,0,111,0,100, -0,121,0,95,0, -49,0,51,0,1, -193,1732,1,192,1741, -19,1742,4,24,83, -0,116,0,97,0, -116,0,101,0,66, -0,111,0,100,0, -121,0,95,0,49, -0,50,0,1,192, -1732,1,191,1743,19, -1744,4,24,83,0, -116,0,97,0,116, -0,101,0,66,0, -111,0,100,0,121, -0,95,0,49,0, -49,0,1,191,1732, -1,190,1745,19,1746, -4,24,83,0,116, -0,97,0,116,0, -101,0,66,0,111, -0,100,0,121,0, -95,0,49,0,48, -0,1,190,1732,1, -189,1747,19,1748,4, -22,83,0,116,0, -97,0,116,0,101, -0,66,0,111,0, -100,0,121,0,95, -0,57,0,1,189, -1732,1,188,1749,19, -1750,4,22,83,0, -116,0,97,0,116, -0,101,0,66,0, -111,0,100,0,121, -0,95,0,56,0, -1,188,1732,1,187, -1751,19,1752,4,22, -83,0,116,0,97, -0,116,0,101,0, -66,0,111,0,100, -0,121,0,95,0, -55,0,1,187,1732, -1,186,1753,19,1754, -4,22,83,0,116, -0,97,0,116,0, -101,0,66,0,111, -0,100,0,121,0, -95,0,54,0,1, -186,1732,1,185,1755, -19,1756,4,22,83, -0,116,0,97,0, -116,0,101,0,66, -0,111,0,100,0, -121,0,95,0,53, -0,1,185,1732,1, -184,1757,19,1758,4, -22,83,0,116,0, -97,0,116,0,101, -0,66,0,111,0, -100,0,121,0,95, -0,52,0,1,184, -1732,1,183,1759,19, -1760,4,22,83,0, -116,0,97,0,116, -0,101,0,66,0, -111,0,100,0,121, -0,95,0,51,0, -1,183,1732,1,182, -1761,19,1762,4,22, -83,0,116,0,97, -0,116,0,101,0, -66,0,111,0,100, -0,121,0,95,0, -50,0,1,182,1732, -1,181,1763,19,1764, -4,22,83,0,116, -0,97,0,116,0, -101,0,66,0,111, -0,100,0,121,0, -95,0,49,0,1, -181,1732,1,180,1765, -19,1766,4,14,83, -0,116,0,97,0, -116,0,101,0,95, -0,50,0,1,180, -1767,5,4,1,2764, -1768,16,0,192,1, -2834,1769,16,0,192, -1,2823,1770,16,0, -782,1,0,1771,16, -0,782,1,179,1772, -19,1773,4,14,83, -0,116,0,97,0, -116,0,101,0,95, -0,49,0,1,179, -1767,1,178,1774,19, -1775,4,16,83,0, -116,0,97,0,116, -0,101,0,115,0, -95,0,50,0,1, -178,1776,5,2,1, -0,1777,16,0,582, -1,2823,1778,16,0, -724,1,177,1779,19, -1780,4,16,83,0, -116,0,97,0,116, -0,101,0,115,0, -95,0,49,0,1, -177,1776,1,176,1781, -19,1782,4,52,71, -0,108,0,111,0, -98,0,97,0,108, -0,70,0,117,0, -110,0,99,0,116, -0,105,0,111,0, -110,0,68,0,101, -0,102,0,105,0, -110,0,105,0,116, -0,105,0,111,0, -110,0,95,0,50, -0,1,176,1783,5, -2,1,0,1784,16, -0,711,1,2823,1785, -16,0,717,1,175, -1786,19,1787,4,52, -71,0,108,0,111, -0,98,0,97,0, -108,0,70,0,117, -0,110,0,99,0, -116,0,105,0,111, -0,110,0,68,0, -101,0,102,0,105, -0,110,0,105,0, -116,0,105,0,111, -0,110,0,95,0, -49,0,1,175,1783, -1,174,1788,19,1789, -4,54,71,0,108, -0,111,0,98,0, -97,0,108,0,86, -0,97,0,114,0, -105,0,97,0,98, -0,108,0,101,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,95,0,50, -0,1,174,1790,5, -2,1,0,1791,16, -0,710,1,2823,1792, -16,0,519,1,173, -1793,19,1794,4,54, -71,0,108,0,111, -0,98,0,97,0, -108,0,86,0,97, -0,114,0,105,0, -97,0,98,0,108, -0,101,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -95,0,49,0,1, -173,1790,1,172,1795, -19,1796,4,38,71, -0,108,0,111,0, -98,0,97,0,108, -0,68,0,101,0, -102,0,105,0,110, -0,105,0,116,0, -105,0,111,0,110, -0,115,0,95,0, -52,0,1,172,1797, -5,1,1,0,1798, -16,0,610,1,171, -1799,19,1800,4,38, -71,0,108,0,111, -0,98,0,97,0, -108,0,68,0,101, -0,102,0,105,0, -110,0,105,0,116, -0,105,0,111,0, -110,0,115,0,95, -0,51,0,1,171, -1797,1,170,1801,19, -1802,4,38,71,0, -108,0,111,0,98, -0,97,0,108,0, -68,0,101,0,102, -0,105,0,110,0, -105,0,116,0,105, -0,111,0,110,0, -115,0,95,0,50, -0,1,170,1797,1, -169,1803,19,1804,4, -38,71,0,108,0, -111,0,98,0,97, -0,108,0,68,0, -101,0,102,0,105, -0,110,0,105,0, -116,0,105,0,111, -0,110,0,115,0, -95,0,49,0,1, -169,1797,1,168,1805, -19,1806,4,32,76, -0,83,0,76,0, -80,0,114,0,111, -0,103,0,114,0, -97,0,109,0,82, -0,111,0,111,0, -116,0,95,0,50, -0,1,168,1807,5, -1,1,0,1808,16, -0,104,1,167,1809, -19,1810,4,32,76, -0,83,0,76,0, -80,0,114,0,111, -0,103,0,114,0, -97,0,109,0,82, -0,111,0,111,0, -116,0,95,0,49, -0,1,167,1807,1, -165,1811,19,1812,4, -56,73,0,110,0, -99,0,114,0,101, -0,109,0,101,0, -110,0,116,0,68, -0,101,0,99,0, -114,0,101,0,109, -0,101,0,110,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,165,1045, -1,164,1813,19,1814, -4,42,80,0,97, -0,114,0,101,0, -110,0,116,0,104, -0,101,0,115,0, -105,0,115,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, -164,1045,1,163,1815, -19,1816,4,36,84, -0,121,0,112,0, -101,0,99,0,97, -0,115,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -1,163,1045,1,162, -1817,19,1818,4,30, -85,0,110,0,97, -0,114,0,121,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -1,162,1045,1,161, -1819,19,1820,4,32, -66,0,105,0,110, -0,97,0,114,0, -121,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,161,1045, -1,160,1821,19,1822, -4,44,70,0,117, -0,110,0,99,0, -116,0,105,0,111, -0,110,0,67,0, -97,0,108,0,108, -0,69,0,120,0, -112,0,114,0,101, -0,115,0,115,0, -105,0,111,0,110, -0,1,160,1045,1, -159,1823,19,1824,4, -36,73,0,100,0, -101,0,110,0,116, -0,68,0,111,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,159,1045, -1,158,1825,19,1826, -4,30,73,0,100, -0,101,0,110,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,158,1045, -1,157,1827,19,1828, -4,36,67,0,111, -0,110,0,115,0, -116,0,97,0,110, -0,116,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,1,157, -1045,1,156,1829,19, -130,1,156,1045,1, -155,1830,19,1831,4, -24,76,0,105,0, -115,0,116,0,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -1,155,1201,1,154, -1832,19,1833,4,32, -82,0,111,0,116, -0,97,0,116,0, -105,0,111,0,110, -0,67,0,111,0, -110,0,115,0,116, -0,97,0,110,0, -116,0,1,154,1201, -1,153,1834,19,1835, -4,28,86,0,101, -0,99,0,116,0, -111,0,114,0,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -1,153,1201,1,152, -1836,19,540,1,152, -1201,1,151,1837,19, -1838,4,36,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,65,0, -114,0,103,0,117, -0,109,0,101,0, -110,0,116,0,1, -151,964,1,150,1839, -19,485,1,150,964, -1,149,1840,19,133, -1,149,812,1,148, -1841,19,555,1,148, -974,1,147,1842,19, -142,1,147,1396,1, -146,1843,19,653,1, -146,1408,1,145,1844, -19,650,1,145,1424, -1,144,1845,19,647, -1,144,1440,1,143, -1846,19,167,1,143, -1456,1,142,1847,19, -643,1,142,1476,1, -141,1848,19,621,1, -141,1492,1,140,1849, -19,635,1,140,1506, -1,139,1850,19,631, -1,139,1284,1,138, -1851,19,108,1,138, -1300,1,137,1852,19, -474,1,137,1380,1, -136,1853,19,625,1, -136,1558,1,135,1854, -19,123,1,135,1520, -1,134,1855,19,449, -1,134,1572,1,133, -1856,19,202,1,133, -1578,1,132,1857,19, -320,1,132,821,1, -131,1858,19,298,1, -131,828,1,130,1859, -19,280,1,130,835, -1,129,1860,19,471, -1,129,842,1,128, -1861,19,241,1,128, -853,1,127,1862,19, -229,1,127,878,1, -126,1863,19,445,1, -126,887,1,125,1864, -19,211,1,125,908, -1,124,1865,19,745, -1,124,931,1,123, -1866,19,265,1,123, -1604,1,122,1867,19, -249,1,122,1609,1, -121,1868,19,237,1, -121,1615,1,120,1869, -19,225,1,120,1623, -1,119,1870,19,275, -1,119,1628,1,118, -1871,19,303,1,118, -1648,1,117,1872,19, -285,1,117,1652,1, -116,1873,19,260,1, -116,1656,1,115,1874, -19,246,1,115,1660, -1,114,1875,19,234, -1,114,1664,1,113, -1876,19,222,1,113, -1668,1,112,1877,19, -206,1,112,804,1, -111,1878,19,191,1, -111,1676,1,110,1879, -19,173,1,110,1683, -1,109,1880,19,170, -1,109,1690,1,108, -1881,19,186,1,108, -1697,1,107,1882,19, -164,1,107,1704,1, -106,1883,19,182,1, -106,1711,1,105,1884, -19,179,1,105,1718, -1,104,1885,19,157, -1,104,1725,1,103, -1886,19,136,1,103, -1732,1,102,1887,19, -194,1,102,1767,1, -101,1888,19,584,1, -101,1776,1,100,1889, -19,713,1,100,1783, -1,99,1890,19,521, -1,99,1790,1,98, -1891,19,612,1,98, -1797,1,97,1892,19, -103,1,97,1807,1, -96,1893,19,497,1, -96,1894,5,95,1, -1574,1895,17,1896,15, -1897,4,20,37,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,-1, -1,5,1898,20,1549, -1,226,1,3,1, -3,1,2,1899,22, -1,61,1,2035,1900, -17,1901,15,1897,1, --1,1,5,1902,20, -1541,1,230,1,3, -1,3,1,2,1903, -22,1,65,1,1371, -1904,16,0,495,1, -71,1905,16,0,495, -1,1958,1906,16,0, -495,1,381,1907,16, -0,495,1,2106,1908, -16,0,495,1,1931, -1909,17,1910,15,1911, -4,30,37,0,87, -0,104,0,105,0, -108,0,101,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,1,-1,1, -5,1912,20,1453,1, -244,1,3,1,6, -1,5,1913,22,1, -79,1,1756,1914,16, -0,495,1,2031,1915, -17,1916,15,1897,1, --1,1,5,1917,20, -1535,1,233,1,3, -1,2,1,1,1918, -22,1,68,1,509, -1919,16,0,495,1, -2337,1920,16,0,495, -1,2029,1921,17,1922, -15,1897,1,-1,1, -5,1923,20,1519,1, -235,1,3,1,2, -1,1,1924,22,1, -70,1,1153,1925,16, -0,495,1,2136,1926, -17,1927,15,1928,4, -24,37,0,73,0, -102,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,-1,1,5,1929, -20,1455,1,243,1, -3,1,8,1,7, -1930,22,1,78,1, -1933,1931,16,0,495, -1,2198,1932,16,0, -495,1,1731,1933,16, -0,495,1,1335,1934, -16,0,495,1,2318, -1935,16,0,495,1, -346,1936,16,0,495, -1,182,1937,16,0, -495,1,137,1938,16, -0,495,1,1515,1939, -16,0,495,1,2105, -1940,17,1941,15,1928, -1,-1,1,5,1942, -20,1469,1,242,1, -3,1,6,1,5, -1943,22,1,77,1, -1775,1944,16,0,495, -1,1117,1945,16,0, -495,1,525,1946,16, -0,495,1,52,1947, -16,0,495,1,1901, -1948,16,0,495,1, -2293,1949,16,0,495, -1,322,1950,16,0, -495,1,124,1951,16, -0,495,1,1695,1952, -16,0,495,1,1297, -1953,16,0,495,1, -151,1954,16,0,495, -1,112,1955,16,0, -495,1,1990,1956,16, -0,495,1,76,1957, -16,0,495,1,43, -1958,16,0,495,1, -2075,1959,16,0,495, -1,1876,1960,16,0, -495,1,299,1961,16, -0,495,1,1479,1962, -16,0,495,1,2462, -1963,17,1964,15,1965, -4,28,37,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -1,-1,1,5,1966, -20,1575,1,220,1, -3,1,2,1,1, -1967,22,1,55,1, -97,1968,16,0,495, -1,2459,1969,17,1970, -15,1971,4,36,37, -0,67,0,111,0, -109,0,112,0,111, -0,117,0,110,0, -100,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,-1,1,5,1972, -20,1577,1,219,1, -3,1,4,1,3, -1973,22,1,54,1, -2458,1974,17,1975,15, -1965,1,-1,1,5, -1976,20,1571,1,221, -1,3,1,3,1, -2,1977,22,1,56, -1,2030,1978,17,1979, -15,1897,1,-1,1, -5,1980,20,1533,1, -234,1,3,1,2, -1,1,1981,22,1, -69,1,89,1982,16, -0,495,1,1860,1983, -17,1984,15,1985,4, -34,37,0,68,0, -111,0,87,0,104, -0,105,0,108,0, -101,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,-1,1,5,1986, -20,1437,1,246,1, -3,1,8,1,7, -1987,22,1,81,1, -85,1988,16,0,495, -1,1659,1989,16,0, -495,1,1657,1990,17, -1991,15,1897,1,-1, -1,5,1992,20,1553, -1,224,1,3,1, -3,1,2,1993,22, -1,59,1,277,1994, -16,0,495,1,1261, -1995,16,0,495,1, -166,1996,16,0,495, -1,2045,1997,17,1998, -15,1897,1,-1,1, -5,1999,20,1555,1, -223,1,3,1,3, -1,2,2000,22,1, -58,1,2043,2001,17, -2002,15,1897,1,-1, -1,5,2003,20,1551, -1,225,1,3,1, -3,1,2,2004,22, -1,60,1,2041,2005, -17,2006,15,1897,1, --1,1,5,2007,20, -1547,1,227,1,3, -1,3,1,2,2008, -22,1,62,1,2039, -2009,17,2010,15,1897, -1,-1,1,5,2011, -20,1545,1,228,1, -3,1,3,1,2, -2012,22,1,63,1, -462,2013,16,0,495, -1,2037,2014,17,2015, -15,1897,1,-1,1, -5,2016,20,1543,1, -229,1,3,1,3, -1,2,2017,22,1, -64,1,459,2018,16, -0,495,1,1443,2019, -16,0,495,1,2033, -2020,17,2021,15,1897, -1,-1,1,5,2022, -20,1539,1,231,1, -3,1,2,1,1, -2023,22,1,66,1, -2032,2024,17,2025,15, -1897,1,-1,1,5, -2026,20,1537,1,232, -1,3,1,2,1, -1,2027,22,1,67, -1,1834,2028,16,0, -495,1,2227,2029,17, -2030,15,1911,1,-1, -1,5,2031,20,1439, -1,245,1,3,1, -6,1,5,2032,22, -1,80,1,256,2033, -16,0,495,1,447, -2034,16,0,495,1, -62,2035,16,0,495, -1,2021,2036,17,2037, -15,1928,1,-1,1, -5,2038,20,1471,1, -241,1,3,1,8, -1,7,2039,22,1, -76,1,2413,2040,16, -0,495,1,1622,2041, -16,0,495,1,2464, -2042,17,2043,15,1971, -1,-1,1,5,2044, -20,1601,1,218,1, -3,1,3,1,2, -2045,22,1,53,1, -1225,2046,16,0,495, -1,41,2047,16,0, -495,1,236,2048,16, -0,495,1,431,2049, -16,0,495,1,32, -2050,16,0,495,1, -1804,2051,16,0,495, -1,1803,2052,17,2053, -15,2054,4,16,37, -0,70,0,111,0, -114,0,76,0,111, -0,111,0,112,0, -1,-1,1,5,2055, -20,1421,1,248,1, -3,1,10,1,9, -2056,22,1,83,1, -1407,2057,16,0,495, -1,79,2058,16,0, -495,1,217,2059,16, -0,495,1,1989,2060, -17,2061,15,1928,1, --1,1,5,2062,20, -1473,1,240,1,3, -1,6,1,5,2063, -22,1,75,1,102, -2064,16,0,495,1, -2786,2065,16,0,495, -1,406,2066,16,0, -495,1,1585,2067,16, -0,495,1,1189,2068, -16,0,495,1,1873, -2069,17,2070,15,1985, -1,-1,1,5,2071, -20,1423,1,247,1, -3,1,8,1,7, -2072,22,1,82,1, -199,2073,16,0,495, -1,2364,2074,17,2075, -15,2054,1,-1,1, -5,2076,20,1407,1, -249,1,3,1,9, -1,8,2077,22,1, -84,1,95,2078,19, -494,1,95,2079,5, -95,1,1574,1895,1, -2035,1900,1,1371,2080, -16,0,492,1,71, -2081,16,0,492,1, -1958,2082,16,0,492, -1,381,2083,16,0, -492,1,2106,2084,16, -0,492,1,1931,1909, -1,1756,2085,16,0, -492,1,2031,1915,1, -509,2086,16,0,492, -1,2337,2087,16,0, -492,1,2029,1921,1, -1153,2088,16,0,492, -1,2136,1926,1,1933, -2089,16,0,492,1, -2198,2090,16,0,492, -1,1731,2091,16,0, -492,1,1335,2092,16, -0,492,1,2318,2093, -16,0,492,1,346, -2094,16,0,492,1, -182,2095,16,0,492, -1,137,2096,16,0, -492,1,1515,2097,16, -0,492,1,2105,1940, -1,1775,2098,16,0, -492,1,1117,2099,16, -0,492,1,525,2100, -16,0,492,1,52, -2101,16,0,492,1, -1901,2102,16,0,492, -1,2293,2103,16,0, -492,1,322,2104,16, -0,492,1,124,2105, -16,0,492,1,1695, -2106,16,0,492,1, -1297,2107,16,0,492, -1,151,2108,16,0, -492,1,112,2109,16, -0,492,1,1990,2110, -16,0,492,1,76, -2111,16,0,492,1, -43,2112,16,0,492, -1,2075,2113,16,0, -492,1,1876,2114,16, -0,492,1,299,2115, -16,0,492,1,1479, -2116,16,0,492,1, -2462,1963,1,97,2117, -16,0,492,1,2459, -1969,1,2458,1974,1, -2030,1978,1,89,2118, -16,0,492,1,1860, -1983,1,85,2119,16, -0,492,1,1659,2120, -16,0,492,1,1657, -1990,1,277,2121,16, -0,492,1,1261,2122, -16,0,492,1,166, -2123,16,0,492,1, -2045,1997,1,2043,2001, -1,2041,2005,1,2039, -2009,1,462,2124,16, -0,492,1,2037,2014, -1,459,2125,16,0, -492,1,1443,2126,16, -0,492,1,2033,2020, -1,2032,2024,1,1834, -2127,16,0,492,1, -2227,2029,1,256,2128, -16,0,492,1,447, -2129,16,0,492,1, -62,2130,16,0,492, -1,2021,2036,1,2413, -2131,16,0,492,1, -1622,2132,16,0,492, -1,2464,2042,1,1225, -2133,16,0,492,1, -41,2134,16,0,492, -1,236,2135,16,0, -492,1,431,2136,16, -0,492,1,32,2137, -16,0,492,1,1804, -2138,16,0,492,1, -1803,2052,1,1407,2139, -16,0,492,1,79, -2140,16,0,492,1, -217,2141,16,0,492, -1,1989,2060,1,102, -2142,16,0,492,1, -2786,2143,16,0,492, -1,406,2144,16,0, -492,1,1585,2145,16, -0,492,1,1189,2146, -16,0,492,1,1873, -2069,1,199,2147,16, -0,492,1,2364,2074, -1,94,2148,19,491, -1,94,2149,5,95, -1,1574,1895,1,2035, -1900,1,1371,2150,16, -0,489,1,71,2151, -16,0,489,1,1958, -2152,16,0,489,1, -381,2153,16,0,489, -1,2106,2154,16,0, -489,1,1931,1909,1, -1756,2155,16,0,489, -1,2031,1915,1,509, -2156,16,0,489,1, -2337,2157,16,0,489, -1,2029,1921,1,1153, -2158,16,0,489,1, -2136,1926,1,1933,2159, -16,0,489,1,2198, -2160,16,0,489,1, -1731,2161,16,0,489, -1,1335,2162,16,0, -489,1,2318,2163,16, -0,489,1,346,2164, -16,0,489,1,182, -2165,16,0,489,1, -137,2166,16,0,489, -1,1515,2167,16,0, -489,1,2105,1940,1, -1775,2168,16,0,489, -1,1117,2169,16,0, -489,1,525,2170,16, -0,489,1,52,2171, -16,0,489,1,1901, -2172,16,0,489,1, -2293,2173,16,0,489, -1,322,2174,16,0, -489,1,124,2175,16, -0,489,1,1695,2176, -16,0,489,1,1297, -2177,16,0,489,1, -151,2178,16,0,489, -1,112,2179,16,0, -489,1,1990,2180,16, -0,489,1,76,2181, -16,0,489,1,43, -2182,16,0,489,1, -2075,2183,16,0,489, -1,1876,2184,16,0, -489,1,299,2185,16, -0,489,1,1479,2186, -16,0,489,1,2462, -1963,1,97,2187,16, -0,489,1,2459,1969, -1,2458,1974,1,2030, -1978,1,89,2188,16, -0,489,1,1860,1983, -1,85,2189,16,0, -489,1,1659,2190,16, -0,489,1,1657,1990, -1,277,2191,16,0, -489,1,1261,2192,16, -0,489,1,166,2193, -16,0,489,1,2045, -1997,1,2043,2001,1, -2041,2005,1,2039,2009, -1,462,2194,16,0, -489,1,2037,2014,1, -459,2195,16,0,489, -1,1443,2196,16,0, -489,1,2033,2020,1, -2032,2024,1,1834,2197, -16,0,489,1,2227, -2029,1,256,2198,16, -0,489,1,447,2199, -16,0,489,1,62, -2200,16,0,489,1, -2021,2036,1,2413,2201, -16,0,489,1,1622, -2202,16,0,489,1, -2464,2042,1,1225,2203, -16,0,489,1,41, -2204,16,0,489,1, -236,2205,16,0,489, -1,431,2206,16,0, -489,1,32,2207,16, -0,489,1,1804,2208, -16,0,489,1,1803, -2052,1,1407,2209,16, -0,489,1,79,2210, -16,0,489,1,217, -2211,16,0,489,1, -1989,2060,1,102,2212, -16,0,489,1,2786, -2213,16,0,489,1, -406,2214,16,0,489, -1,1585,2215,16,0, -489,1,1189,2216,16, -0,489,1,1873,2069, -1,199,2217,16,0, -489,1,2364,2074,1, -93,2218,19,161,1, -93,2219,5,129,1, -1574,1895,1,2035,1900, -1,1371,2220,16,0, -760,1,71,2221,16, -0,754,1,1958,2222, -16,0,760,1,381, -2223,16,0,754,1, -2106,2224,16,0,760, -1,1931,1909,1,378, -2225,16,0,541,1, -1756,2226,16,0,760, -1,376,2227,16,0, -159,1,2542,2228,16, -0,266,1,374,2229, -16,0,547,1,372, -2230,16,0,549,1, -509,2231,16,0,754, -1,2337,2232,16,0, -760,1,2029,1921,1, -1153,2233,16,0,760, -1,1901,2234,16,0, -760,1,2136,1926,1, -85,2235,16,0,754, -1,2527,2236,16,0, -289,1,65,2237,16, -0,739,1,1933,2238, -16,0,760,1,2198, -2239,16,0,760,1, -2811,2240,17,2241,15, -2242,4,52,37,0, -71,0,108,0,111, -0,98,0,97,0, -108,0,86,0,97, -0,114,0,105,0, -97,0,98,0,108, -0,101,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -1,-1,1,5,2243, -20,1789,1,174,1, -3,1,5,1,4, -2244,22,1,8,1, -1731,2245,16,0,754, -1,1335,2246,16,0, -760,1,2318,2247,16, -0,760,1,346,2248, -16,0,754,1,2512, -2249,16,0,307,1, -2508,2250,16,0,313, -1,182,2251,16,0, -754,1,137,2252,16, -0,754,1,1515,2253, -16,0,760,1,2105, -1940,1,1873,2069,1, -1117,2254,16,0,760, -1,525,2255,16,0, -754,1,52,2256,16, -0,760,1,1113,2257, -16,0,644,1,46, -2258,16,0,752,1, -2293,2259,16,0,754, -1,322,2260,16,0, -754,1,124,2261,16, -0,754,1,1695,2262, -16,0,760,1,1297, -2263,16,0,760,1, -151,2264,16,0,754, -1,112,2265,16,0, -754,1,1990,2266,16, -0,760,1,199,2267, -16,0,754,1,76, -2268,16,0,754,1, -43,2269,16,0,754, -1,2075,2270,16,0, -760,1,2468,2271,16, -0,423,1,2822,2272, -17,2273,15,2242,1, --1,1,5,2274,20, -1794,1,173,1,3, -1,3,1,2,2275, -22,1,7,1,299, -2276,16,0,754,1, -1479,2277,16,0,760, -1,2462,1963,1,97, -2278,16,0,754,1, -2031,1915,1,2459,1969, -1,2458,1974,1,2030, -1978,1,89,2279,16, -0,754,1,1860,1983, -1,2844,2280,17,2281, -15,2282,4,36,37, -0,71,0,108,0, -111,0,98,0,97, -0,108,0,68,0, -101,0,102,0,105, -0,110,0,105,0, -116,0,105,0,111, -0,110,0,115,0, -1,-1,1,5,2283, -20,1804,1,169,1, -3,1,2,1,1, -2284,22,1,3,1, -2843,2285,17,2286,15, -2282,1,-1,1,5, -2287,20,1800,1,171, -1,3,1,2,1, -1,2288,22,1,5, -1,2842,2289,17,2290, -15,2282,1,-1,1, -5,2291,20,1802,1, -170,1,3,1,3, -1,2,2292,22,1, -4,1,1659,2293,16, -0,760,1,1657,1990, -1,277,2294,16,0, -754,1,1261,2295,16, -0,760,1,2841,2296, -17,2297,15,2282,1, --1,1,5,2298,20, -1796,1,172,1,3, -1,3,1,2,2299, -22,1,6,1,166, -2300,16,0,754,1, -2045,1997,1,2043,2001, -1,2041,2005,1,2039, -2009,1,462,2301,16, -0,754,1,2037,2014, -1,459,2302,16,0, -754,1,1443,2303,16, -0,760,1,2033,2020, -1,2032,2024,1,1834, -2304,16,0,760,1, -2227,2029,1,256,2305, -16,0,754,1,2027, -2306,16,0,655,1, -2025,2307,16,0,698, -1,447,2308,16,0, -754,1,2466,2309,17, -2310,15,2311,4,50, -37,0,71,0,108, -0,111,0,98,0, -97,0,108,0,70, -0,117,0,110,0, -99,0,116,0,105, -0,111,0,110,0, -68,0,101,0,102, -0,105,0,110,0, -105,0,116,0,105, -0,111,0,110,0, -1,-1,1,5,2312, -20,1782,1,176,1, -3,1,7,1,6, -2313,22,1,10,1, -2021,2036,1,7,2314, -17,2315,15,2316,4, -18,37,0,84,0, -121,0,112,0,101, -0,110,0,97,0, -109,0,101,0,1, --1,1,5,2317,20, -961,1,337,1,3, -1,2,1,1,2318, -22,1,173,1,2413, -2319,16,0,760,1, -1876,2320,16,0,760, -1,1622,2321,16,0, -754,1,2464,2042,1, -1225,2322,16,0,760, -1,2022,2323,16,0, -663,1,41,2324,16, -0,754,1,236,2325, -16,0,754,1,431, -2326,16,0,754,1, -8,2327,16,0,784, -1,62,2328,16,0, -741,1,1804,2329,16, -0,760,1,1803,2052, -1,32,2330,16,0, -760,1,1407,2331,16, -0,760,1,2783,2332, -17,2333,15,2311,1, --1,1,5,2334,20, -1787,1,175,1,3, -1,6,1,5,2335, -22,1,9,1,2, -2336,17,2337,15,2316, -1,-1,1,5,2338, -20,951,1,342,1, -3,1,2,1,1, -2339,22,1,178,1, -79,2340,16,0,754, -1,217,2341,16,0, -754,1,1989,2060,1, -18,2342,16,0,778, -1,102,2343,16,0, -754,1,2786,2344,16, -0,754,1,406,2345, -16,0,754,1,0, -2346,16,0,781,1, -1585,2347,16,0,754, -1,2823,2348,16,0, -781,1,1189,2349,16, -0,760,1,6,2350, -17,2351,15,2316,1, --1,1,5,2352,20, -959,1,338,1,3, -1,2,1,1,2353, -22,1,174,1,5, -2354,17,2355,15,2316, -1,-1,1,5,2356, -20,957,1,339,1, -3,1,2,1,1, -2357,22,1,175,1, -4,2358,17,2359,15, -2316,1,-1,1,5, -2360,20,955,1,340, -1,3,1,2,1, -1,2361,22,1,176, -1,3,2362,17,2363, -15,2316,1,-1,1, -5,2364,20,953,1, -341,1,3,1,2, -1,1,2365,22,1, -177,1,1775,2366,16, -0,760,1,1,2367, -17,2368,15,2316,1, --1,1,5,2369,20, -930,1,343,1,3, -1,2,1,1,2370, -22,1,179,1,2364, -2074,1,92,2371,19, -347,1,92,2372,5, -30,1,2580,2373,17, -2374,15,2375,4,36, -37,0,86,0,111, -0,105,0,100,0, -65,0,114,0,103, -0,83,0,116,0, -97,0,116,0,101, -0,69,0,118,0, -101,0,110,0,116, -0,1,-1,1,5, -2376,20,1717,1,198, -1,3,1,5,1, -4,2377,22,1,32, -1,2648,2378,17,2379, -15,2380,4,20,37, -0,83,0,116,0, -97,0,116,0,101, -0,66,0,111,0, -100,0,121,0,1, --1,1,5,2381,20, -1762,1,182,1,3, -1,3,1,2,2382, -22,1,16,1,2575, -2383,17,2384,15,2385, -4,34,37,0,75, -0,101,0,121,0, -65,0,114,0,103, -0,83,0,116,0, -97,0,116,0,101, -0,69,0,118,0, -101,0,110,0,116, -0,1,-1,1,5, -2386,20,1710,1,199, -1,3,1,6,1, -5,2387,22,1,33, -1,2659,2388,16,0, -345,1,2657,2389,17, -2390,15,2380,1,-1, -1,5,2391,20,1764, -1,181,1,3,1, -2,1,1,2392,22, -1,15,1,2567,2393, -17,2394,15,2395,4, -34,37,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -1,-1,1,5,2396, -20,1703,1,200,1, -3,1,6,1,5, -2397,22,1,34,1, -2655,2398,17,2399,15, -2380,1,-1,1,5, -2400,20,1756,1,185, -1,3,1,2,1, -1,2401,22,1,19, -1,2654,2402,17,2403, -15,2380,1,-1,1, -5,2404,20,1752,1, -187,1,3,1,2, -1,1,2405,22,1, -21,1,2653,2406,17, -2407,15,2380,1,-1, -1,5,2408,20,1748, -1,189,1,3,1, -2,1,1,2409,22, -1,23,1,2652,2410, -17,2411,15,2380,1, --1,1,5,2412,20, -1744,1,191,1,3, -1,2,1,1,2413, -22,1,25,1,2651, -2414,17,2415,15,2380, -1,-1,1,5,2416, -20,1740,1,193,1, -3,1,2,1,1, -2417,22,1,27,1, -2650,2418,17,2419,15, -2380,1,-1,1,5, -2420,20,1736,1,195, -1,3,1,2,1, -1,2421,22,1,29, -1,2559,2422,17,2423, -15,2424,4,40,37, -0,86,0,101,0, -99,0,116,0,111, -0,114,0,65,0, -114,0,103,0,83, -0,116,0,97,0, -116,0,101,0,69, -0,118,0,101,0, -110,0,116,0,1, --1,1,5,2425,20, -1696,1,201,1,3, -1,6,1,5,2426, -22,1,35,1,2647, -2427,17,2428,15,2380, -1,-1,1,5,2429, -20,1758,1,184,1, -3,1,3,1,2, -2430,22,1,18,1, -2646,2431,17,2432,15, -2380,1,-1,1,5, -2433,20,1754,1,186, -1,3,1,3,1, -2,2434,22,1,20, -1,2645,2435,17,2436, -15,2380,1,-1,1, -5,2437,20,1750,1, -188,1,3,1,3, -1,2,2438,22,1, -22,1,2644,2439,17, -2440,15,2380,1,-1, -1,5,2441,20,1746, -1,190,1,3,1, -3,1,2,2442,22, -1,24,1,2643,2443, -17,2444,15,2380,1, --1,1,5,2445,20, -1742,1,192,1,3, -1,3,1,2,2446, -22,1,26,1,2464, -2042,1,2641,2447,17, -2448,15,2380,1,-1, -1,5,2449,20,1731, -1,196,1,3,1, -3,1,2,2450,22, -1,30,1,2551,2451, -17,2452,15,2453,4, -46,37,0,73,0, -110,0,116,0,82, -0,111,0,116,0, -82,0,111,0,116, -0,65,0,114,0, -103,0,83,0,116, -0,97,0,116,0, -101,0,69,0,118, -0,101,0,110,0, -116,0,1,-1,1, -5,2454,20,1689,1, -202,1,3,1,6, -1,5,2455,22,1, -36,1,2470,2456,16, -0,345,1,2459,1969, -1,2536,2457,17,2458, -15,2459,4,46,37, -0,73,0,110,0, -116,0,86,0,101, -0,99,0,86,0, -101,0,99,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -1,-1,1,5,2460, -20,1682,1,203,1, -3,1,6,1,5, -2461,22,1,37,1, -2703,2462,16,0,345, -1,2521,2463,17,2464, -15,2465,4,46,37, -0,75,0,101,0, -121,0,73,0,110, -0,116,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -83,0,116,0,97, -0,116,0,101,0, -69,0,118,0,101, -0,110,0,116,0, -1,-1,1,5,2466, -20,1675,1,204,1, -3,1,6,1,5, -2467,22,1,38,1, -2642,2468,17,2469,15, -2380,1,-1,1,5, -2470,20,1738,1,194, -1,3,1,3,1, -2,2471,22,1,28, -1,2656,2472,17,2473, -15,2380,1,-1,1, -5,2474,20,1760,1, -183,1,3,1,2, -1,1,2475,22,1, -17,1,2597,2476,16, -0,345,1,2595,2477, -17,2478,15,2479,4, -22,37,0,83,0, -116,0,97,0,116, -0,101,0,69,0, -118,0,101,0,110, -0,116,0,1,-1, -1,5,2480,20,1724, -1,197,1,3,1, -6,1,5,2481,22, -1,31,1,91,2482, -19,344,1,91,2483, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2484,16, -0,342,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2485,16,0,342,1, -2459,1969,1,2536,2457, -1,2703,2486,16,0, -342,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2487,16,0, -342,1,2595,2477,1, -90,2488,19,402,1, -90,2489,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2490,16,0,400,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2491,16,0, -400,1,2459,1969,1, -2536,2457,1,2703,2492, -16,0,400,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2493, -16,0,400,1,2595, -2477,1,89,2494,19, -405,1,89,2495,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2496,16,0, -403,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2497, -16,0,403,1,2459, -1969,1,2536,2457,1, -2703,2498,16,0,403, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2499,16,0,403, -1,2595,2477,1,88, -2500,19,399,1,88, -2501,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2502, -16,0,397,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2503,16,0,397, -1,2459,1969,1,2536, -2457,1,2703,2504,16, -0,397,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2505,16, -0,397,1,2595,2477, -1,87,2506,19,369, -1,87,2507,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2508,16,0,367, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2509,16, -0,367,1,2459,1969, -1,2536,2457,1,2703, -2510,16,0,367,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2511,16,0,367,1, -2595,2477,1,86,2512, -19,353,1,86,2513, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2514,16, -0,351,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2515,16,0,351,1, -2459,1969,1,2536,2457, -1,2703,2516,16,0, -351,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2517,16,0, -351,1,2595,2477,1, -85,2518,19,350,1, -85,2519,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2520,16,0,348,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2521,16,0, -348,1,2459,1969,1, -2536,2457,1,2703,2522, -16,0,348,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2523, -16,0,348,1,2595, -2477,1,84,2524,19, -396,1,84,2525,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2526,16,0, -394,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2527, -16,0,394,1,2459, -1969,1,2536,2457,1, -2703,2528,16,0,394, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2529,16,0,394, -1,2595,2477,1,83, -2530,19,393,1,83, -2531,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2532, -16,0,391,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2533,16,0,391, -1,2459,1969,1,2536, -2457,1,2703,2534,16, -0,391,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2535,16, -0,391,1,2595,2477, -1,82,2536,19,341, -1,82,2537,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2538,16,0,339, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2539,16, -0,339,1,2459,1969, -1,2536,2457,1,2703, -2540,16,0,339,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2541,16,0,339,1, -2595,2477,1,81,2542, -19,390,1,81,2543, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2544,16, -0,388,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2545,16,0,388,1, -2459,1969,1,2536,2457, -1,2703,2546,16,0, -388,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2547,16,0, -388,1,2595,2477,1, -80,2548,19,375,1, -80,2549,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2550,16,0,373,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2551,16,0, -373,1,2459,1969,1, -2536,2457,1,2703,2552, -16,0,373,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2553, -16,0,373,1,2595, -2477,1,79,2554,19, -366,1,79,2555,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2556,16,0, -364,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2557, -16,0,364,1,2459, -1969,1,2536,2457,1, -2703,2558,16,0,364, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2559,16,0,364, -1,2595,2477,1,78, -2560,19,363,1,78, -2561,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2562, -16,0,361,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2563,16,0,361, -1,2459,1969,1,2536, -2457,1,2703,2564,16, -0,361,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2565,16, -0,361,1,2595,2477, -1,77,2566,19,360, -1,77,2567,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2568,16,0,358, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2569,16, -0,358,1,2459,1969, -1,2536,2457,1,2703, -2570,16,0,358,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2571,16,0,358,1, -2595,2477,1,76,2572, -19,600,1,76,2573, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2574,16, -0,598,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2575,16,0,598,1, -2459,1969,1,2536,2457, -1,2703,2576,16,0, -598,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2577,16,0, -598,1,2595,2477,1, -75,2578,19,356,1, -75,2579,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2580,16,0,354,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2581,16,0, -354,1,2459,1969,1, -2536,2457,1,2703,2582, -16,0,354,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2583, -16,0,354,1,2595, -2477,1,74,2584,19, -338,1,74,2585,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2586,16,0, -336,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2587, -16,0,336,1,2459, -1969,1,2536,2457,1, -2703,2588,16,0,336, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2589,16,0,336, -1,2595,2477,1,73, -2590,19,335,1,73, -2591,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2592, -16,0,333,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2593,16,0,333, -1,2459,1969,1,2536, -2457,1,2703,2594,16, -0,333,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2595,16, -0,333,1,2595,2477, -1,72,2596,19,332, -1,72,2597,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2598,16,0,330, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2599,16, -0,330,1,2459,1969, -1,2536,2457,1,2703, -2600,16,0,330,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2601,16,0,330,1, -2595,2477,1,71,2602, -19,730,1,71,2603, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2604,16, -0,728,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2605,16,0,728,1, -2459,1969,1,2536,2457, -1,2703,2606,16,0, -728,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2607,16,0, -728,1,2595,2477,1, -70,2608,19,411,1, -70,2609,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2610,16,0,409,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2611,16,0, -409,1,2459,1969,1, -2536,2457,1,2703,2612, -16,0,409,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2613, -16,0,409,1,2595, -2477,1,69,2614,19, -408,1,69,2615,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2616,16,0, -406,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2617, -16,0,406,1,2459, -1969,1,2536,2457,1, -2703,2618,16,0,406, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2619,16,0,406, -1,2595,2477,1,68, -2620,19,329,1,68, -2621,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2622, -16,0,327,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2623,16,0,327, -1,2459,1969,1,2536, -2457,1,2703,2624,16, -0,327,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2625,16, -0,327,1,2595,2477, -1,67,2626,19,677, -1,67,2627,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2628,16,0,675, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2629,16, -0,675,1,2459,1969, -1,2536,2457,1,2703, -2630,16,0,675,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2631,16,0,675,1, -2595,2477,1,66,2632, -19,323,1,66,2633, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2634,16, -0,321,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2635,16,0,321,1, -2459,1969,1,2536,2457, -1,2703,2636,16,0, -321,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2637,16,0, -321,1,2595,2477,1, -65,2638,19,421,1, -65,2639,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2640,16,0,419,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2641,16,0, -419,1,2459,1969,1, -2536,2457,1,2703,2642, -16,0,419,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2643, -16,0,419,1,2595, -2477,1,64,2644,19, -387,1,64,2645,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2646,16,0, -385,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2647, -16,0,385,1,2459, -1969,1,2536,2457,1, -2703,2648,16,0,385, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2649,16,0,385, -1,2595,2477,1,63, -2650,19,384,1,63, -2651,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2652, -16,0,382,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2653,16,0,382, -1,2459,1969,1,2536, -2457,1,2703,2654,16, -0,382,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2655,16, -0,382,1,2595,2477, -1,62,2656,19,381, -1,62,2657,5,30, -1,2580,2373,1,2648, -2378,1,2575,2383,1, -2659,2658,16,0,379, -1,2657,2389,1,2567, -2393,1,2655,2398,1, -2654,2402,1,2653,2406, -1,2652,2410,1,2651, -2414,1,2650,2418,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -2643,2443,1,2464,2042, -1,2641,2447,1,2551, -2451,1,2470,2659,16, -0,379,1,2459,1969, -1,2536,2457,1,2703, -2660,16,0,379,1, -2521,2463,1,2642,2468, -1,2656,2472,1,2597, -2661,16,0,379,1, -2595,2477,1,61,2662, -19,378,1,61,2663, -5,30,1,2580,2373, -1,2648,2378,1,2575, -2383,1,2659,2664,16, -0,376,1,2657,2389, -1,2567,2393,1,2655, -2398,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2559,2422,1, -2647,2427,1,2646,2431, -1,2645,2435,1,2644, -2439,1,2643,2443,1, -2464,2042,1,2641,2447, -1,2551,2451,1,2470, -2665,16,0,376,1, -2459,1969,1,2536,2457, -1,2703,2666,16,0, -376,1,2521,2463,1, -2642,2468,1,2656,2472, -1,2597,2667,16,0, -376,1,2595,2477,1, -60,2668,19,372,1, -60,2669,5,30,1, -2580,2373,1,2648,2378, -1,2575,2383,1,2659, -2670,16,0,370,1, -2657,2389,1,2567,2393, -1,2655,2398,1,2654, -2402,1,2653,2406,1, -2652,2410,1,2651,2414, -1,2650,2418,1,2559, -2422,1,2647,2427,1, -2646,2431,1,2645,2435, -1,2644,2439,1,2643, -2443,1,2464,2042,1, -2641,2447,1,2551,2451, -1,2470,2671,16,0, -370,1,2459,1969,1, -2536,2457,1,2703,2672, -16,0,370,1,2521, -2463,1,2642,2468,1, -2656,2472,1,2597,2673, -16,0,370,1,2595, -2477,1,59,2674,19, -418,1,59,2675,5, -30,1,2580,2373,1, -2648,2378,1,2575,2383, -1,2659,2676,16,0, -416,1,2657,2389,1, -2567,2393,1,2655,2398, -1,2654,2402,1,2653, -2406,1,2652,2410,1, -2651,2414,1,2650,2418, -1,2559,2422,1,2647, -2427,1,2646,2431,1, -2645,2435,1,2644,2439, -1,2643,2443,1,2464, -2042,1,2641,2447,1, -2551,2451,1,2470,2677, -16,0,416,1,2459, -1969,1,2536,2457,1, -2703,2678,16,0,416, -1,2521,2463,1,2642, -2468,1,2656,2472,1, -2597,2679,16,0,416, -1,2595,2477,1,58, -2680,19,415,1,58, -2681,5,30,1,2580, -2373,1,2648,2378,1, -2575,2383,1,2659,2682, -16,0,413,1,2657, -2389,1,2567,2393,1, -2655,2398,1,2654,2402, -1,2653,2406,1,2652, -2410,1,2651,2414,1, -2650,2418,1,2559,2422, -1,2647,2427,1,2646, -2431,1,2645,2435,1, -2644,2439,1,2643,2443, -1,2464,2042,1,2641, -2447,1,2551,2451,1, -2470,2683,16,0,413, -1,2459,1969,1,2536, -2457,1,2703,2684,16, -0,413,1,2521,2463, -1,2642,2468,1,2656, -2472,1,2597,2685,16, -0,413,1,2595,2477, -1,57,2686,19,798, -1,57,2687,5,53, -1,1803,2052,1,2043, -2001,1,1775,2688,16, -0,796,1,2041,2005, -1,2843,2285,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,2689,16,0, -796,1,2842,2289,1, -2823,2690,16,0,796, -1,2464,2042,1,2822, -2272,1,1931,1909,1, -1574,1895,1,2462,1963, -1,2105,1940,1,52, -2691,16,0,796,1, -2459,1969,1,2458,1974, -1,10,2692,16,0, -796,1,2811,2240,1, -2364,2074,1,32,2693, -16,0,796,1,2783, -2332,1,1958,2694,16, -0,796,1,2841,2296, -1,2582,2695,16,0, -796,1,2198,2696,16, -0,796,1,2021,2036, -1,1901,2697,16,0, -796,1,1989,2060,1, -1990,2698,16,0,796, -1,2075,2699,16,0, -796,1,1804,2700,16, -0,796,1,2337,2701, -16,0,796,1,21, -2702,16,0,796,1, -1657,1990,1,2770,2703, -16,0,796,1,2413, -2704,16,0,796,1, -2844,2280,1,2045,1997, -1,1873,2069,1,0, -2705,16,0,796,1, -2227,2029,1,2466,2309, -1,2136,1926,1,56, -2706,19,269,1,56, -2707,5,55,1,1803, -2052,1,2043,2001,1, -1775,2708,16,0,795, -1,2041,2005,1,2843, -2285,1,2039,2009,1, -1860,1983,1,2037,2014, -1,2035,1900,1,2075, -2709,16,0,795,1, -2033,2020,1,2032,2024, -1,2031,1915,1,2030, -1978,1,2029,1921,1, -2106,2710,16,0,795, -1,2842,2289,1,2823, -2711,16,0,795,1, -2464,2042,1,2822,2272, -1,1931,1909,1,1574, -1895,1,2462,1963,1, -2105,1940,1,52,2712, -16,0,795,1,2459, -1969,1,2458,1974,1, -2545,2713,16,0,267, -1,2811,2240,1,2364, -2074,1,2541,2714,16, -0,267,1,2783,2332, -1,1958,2715,16,0, -795,1,2841,2296,1, -2198,2716,16,0,795, -1,2021,2036,1,1901, -2717,16,0,795,1, -1989,2060,1,1990,2718, -16,0,795,1,2466, -2309,1,32,2719,16, -0,795,1,1804,2720, -16,0,795,1,2337, -2721,16,0,795,1, -21,2722,16,0,795, -1,1657,1990,1,2770, -2723,16,0,795,1, -2413,2724,16,0,795, -1,2844,2280,1,2045, -1997,1,10,2725,16, -0,795,1,1873,2069, -1,0,2726,16,0, -795,1,2227,2029,1, -2582,2727,16,0,795, -1,2136,1926,1,55, -2728,19,292,1,55, -2729,5,56,1,1803, -2052,1,2043,2001,1, -1775,2730,16,0,794, -1,2041,2005,1,2843, -2285,1,2039,2009,1, -1860,1983,1,2037,2014, -1,2035,1900,1,2033, -2020,1,2032,2024,1, -2031,1915,1,2030,1978, -1,2029,1921,1,2106, -2731,16,0,794,1, -2842,2289,1,2823,2732, -16,0,794,1,2464, -2042,1,2822,2272,1, -1931,1909,1,2553,2733, -16,0,290,1,2462, -1963,1,2105,1940,1, -52,2734,16,0,794, -1,2459,1969,1,2458, -1974,1,10,2735,16, -0,794,1,2811,2240, -1,2364,2074,1,32, -2736,16,0,794,1, -2783,2332,1,1958,2737, -16,0,794,1,2841, -2296,1,2582,2738,16, -0,794,1,2530,2739, -16,0,290,1,2198, -2740,16,0,794,1, -2021,2036,1,2526,2741, -16,0,290,1,1901, -2742,16,0,794,1, -1989,2060,1,1990,2743, -16,0,794,1,2075, -2744,16,0,794,1, -1804,2745,16,0,794, -1,2337,2746,16,0, -794,1,21,2747,16, -0,794,1,1574,1895, -1,1657,1990,1,2770, -2748,16,0,794,1, -2413,2749,16,0,794, -1,2844,2280,1,2045, -1997,1,1873,2069,1, -0,2750,16,0,794, -1,2227,2029,1,2466, -2309,1,2136,1926,1, -54,2751,19,316,1, -54,2752,5,55,1, -1803,2052,1,2043,2001, -1,1775,2753,16,0, -793,1,2041,2005,1, -2843,2285,1,2039,2009, -1,1860,1983,1,2037, -2014,1,2569,2754,16, -0,314,1,2811,2240, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,2755,16,0, -793,1,2842,2289,1, -2823,2756,16,0,793, -1,2464,2042,1,2822, -2272,1,1931,1909,1, -1574,1895,1,2462,1963, -1,2105,1940,1,52, -2757,16,0,793,1, -2459,1969,1,2458,1974, -1,10,2758,16,0, -793,1,2841,2296,1, -2364,2074,1,32,2759, -16,0,793,1,2783, -2332,1,1958,2760,16, -0,793,1,2035,1900, -1,2582,2761,16,0, -793,1,2198,2762,16, -0,793,1,2021,2036, -1,1901,2763,16,0, -793,1,1989,2060,1, -1990,2764,16,0,793, -1,2075,2765,16,0, -793,1,1804,2766,16, -0,793,1,2337,2767, -16,0,793,1,21, -2768,16,0,793,1, -1657,1990,1,2507,2769, -16,0,314,1,2770, -2770,16,0,793,1, -2413,2771,16,0,793, -1,2844,2280,1,2045, -1997,1,1873,2069,1, -0,2772,16,0,793, -1,2227,2029,1,2466, -2309,1,2136,1926,1, -53,2773,19,792,1, -53,2774,5,53,1, -1803,2052,1,2043,2001, -1,1775,2775,16,0, -790,1,2041,2005,1, -2843,2285,1,2039,2009, -1,1860,1983,1,2037, -2014,1,2035,1900,1, -2033,2020,1,2032,2024, -1,2031,1915,1,2030, -1978,1,2029,1921,1, -2106,2776,16,0,790, -1,2842,2289,1,2823, -2777,16,0,790,1, -2464,2042,1,2822,2272, -1,1931,1909,1,1574, -1895,1,2462,1963,1, -2105,1940,1,52,2778, -16,0,790,1,2459, -1969,1,2458,1974,1, -10,2779,16,0,790, -1,2811,2240,1,2364, -2074,1,32,2780,16, -0,790,1,2783,2332, -1,1958,2781,16,0, -790,1,2841,2296,1, -2582,2782,16,0,790, -1,2198,2783,16,0, -790,1,2021,2036,1, -1901,2784,16,0,790, -1,1989,2060,1,1990, -2785,16,0,790,1, -2075,2786,16,0,790, -1,1804,2787,16,0, -790,1,2337,2788,16, -0,790,1,21,2789, -16,0,790,1,1657, -1990,1,2770,2790,16, -0,790,1,2413,2791, -16,0,790,1,2844, -2280,1,2045,1997,1, -1873,2069,1,0,2792, -16,0,790,1,2227, -2029,1,2466,2309,1, -2136,1926,1,52,2793, -19,789,1,52,2794, -5,53,1,1803,2052, -1,2043,2001,1,1775, -2795,16,0,787,1, -2041,2005,1,2843,2285, -1,2039,2009,1,1860, -1983,1,2037,2014,1, -2035,1900,1,2033,2020, -1,2032,2024,1,2031, -1915,1,2030,1978,1, -2029,1921,1,2106,2796, -16,0,787,1,2842, -2289,1,2823,2797,16, -0,787,1,2464,2042, -1,2822,2272,1,1931, -1909,1,1574,1895,1, -2462,1963,1,2105,1940, -1,52,2798,16,0, -787,1,2459,1969,1, -2458,1974,1,10,2799, -16,0,787,1,2811, -2240,1,2364,2074,1, -32,2800,16,0,787, -1,2783,2332,1,1958, -2801,16,0,787,1, -2841,2296,1,2582,2802, -16,0,787,1,2198, -2803,16,0,787,1, -2021,2036,1,1901,2804, -16,0,787,1,1989, -2060,1,1990,2805,16, -0,787,1,2075,2806, -16,0,787,1,1804, -2807,16,0,787,1, -2337,2808,16,0,787, -1,21,2809,16,0, -787,1,1657,1990,1, -2770,2810,16,0,787, -1,2413,2811,16,0, -787,1,2844,2280,1, -2045,1997,1,1873,2069, -1,0,2812,16,0, -787,1,2227,2029,1, -2466,2309,1,2136,1926, -1,51,2813,19,310, -1,51,2814,5,58, -1,1803,2052,1,2043, -2001,1,1775,2815,16, -0,786,1,2842,2289, -1,2843,2285,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2198,2816,16, -0,786,1,2030,1978, -1,2515,2817,16,0, -308,1,2106,2818,16, -0,786,1,2561,2819, -16,0,308,1,1873, -2069,1,2823,2820,16, -0,786,1,2466,2309, -1,1931,1909,1,2464, -2042,1,2783,2332,1, -2462,1963,1,2105,1940, -1,52,2821,16,0, -786,1,2459,1969,1, -2458,1974,1,2822,2272, -1,2811,2240,1,2364, -2074,1,32,2822,16, -0,786,1,2029,1921, -1,2538,2823,16,0, -308,1,2841,2296,1, -2041,2005,1,1657,1990, -1,2021,2036,1,1901, -2824,16,0,786,1, -2523,2825,16,0,308, -1,1990,2826,16,0, -786,1,2075,2827,16, -0,786,1,1804,2828, -16,0,786,1,2337, -2829,16,0,786,1, -21,2830,16,0,786, -1,1574,1895,1,1989, -2060,1,2511,2831,16, -0,308,1,2770,2832, -16,0,786,1,2413, -2833,16,0,786,1, -2844,2280,1,2045,1997, -1,10,2834,16,0, -786,1,0,2835,16, -0,786,1,2031,1915, -1,1958,2836,16,0, -786,1,2227,2029,1, -2582,2837,16,0,786, -1,2136,1926,1,50, -2838,19,326,1,50, -2839,5,38,1,2045, -1997,1,2043,2001,1, -1775,2840,16,0,324, -1,2041,2005,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,2841,16,0, -324,1,2464,2042,1, -1931,1909,1,1574,1895, -1,2462,1963,1,2105, -1940,1,2459,1969,1, -2458,1974,1,2364,2074, -1,1958,2842,16,0, -324,1,2198,2843,16, -0,324,1,2021,2036, -1,1901,2844,16,0, -324,1,1989,2060,1, -1803,2052,1,2075,2845, -16,0,324,1,1990, -2846,16,0,324,1, -1804,2847,16,0,324, -1,2337,2848,16,0, -324,1,1657,1990,1, -2413,2849,16,0,324, -1,32,2850,16,0, -324,1,1873,2069,1, -2227,2029,1,2136,1926, -1,49,2851,19,662, -1,49,2852,5,38, -1,2045,1997,1,2043, -2001,1,1775,2853,16, -0,660,1,2041,2005, -1,2039,2009,1,1860, -1983,1,2037,2014,1, -2035,1900,1,2033,2020, -1,2032,2024,1,2031, -1915,1,2030,1978,1, -2029,1921,1,2106,2854, -16,0,660,1,2464, -2042,1,1931,1909,1, -1574,1895,1,2462,1963, -1,2105,1940,1,2459, -1969,1,2458,1974,1, -2364,2074,1,1958,2855, -16,0,660,1,2198, -2856,16,0,660,1, -2021,2036,1,1901,2857, -16,0,660,1,1989, -2060,1,1803,2052,1, -2075,2858,16,0,660, -1,1990,2859,16,0, -660,1,1804,2860,16, -0,660,1,2337,2861, -16,0,660,1,1657, -1990,1,2413,2862,16, -0,660,1,32,2863, -16,0,660,1,1873, -2069,1,2227,2029,1, -2136,1926,1,48,2864, -19,426,1,48,2865, -5,54,1,1803,2052, -1,2043,2001,1,2755, -2866,17,2867,15,2868, -4,12,37,0,83, -0,116,0,97,0, -116,0,101,0,1, --1,1,5,2869,20, -1773,1,179,1,3, -1,5,1,4,2870, -22,1,13,1,2041, -2005,1,2843,2285,1, -2039,2009,1,1860,1983, -1,2037,2014,1,2035, -1900,1,2033,2020,1, -2032,2024,1,2031,1915, -1,2030,1978,1,2029, -1921,1,2106,2871,16, -0,665,1,2842,2289, -1,2649,2872,17,2873, -15,2868,1,-1,1, -5,2874,20,1766,1, -180,1,3,1,6, -1,5,2875,22,1, -14,1,2768,2876,17, -2877,15,2878,4,14, -37,0,83,0,116, -0,97,0,116,0, -101,0,115,0,1, --1,1,5,2879,20, -1780,1,177,1,3, -1,2,1,1,2880, -22,1,11,1,2823, -2881,16,0,424,1, -2822,2272,1,1931,1909, -1,2464,2042,1,2462, -1963,1,2105,1940,1, -2459,1969,1,2458,1974, -1,2811,2240,1,2364, -2074,1,32,2882,16, -0,665,1,2783,2332, -1,1958,2883,16,0, -665,1,2834,2884,16, -0,424,1,2841,2296, -1,2198,2885,16,0, -665,1,2021,2036,1, -1901,2886,16,0,665, -1,1989,2060,1,1990, -2887,16,0,665,1, -2075,2888,16,0,665, -1,1804,2889,16,0, -665,1,2337,2890,16, -0,665,1,1574,1895, -1,2045,1997,1,1657, -1990,1,1775,2891,16, -0,665,1,2413,2892, -16,0,665,1,2844, -2280,1,2767,2893,17, -2894,15,2878,1,-1, -1,5,2895,20,1775, -1,178,1,3,1, -3,1,2,2896,22, -1,12,1,2764,2897, -16,0,424,1,1873, -2069,1,0,2898,16, -0,424,1,2227,2029, -1,2466,2309,1,2136, -1926,1,47,2899,19, -154,1,47,2900,5, -19,1,2811,2240,1, -2768,2876,1,2844,2280, -1,2843,2285,1,2842, -2289,1,2767,2893,1, -2764,2901,16,0,152, -1,2022,2902,16,0, -664,1,2649,2872,1, -2834,2903,16,0,152, -1,2464,2042,1,2755, -2866,1,2841,2296,1, -2459,1969,1,2823,2904, -16,0,152,1,2822, -2272,1,2783,2332,1, -2466,2309,1,0,2905, -16,0,152,1,46, -2906,19,216,1,46, -2907,5,38,1,2045, -1997,1,2043,2001,1, -1775,2908,16,0,214, -1,2041,2005,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,2909,16,0, -214,1,2464,2042,1, -1931,1909,1,1574,1895, -1,2462,1963,1,2105, -1940,1,2459,1969,1, -2458,1974,1,2364,2074, -1,1958,2910,16,0, -214,1,2198,2911,16, -0,214,1,2021,2036, -1,1901,2912,16,0, -214,1,1989,2060,1, -1803,2052,1,2075,2913, -16,0,214,1,1990, -2914,16,0,214,1, -1804,2915,16,0,214, -1,2337,2916,16,0, -214,1,1657,1990,1, -2413,2917,16,0,214, -1,32,2918,16,0, -214,1,1873,2069,1, -2227,2029,1,2136,1926, -1,45,2919,19,120, -1,45,2920,5,39, -1,2045,1997,1,2043, -2001,1,1775,2921,16, -0,763,1,2041,2005, -1,2039,2009,1,1860, -1983,1,2037,2014,1, -2035,1900,1,2033,2020, -1,2032,2024,1,2031, -1915,1,2030,1978,1, -2029,1921,1,2106,2922, -16,0,763,1,2464, -2042,1,1931,1909,1, -1574,1895,1,2462,1963, -1,2105,1940,1,2459, -1969,1,2458,1974,1, -1832,2923,16,0,118, -1,2364,2074,1,1958, -2924,16,0,763,1, -2198,2925,16,0,763, -1,2021,2036,1,1901, -2926,16,0,763,1, -1989,2060,1,1803,2052, -1,2075,2927,16,0, -763,1,1990,2928,16, -0,763,1,1804,2929, -16,0,763,1,2337, -2930,16,0,763,1, -1657,1990,1,2413,2931, -16,0,763,1,32, -2932,16,0,763,1, -1873,2069,1,2227,2029, -1,2136,1926,1,44, -2933,19,126,1,44, -2934,5,38,1,2045, -1997,1,2043,2001,1, -1775,2935,16,0,124, -1,2041,2005,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,2936,16,0, -124,1,2464,2042,1, -1931,1909,1,1574,1895, -1,2462,1963,1,2105, -1940,1,2459,1969,1, -2458,1974,1,2364,2074, -1,1958,2937,16,0, -124,1,2198,2938,16, -0,124,1,2021,2036, -1,1901,2939,16,0, -124,1,1989,2060,1, -1803,2052,1,2075,2940, -16,0,124,1,1990, -2941,16,0,124,1, -1804,2942,16,0,124, -1,2337,2943,16,0, -124,1,1657,1990,1, -2413,2944,16,0,124, -1,32,2945,16,0, -124,1,1873,2069,1, -2227,2029,1,2136,1926, -1,43,2946,19,594, -1,43,2947,5,25, -1,1860,1983,1,2033, -2020,1,2032,2024,1, -2364,2074,1,2030,1978, -1,2029,1921,1,1657, -1990,1,1989,2948,16, -0,673,1,1803,2052, -1,2021,2036,1,2464, -2042,1,1574,1895,1, -2459,1969,1,1873,2069, -1,2136,1926,1,2031, -1915,1,2105,2949,16, -0,592,1,2045,1997, -1,2043,2001,1,1931, -1909,1,2041,2005,1, -2227,2029,1,2039,2009, -1,2037,2014,1,2035, -1900,1,42,2950,19, -438,1,42,2951,5, -38,1,2045,1997,1, -2043,2001,1,1775,2952, -16,0,436,1,2041, -2005,1,2039,2009,1, -1860,1983,1,2037,2014, -1,2035,1900,1,2033, -2020,1,2032,2024,1, -2031,1915,1,2030,1978, -1,2029,1921,1,2106, -2953,16,0,436,1, -2464,2042,1,1931,1909, -1,1574,1895,1,2462, -1963,1,2105,1940,1, -2459,1969,1,2458,1974, -1,2364,2074,1,1958, -2954,16,0,436,1, -2198,2955,16,0,436, -1,2021,2036,1,1901, -2956,16,0,436,1, -1989,2060,1,1803,2052, -1,2075,2957,16,0, -436,1,1990,2958,16, -0,436,1,1804,2959, -16,0,436,1,2337, -2960,16,0,436,1, -1657,1990,1,2413,2961, -16,0,436,1,32, -2962,16,0,436,1, -1873,2069,1,2227,2029, -1,2136,1926,1,41, -2963,19,757,1,41, -2964,5,84,1,1377, -2965,16,0,755,1, -387,2966,16,0,755, -1,188,2967,16,0, -755,1,380,2968,17, -2969,15,2970,4,38, -37,0,67,0,111, -0,110,0,115,0, -116,0,97,0,110, -0,116,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,1,-1, -1,5,2971,20,1198, -1,289,1,3,1, -2,1,1,2972,22, -1,124,1,379,2973, -17,2974,15,2975,4, -58,37,0,73,0, -110,0,99,0,114, -0,101,0,109,0, -101,0,110,0,116, -0,68,0,101,0, -99,0,114,0,101, -0,109,0,101,0, -110,0,116,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, --1,1,5,2976,20, -1180,1,298,1,3, -1,5,1,4,2977, -22,1,133,1,377, -2978,17,2979,15,2975, -1,-1,1,5,2980, -20,1184,1,296,1, -3,1,3,1,2, -2981,22,1,131,1, -2792,2982,16,0,755, -1,375,2983,17,2984, -15,2975,1,-1,1, -5,2985,20,1178,1, -299,1,3,1,5, -1,4,2986,22,1, -134,1,373,2987,17, -2988,15,2975,1,-1, -1,5,2989,20,1182, -1,297,1,3,1, -3,1,2,2990,22, -1,132,1,371,2991, -17,2992,15,2993,4, -46,37,0,70,0, -117,0,110,0,99, -0,116,0,105,0, -111,0,110,0,67, -0,97,0,108,0, -108,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,-1,1, -5,2994,20,1176,1, -300,1,3,1,2, -1,1,2995,22,1, -135,1,172,2996,16, -0,755,1,67,2997, -17,2998,15,2999,4, -38,37,0,84,0, -121,0,112,0,101, -0,99,0,97,0, -115,0,116,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, --1,1,5,3000,20, -1116,1,330,1,3, -1,8,1,7,3001, -22,1,165,1,1939, -3002,16,0,755,1, -1737,3003,16,0,755, -1,1341,3004,16,0, -755,1,157,3005,16, -0,755,1,480,3006, -17,3007,15,3008,4, -26,37,0,76,0, -105,0,115,0,116, -0,67,0,111,0, -110,0,115,0,116, -0,97,0,110,0, -116,0,1,-1,1, -5,3009,20,1273,1, -286,1,3,1,4, -1,3,3010,22,1, -121,1,942,3011,17, -3012,15,3013,4,34, -37,0,66,0,105, -0,110,0,97,0, -114,0,121,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, --1,1,5,3014,20, -1142,1,317,1,3, -1,4,1,3,3015, -22,1,152,1,49, -3016,17,3017,15,2975, -1,-1,1,5,3018, -20,1188,1,294,1, -3,1,5,1,4, -3019,22,1,129,1, -143,3020,16,0,755, -1,1521,3021,16,0, -755,1,1123,3022,16, -0,755,1,82,3023, -17,3024,15,3025,4, -32,37,0,85,0, -110,0,97,0,114, -0,121,0,69,0, -120,0,112,0,114, -0,101,0,115,0, -115,0,105,0,111, -0,110,0,1,-1, -1,5,3026,20,1134, -1,321,1,3,1, -3,1,2,3027,22, -1,156,1,2299,3028, -16,0,755,1,328, -3029,17,3030,15,3013, -1,-1,1,5,3031, -20,1172,1,302,1, -3,1,4,1,3, -3032,22,1,137,1, -130,3033,16,0,755, -1,1114,3034,17,3035, -15,3036,4,38,37, -0,73,0,100,0, -101,0,110,0,116, -0,68,0,111,0, -116,0,69,0,120, -0,112,0,114,0, -101,0,115,0,115, -0,105,0,111,0, -110,0,1,-1,1, -5,3037,20,1194,1, -291,1,3,1,4, -1,3,3038,22,1, -126,1,1701,3039,16, -0,755,1,1303,3040, -16,0,755,1,118, -3041,16,0,755,1, -1096,3042,17,3043,15, -3044,4,26,37,0, -70,0,117,0,110, -0,99,0,116,0, -105,0,111,0,110, -0,67,0,97,0, -108,0,108,0,1, --1,1,5,3045,20, -973,1,333,1,3, -1,5,1,4,3046, -22,1,168,1,1882, -3047,16,0,755,1, -305,3048,17,3049,15, -3013,1,-1,1,5, -3050,20,1170,1,303, -1,3,1,4,1, -3,3051,22,1,138, -1,107,3052,17,3053, -15,3025,1,-1,1, -5,3054,20,1138,1, -319,1,3,1,3, -1,2,3055,22,1, -154,1,1485,3056,16, -0,755,1,70,3057, -17,3058,15,2999,1, --1,1,5,3059,20, -1122,1,327,1,3, -1,6,1,5,3060, -22,1,162,1,1555, -3061,16,0,755,1, -883,3062,16,0,755, -1,93,3063,17,3064, -15,3025,1,-1,1, -5,3065,20,1136,1, -320,1,3,1,3, -1,2,3066,22,1, -155,1,1665,3067,16, -0,755,1,283,3068, -17,3069,15,3013,1, --1,1,5,3070,20, -1168,1,304,1,3, -1,4,1,3,3071, -22,1,139,1,479, -3072,17,3073,15,3074, -4,18,37,0,67, -0,111,0,110,0, -115,0,116,0,97, -0,110,0,116,0, -1,-1,1,5,3075, -20,1281,1,282,1, -3,1,2,1,1, -3076,22,1,117,1, -478,3077,17,3078,15, -3074,1,-1,1,5, -3079,20,1279,1,283, -1,3,1,2,1, -1,3080,22,1,118, -1,477,3081,17,3082, -15,3074,1,-1,1, -5,3083,20,1277,1, -284,1,3,1,2, -1,1,3084,22,1, -119,1,476,3085,17, -3086,15,3074,1,-1, -1,5,3087,20,1275, -1,285,1,3,1, -2,1,1,3088,22, -1,120,1,74,3089, -17,3090,15,2999,1, --1,1,5,3091,20, -1044,1,332,1,3, -1,7,1,6,3092, -22,1,167,1,73, -3093,16,0,755,1, -1449,3094,16,0,755, -1,69,3095,17,3096, -15,2999,1,-1,1, -5,3097,20,1118,1, -329,1,3,1,6, -1,5,3098,22,1, -164,1,68,3099,17, -3100,15,2999,1,-1, -1,5,3101,20,1120, -1,328,1,3,1, -8,1,7,3102,22, -1,163,1,1840,3103, -16,0,755,1,66, -3104,17,3105,15,2999, -1,-1,1,5,3106, -20,1124,1,326,1, -3,1,7,1,6, -3107,22,1,161,1, -262,3108,17,3109,15, -3013,1,-1,1,5, -3110,20,1166,1,305, -1,3,1,4,1, -3,3111,22,1,140, -1,1267,3112,16,0, -755,1,1048,3113,17, -3114,15,3013,1,-1, -1,5,3115,20,1140, -1,318,1,3,1, -4,1,3,3116,22, -1,153,1,447,3117, -17,3118,15,3119,4, -30,37,0,86,0, -101,0,99,0,116, -0,111,0,114,0, -67,0,111,0,110, -0,115,0,116,0, -97,0,110,0,116, -0,1,-1,1,5, -3120,20,1271,1,287, -1,3,1,8,1, -7,3121,22,1,122, -1,1628,3122,16,0, -755,1,51,3123,17, -3124,15,2975,1,-1, -1,5,3125,20,1192, -1,292,1,3,1, -3,1,2,3126,22, -1,127,1,63,3127, -17,3128,15,2999,1, --1,1,5,3129,20, -1126,1,325,1,3, -1,5,1,4,3130, -22,1,160,1,1231, -3131,16,0,755,1, -48,3132,17,3133,15, -2975,1,-1,1,5, -3134,20,1186,1,295, -1,3,1,5,1, -4,3135,22,1,130, -1,47,3136,17,3035, -1,3,3038,1,242, -3137,16,0,755,1, -44,3138,17,3139,15, -3140,4,32,37,0, -73,0,100,0,101, -0,110,0,116,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -1,-1,1,5,3141, -20,1196,1,290,1, -3,1,2,1,1, -3142,22,1,125,1, -437,3143,16,0,755, -1,42,3144,16,0, -755,1,525,3145,17, -3146,15,3147,4,34, -37,0,82,0,111, -0,116,0,97,0, -116,0,105,0,111, -0,110,0,67,0, -111,0,110,0,115, -0,116,0,97,0, -110,0,116,0,1, --1,1,5,3148,20, -1200,1,288,1,3, -1,10,1,9,3149, -22,1,123,1,827, -3150,16,0,755,1, -352,3151,17,3152,15, -3013,1,-1,1,5, -3153,20,1174,1,301, -1,3,1,4,1, -3,3154,22,1,136, -1,1413,3155,16,0, -755,1,1013,3156,17, -3157,15,3158,4,44, -37,0,80,0,97, -0,114,0,101,0, -110,0,116,0,104, -0,101,0,115,0, -105,0,115,0,69, -0,120,0,112,0, -114,0,101,0,115, -0,115,0,105,0, -111,0,110,0,1, --1,1,5,3159,20, -1132,1,322,1,3, -1,4,1,3,3160, -22,1,157,1,1012, -3161,16,0,755,1, -223,3162,16,0,755, -1,1159,3163,16,0, -755,1,1011,3164,17, -3165,15,3158,1,-1, -1,5,3166,20,1130, -1,323,1,3,1, -4,1,3,3167,22, -1,158,1,412,3168, -16,0,755,1,1002, -3169,17,3170,15,2999, -1,-1,1,5,3171, -20,1128,1,324,1, -3,1,5,1,4, -3172,22,1,159,1, -1001,3173,17,3174,15, -2999,1,-1,1,5, -3175,20,1114,1,331, -1,3,1,5,1, -4,3176,22,1,166, -1,1591,3177,16,0, -755,1,1195,3178,16, -0,755,1,40,3179, -17,3139,1,1,3142, -1,205,3180,16,0, -755,1,50,3181,17, -3182,15,2975,1,-1, -1,5,3183,20,1190, -1,293,1,3,1, -3,1,2,3184,22, -1,128,1,515,3185, -16,0,755,1,40, -3186,19,727,1,40, -3187,5,84,1,1377, -3188,16,0,725,1, -387,3189,16,0,725, -1,188,3190,16,0, -725,1,380,2968,1, -379,2973,1,377,2978, -1,2792,3191,16,0, -725,1,375,2983,1, -373,2987,1,371,2991, -1,172,3192,16,0, -725,1,67,2997,1, -1939,3193,16,0,725, -1,1737,3194,16,0, -725,1,1341,3195,16, -0,725,1,157,3196, -16,0,725,1,480, -3006,1,942,3011,1, -49,3016,1,143,3197, -16,0,725,1,1521, -3198,16,0,725,1, -1123,3199,16,0,725, -1,82,3023,1,2299, -3200,16,0,725,1, -328,3029,1,130,3201, -16,0,725,1,1114, -3034,1,1701,3202,16, -0,725,1,1303,3203, -16,0,725,1,118, -3204,16,0,725,1, -1096,3042,1,1882,3205, -16,0,725,1,305, -3048,1,107,3052,1, -1485,3206,16,0,725, -1,70,3057,1,1555, -3207,16,0,725,1, -883,3208,16,0,725, -1,93,3063,1,1665, -3209,16,0,725,1, -283,3068,1,479,3072, -1,478,3077,1,477, -3081,1,476,3085,1, -74,3089,1,73,3210, -16,0,725,1,1449, -3211,16,0,725,1, -69,3095,1,68,3099, -1,1840,3212,16,0, -725,1,66,3104,1, -262,3108,1,1267,3213, -16,0,725,1,1048, -3113,1,447,3117,1, -1628,3214,16,0,725, -1,51,3123,1,63, -3127,1,1231,3215,16, -0,725,1,48,3132, -1,47,3136,1,242, -3216,16,0,725,1, -44,3138,1,437,3217, -16,0,725,1,42, -3218,16,0,725,1, -525,3145,1,827,3219, -16,0,725,1,352, -3151,1,1413,3220,16, -0,725,1,1013,3156, -1,1012,3221,16,0, -725,1,223,3222,16, -0,725,1,1159,3223, -16,0,725,1,1011, -3164,1,412,3224,16, -0,725,1,1002,3169, -1,1001,3173,1,1591, -3225,16,0,725,1, -1195,3226,16,0,725, -1,40,3179,1,205, -3227,16,0,725,1, -50,3181,1,515,3228, -16,0,725,1,39, -3229,19,716,1,39, -3230,5,84,1,1377, -3231,16,0,714,1, -387,3232,16,0,714, -1,188,3233,17,3234, -15,3013,1,-1,1, -5,3235,20,1158,1, -309,1,3,1,4, -1,3,3236,22,1, -144,1,380,2968,1, -379,2973,1,377,2978, -1,2792,3237,16,0, -714,1,375,2983,1, -373,2987,1,371,2991, -1,172,3238,17,3239, -15,3013,1,-1,1, -5,3240,20,1156,1, -310,1,3,1,4, -1,3,3241,22,1, -145,1,67,2997,1, -1939,3242,16,0,714, -1,1737,3243,16,0, -714,1,1341,3244,16, -0,714,1,157,3245, -17,3246,15,3013,1, --1,1,5,3247,20, -1154,1,311,1,3, -1,4,1,3,3248, -22,1,146,1,480, -3006,1,942,3011,1, -49,3016,1,143,3249, -17,3250,15,3013,1, --1,1,5,3251,20, -1152,1,312,1,3, -1,4,1,3,3252, -22,1,147,1,1521, -3253,16,0,714,1, -1123,3254,16,0,714, -1,82,3023,1,2299, -3255,16,0,714,1, -328,3029,1,130,3256, -17,3257,15,3013,1, --1,1,5,3258,20, -1150,1,313,1,3, -1,4,1,3,3259, -22,1,148,1,1114, -3034,1,1701,3260,16, -0,714,1,1303,3261, -16,0,714,1,118, -3262,17,3263,15,3013, -1,-1,1,5,3264, -20,1148,1,314,1, -3,1,4,1,3, -3265,22,1,149,1, -1096,3042,1,1882,3266, -16,0,714,1,305, -3048,1,107,3052,1, -1485,3267,16,0,714, -1,70,3057,1,1555, -3268,16,0,714,1, -883,3269,17,3270,15, -3013,1,-1,1,5, -3271,20,1144,1,316, -1,3,1,4,1, -3,3272,22,1,151, -1,93,3063,1,1665, -3273,16,0,714,1, -283,3068,1,479,3072, -1,478,3077,1,477, -3081,1,476,3085,1, -74,3089,1,73,3274, -16,0,714,1,1449, -3275,16,0,714,1, -69,3095,1,68,3099, -1,1840,3276,16,0, -714,1,66,3104,1, -262,3108,1,1267,3277, -16,0,714,1,1048, -3113,1,447,3117,1, -1628,3278,16,0,714, -1,51,3123,1,63, -3127,1,1231,3279,16, -0,714,1,48,3132, -1,47,3136,1,242, -3280,17,3281,15,3013, -1,-1,1,5,3282, -20,1164,1,306,1, -3,1,4,1,3, -3283,22,1,141,1, -44,3138,1,437,3284, -16,0,714,1,42, -3285,16,0,714,1, -525,3145,1,827,3286, -17,3287,15,3013,1, --1,1,5,3288,20, -1146,1,315,1,3, -1,4,1,3,3289, -22,1,150,1,352, -3151,1,1413,3290,16, -0,714,1,1013,3156, -1,1012,3291,16,0, -714,1,223,3292,17, -3293,15,3013,1,-1, -1,5,3294,20,1162, -1,307,1,3,1, -4,1,3,3295,22, -1,142,1,1159,3296, -16,0,714,1,1011, -3164,1,412,3297,16, -0,714,1,1002,3169, -1,1001,3173,1,1591, -3298,16,0,714,1, -1195,3299,16,0,714, -1,40,3179,1,205, -3300,17,3301,15,3013, -1,-1,1,5,3302, -20,1160,1,308,1, -3,1,4,1,3, -3303,22,1,143,1, -50,3181,1,515,3304, -16,0,714,1,38, -3305,19,703,1,38, -3306,5,84,1,1377, -3307,16,0,701,1, -387,3308,16,0,701, -1,188,3233,1,380, -2968,1,379,2973,1, -377,2978,1,2792,3309, -16,0,701,1,375, -2983,1,373,2987,1, -371,2991,1,172,3238, -1,67,2997,1,1939, -3310,16,0,701,1, -1737,3311,16,0,701, -1,1341,3312,16,0, -701,1,157,3245,1, -480,3006,1,942,3011, -1,49,3016,1,143, -3249,1,1521,3313,16, -0,701,1,1123,3314, -16,0,701,1,82, -3023,1,2299,3315,16, -0,701,1,328,3029, -1,130,3256,1,1114, -3034,1,1701,3316,16, -0,701,1,1303,3317, -16,0,701,1,118, -3262,1,1096,3042,1, -1882,3318,16,0,701, -1,305,3048,1,107, -3052,1,1485,3319,16, -0,701,1,70,3057, -1,1555,3320,16,0, -701,1,883,3269,1, -93,3063,1,1665,3321, -16,0,701,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,3322,16, -0,701,1,1449,3323, -16,0,701,1,69, -3095,1,68,3099,1, -1840,3324,16,0,701, -1,66,3104,1,262, -3108,1,1267,3325,16, -0,701,1,1048,3113, -1,447,3117,1,1628, -3326,16,0,701,1, -51,3123,1,63,3127, -1,1231,3327,16,0, -701,1,48,3132,1, -47,3136,1,242,3280, -1,44,3138,1,437, -3328,16,0,701,1, -42,3329,16,0,701, -1,525,3145,1,827, -3286,1,352,3151,1, -1413,3330,16,0,701, -1,1013,3156,1,1012, -3331,16,0,701,1, -223,3292,1,1159,3332, -16,0,701,1,1011, -3164,1,412,3333,16, -0,701,1,1002,3169, -1,1001,3173,1,1591, -3334,16,0,701,1, -1195,3335,16,0,701, -1,40,3179,1,205, -3300,1,50,3181,1, -515,3336,16,0,701, -1,37,3337,19,696, -1,37,3338,5,94, -1,1574,1895,1,2035, -1900,1,1371,3339,16, -0,694,1,71,3340, -16,0,694,1,1958, -3341,16,0,694,1, -381,3342,16,0,694, -1,2106,3343,16,0, -694,1,1931,1909,1, -1756,3344,16,0,694, -1,2031,1915,1,509, -3345,16,0,694,1, -2337,3346,16,0,694, -1,2029,1921,1,1153, -3347,16,0,694,1, -2136,1926,1,1933,3348, -16,0,694,1,2198, -3349,16,0,694,1, -1731,3350,16,0,694, -1,1335,3351,16,0, -694,1,2318,3352,16, -0,694,1,346,3353, -16,0,694,1,182, -3354,16,0,694,1, -137,3355,16,0,694, -1,1515,3356,16,0, -694,1,2105,1940,1, -1775,3357,16,0,694, -1,1117,3358,16,0, -694,1,525,3359,16, -0,694,1,1901,3360, -16,0,694,1,2293, -3361,16,0,694,1, -322,3362,16,0,694, -1,124,3363,16,0, -694,1,1695,3364,16, -0,694,1,1297,3365, -16,0,694,1,151, -3366,16,0,694,1, -112,3367,16,0,694, -1,1990,3368,16,0, -694,1,76,3369,16, -0,694,1,43,3370, -16,0,694,1,2075, -3371,16,0,694,1, -1876,3372,16,0,694, -1,299,3373,16,0, -694,1,1479,3374,16, -0,694,1,2462,1963, -1,97,3375,16,0, -694,1,2459,1969,1, -2458,1974,1,2030,1978, -1,89,3376,16,0, -694,1,1860,1983,1, -85,3377,16,0,694, -1,1659,3378,16,0, -694,1,1657,1990,1, -277,3379,16,0,694, -1,1261,3380,16,0, -694,1,166,3381,16, -0,694,1,2045,1997, -1,2043,2001,1,2041, -2005,1,2039,2009,1, -462,3382,16,0,694, -1,2037,2014,1,459, -3383,16,0,694,1, -1443,3384,16,0,694, -1,2033,2020,1,2032, -2024,1,1834,3385,16, -0,694,1,2227,2029, -1,256,3386,16,0, -694,1,447,3387,16, -0,694,1,52,3388, -16,0,694,1,2021, -2036,1,2413,3389,16, -0,694,1,1622,3390, -16,0,694,1,2464, -2042,1,1225,3391,16, -0,694,1,41,3392, -16,0,694,1,236, -3393,16,0,694,1, -431,3394,16,0,694, -1,32,3395,16,0, -694,1,1804,3396,16, -0,694,1,1803,2052, -1,1407,3397,16,0, -694,1,79,3398,16, -0,694,1,217,3399, -16,0,694,1,1989, -2060,1,102,3400,16, -0,694,1,2786,3401, -16,0,694,1,406, -3402,16,0,694,1, -1585,3403,16,0,694, -1,1189,3404,16,0, -694,1,1873,2069,1, -199,3405,16,0,694, -1,2364,2074,1,36, -3406,19,722,1,36, -3407,5,94,1,1574, -1895,1,2035,1900,1, -1371,3408,16,0,720, -1,71,3409,16,0, -720,1,1958,3410,16, -0,720,1,381,3411, -16,0,720,1,2106, -3412,16,0,720,1, -1931,1909,1,1756,3413, -16,0,720,1,2031, -1915,1,509,3414,16, -0,720,1,2337,3415, -16,0,720,1,2029, -1921,1,1153,3416,16, -0,720,1,2136,1926, -1,1933,3417,16,0, -720,1,2198,3418,16, -0,720,1,1731,3419, -16,0,720,1,1335, -3420,16,0,720,1, -2318,3421,16,0,720, -1,346,3422,16,0, -720,1,182,3423,16, -0,720,1,137,3424, -16,0,720,1,1515, -3425,16,0,720,1, -2105,1940,1,1775,3426, -16,0,720,1,1117, -3427,16,0,720,1, -525,3428,16,0,720, -1,1901,3429,16,0, -720,1,2293,3430,16, -0,720,1,322,3431, -16,0,720,1,124, -3432,16,0,720,1, -1695,3433,16,0,720, -1,1297,3434,16,0, -720,1,151,3435,16, -0,720,1,112,3436, -16,0,720,1,1990, -3437,16,0,720,1, -76,3438,16,0,720, -1,43,3439,16,0, -720,1,2075,3440,16, -0,720,1,1876,3441, -16,0,720,1,299, -3442,16,0,720,1, -1479,3443,16,0,720, -1,2462,1963,1,97, -3444,16,0,720,1, -2459,1969,1,2458,1974, -1,2030,1978,1,89, -3445,16,0,720,1, -1860,1983,1,85,3446, -16,0,720,1,1659, -3447,16,0,720,1, -1657,1990,1,277,3448, -16,0,720,1,1261, -3449,16,0,720,1, -166,3450,16,0,720, -1,2045,1997,1,2043, -2001,1,2041,2005,1, -2039,2009,1,462,3451, -16,0,720,1,2037, -2014,1,459,3452,16, -0,720,1,1443,3453, -16,0,720,1,2033, -2020,1,2032,2024,1, -1834,3454,16,0,720, -1,2227,2029,1,256, -3455,16,0,720,1, -447,3456,16,0,720, -1,52,3457,16,0, -720,1,2021,2036,1, -2413,3458,16,0,720, -1,1622,3459,16,0, -720,1,2464,2042,1, -1225,3460,16,0,720, -1,41,3461,16,0, -720,1,236,3462,16, -0,720,1,431,3463, -16,0,720,1,32, -3464,16,0,720,1, -1804,3465,16,0,720, -1,1803,2052,1,1407, -3466,16,0,720,1, -79,3467,16,0,720, -1,217,3468,16,0, -720,1,1989,2060,1, -102,3469,16,0,720, -1,2786,3470,16,0, -720,1,406,3471,16, -0,720,1,1585,3472, -16,0,720,1,1189, -3473,16,0,720,1, -1873,2069,1,199,3474, -16,0,720,1,2364, -2074,1,35,3475,19, -638,1,35,3476,5, -84,1,1377,3477,16, -0,636,1,387,3478, -16,0,636,1,188, -3233,1,380,2968,1, -379,2973,1,377,2978, -1,2792,3479,16,0, -636,1,375,2983,1, -373,2987,1,371,2991, -1,172,3238,1,67, -2997,1,1939,3480,16, -0,636,1,1737,3481, -16,0,636,1,1341, -3482,16,0,636,1, -157,3245,1,480,3006, -1,942,3011,1,49, -3016,1,143,3249,1, -1521,3483,16,0,636, -1,1123,3484,16,0, -636,1,82,3023,1, -2299,3485,16,0,636, -1,328,3029,1,130, -3256,1,1114,3034,1, -1701,3486,16,0,636, -1,1303,3487,16,0, -636,1,118,3262,1, -1096,3042,1,1882,3488, -16,0,636,1,305, -3048,1,107,3052,1, -1485,3489,16,0,636, -1,70,3057,1,1555, -3490,16,0,636,1, -883,3491,16,0,636, -1,93,3063,1,1665, -3492,16,0,636,1, -283,3068,1,479,3072, -1,478,3077,1,477, -3081,1,476,3085,1, -74,3089,1,73,3493, -16,0,636,1,1449, -3494,16,0,636,1, -69,3095,1,68,3099, -1,1840,3495,16,0, -636,1,66,3104,1, -262,3108,1,1267,3496, -16,0,636,1,1048, -3113,1,447,3117,1, -1628,3497,16,0,636, -1,51,3123,1,63, -3127,1,1231,3498,16, -0,636,1,48,3132, -1,47,3136,1,242, -3280,1,44,3138,1, -437,3499,16,0,636, -1,42,3500,16,0, -636,1,525,3145,1, -827,3501,16,0,636, -1,352,3151,1,1413, -3502,16,0,636,1, -1013,3156,1,1012,3503, -16,0,636,1,223, -3504,16,0,636,1, -1159,3505,16,0,636, -1,1011,3164,1,412, -3506,16,0,636,1, -1002,3169,1,1001,3173, -1,1591,3507,16,0, -636,1,1195,3508,16, -0,636,1,40,3179, -1,205,3300,1,50, -3181,1,515,3509,16, -0,636,1,34,3510, -19,618,1,34,3511, -5,84,1,1377,3512, -16,0,616,1,387, -3513,16,0,616,1, -188,3233,1,380,2968, -1,379,2973,1,377, -2978,1,2792,3514,16, -0,616,1,375,2983, -1,373,2987,1,371, -2991,1,172,3238,1, -67,2997,1,1939,3515, -16,0,616,1,1737, -3516,16,0,616,1, -1341,3517,16,0,616, -1,157,3245,1,480, -3006,1,942,3011,1, -49,3016,1,143,3249, -1,1521,3518,16,0, -616,1,1123,3519,16, -0,616,1,82,3023, -1,2299,3520,16,0, -616,1,328,3029,1, -130,3256,1,1114,3034, -1,1701,3521,16,0, -616,1,1303,3522,16, -0,616,1,118,3262, -1,1096,3042,1,1882, -3523,16,0,616,1, -305,3048,1,107,3052, -1,1485,3524,16,0, -616,1,70,3057,1, -1555,3525,16,0,616, -1,883,3526,16,0, -616,1,93,3063,1, -1665,3527,16,0,616, -1,283,3068,1,479, -3072,1,478,3077,1, -477,3081,1,476,3085, -1,74,3089,1,73, -3528,16,0,616,1, -1449,3529,16,0,616, -1,69,3095,1,68, -3099,1,1840,3530,16, -0,616,1,66,3104, -1,262,3108,1,1267, -3531,16,0,616,1, -1048,3113,1,447,3117, -1,1628,3532,16,0, -616,1,51,3123,1, -63,3127,1,1231,3533, -16,0,616,1,48, -3132,1,47,3136,1, -242,3280,1,44,3138, -1,437,3534,16,0, -616,1,42,3535,16, -0,616,1,525,3145, -1,827,3536,16,0, -616,1,352,3151,1, -1413,3537,16,0,616, -1,1013,3156,1,1012, -3538,16,0,616,1, -223,3292,1,1159,3539, -16,0,616,1,1011, -3164,1,412,3540,16, -0,616,1,1002,3169, -1,1001,3173,1,1591, -3541,16,0,616,1, -1195,3542,16,0,616, -1,40,3179,1,205, -3300,1,50,3181,1, -515,3543,16,0,616, -1,33,3544,19,609, -1,33,3545,5,84, -1,1377,3546,16,0, -607,1,387,3547,16, -0,607,1,188,3233, -1,380,2968,1,379, -2973,1,377,2978,1, -2792,3548,16,0,607, -1,375,2983,1,373, -2987,1,371,2991,1, -172,3238,1,67,2997, -1,1939,3549,16,0, -607,1,1737,3550,16, -0,607,1,1341,3551, -16,0,607,1,157, -3245,1,480,3006,1, -942,3011,1,49,3016, -1,143,3249,1,1521, -3552,16,0,607,1, -1123,3553,16,0,607, -1,82,3023,1,2299, -3554,16,0,607,1, -328,3029,1,130,3256, -1,1114,3034,1,1701, -3555,16,0,607,1, -1303,3556,16,0,607, -1,118,3262,1,1096, -3042,1,1882,3557,16, -0,607,1,305,3048, -1,107,3052,1,1485, -3558,16,0,607,1, -70,3057,1,1555,3559, -16,0,607,1,883, -3560,16,0,607,1, -93,3063,1,1665,3561, -16,0,607,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,3562,16, -0,607,1,1449,3563, -16,0,607,1,69, -3095,1,68,3099,1, -1840,3564,16,0,607, -1,66,3104,1,262, -3108,1,1267,3565,16, -0,607,1,1048,3113, -1,447,3117,1,1628, -3566,16,0,607,1, -51,3123,1,63,3127, -1,1231,3567,16,0, -607,1,48,3132,1, -47,3136,1,242,3280, -1,44,3138,1,437, -3568,16,0,607,1, -42,3569,16,0,607, -1,525,3145,1,827, -3570,16,0,607,1, -352,3151,1,1413,3571, -16,0,607,1,1013, -3156,1,1012,3572,16, -0,607,1,223,3573, -16,0,607,1,1159, -3574,16,0,607,1, -1011,3164,1,412,3575, -16,0,607,1,1002, -3169,1,1001,3173,1, -1591,3576,16,0,607, -1,1195,3577,16,0, -607,1,40,3179,1, -205,3578,16,0,607, -1,50,3181,1,515, -3579,16,0,607,1, -32,3580,19,692,1, -32,3581,5,84,1, -1377,3582,16,0,690, -1,387,3583,16,0, -690,1,188,3233,1, -380,2968,1,379,2973, -1,377,2978,1,2792, -3584,16,0,690,1, -375,2983,1,373,2987, -1,371,2991,1,172, -3238,1,67,2997,1, -1939,3585,16,0,690, -1,1737,3586,16,0, -690,1,1341,3587,16, -0,690,1,157,3588, -16,0,690,1,480, -3006,1,942,3011,1, -49,3016,1,143,3589, -16,0,690,1,1521, -3590,16,0,690,1, -1123,3591,16,0,690, -1,82,3023,1,2299, -3592,16,0,690,1, -328,3029,1,130,3256, -1,1114,3034,1,1701, -3593,16,0,690,1, -1303,3594,16,0,690, -1,118,3262,1,1096, -3042,1,1882,3595,16, -0,690,1,305,3048, -1,107,3052,1,1485, -3596,16,0,690,1, -70,3057,1,1555,3597, -16,0,690,1,883, -3598,16,0,690,1, -93,3063,1,1665,3599, -16,0,690,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,3600,16, -0,690,1,1449,3601, -16,0,690,1,69, -3095,1,68,3099,1, -1840,3602,16,0,690, -1,66,3104,1,262, -3108,1,1267,3603,16, -0,690,1,1048,3113, -1,447,3117,1,1628, -3604,16,0,690,1, -51,3123,1,63,3127, -1,1231,3605,16,0, -690,1,48,3132,1, -47,3136,1,242,3606, -16,0,690,1,44, -3138,1,437,3607,16, -0,690,1,42,3608, -16,0,690,1,525, -3145,1,827,3609,16, -0,690,1,352,3151, -1,1413,3610,16,0, -690,1,1013,3156,1, -1012,3611,16,0,690, -1,223,3612,16,0, -690,1,1159,3613,16, -0,690,1,1011,3164, -1,412,3614,16,0, -690,1,1002,3169,1, -1001,3173,1,1591,3615, -16,0,690,1,1195, -3616,16,0,690,1, -40,3179,1,205,3617, -16,0,690,1,50, -3181,1,515,3618,16, -0,690,1,31,3619, -19,686,1,31,3620, -5,84,1,1377,3621, -16,0,684,1,387, -3622,16,0,684,1, -188,3233,1,380,2968, -1,379,2973,1,377, -2978,1,2792,3623,16, -0,684,1,375,2983, -1,373,2987,1,371, -2991,1,172,3238,1, -67,2997,1,1939,3624, -16,0,684,1,1737, -3625,16,0,684,1, -1341,3626,16,0,684, -1,157,3627,16,0, -684,1,480,3006,1, -942,3011,1,49,3016, -1,143,3628,16,0, -684,1,1521,3629,16, -0,684,1,1123,3630, -16,0,684,1,82, -3023,1,2299,3631,16, -0,684,1,328,3029, -1,130,3256,1,1114, -3034,1,1701,3632,16, -0,684,1,1303,3633, -16,0,684,1,118, -3262,1,1096,3042,1, -1882,3634,16,0,684, -1,305,3048,1,107, -3052,1,1485,3635,16, -0,684,1,70,3057, -1,1555,3636,16,0, -684,1,883,3637,16, -0,684,1,93,3063, -1,1665,3638,16,0, -684,1,283,3068,1, -479,3072,1,478,3077, -1,477,3081,1,476, -3085,1,74,3089,1, -73,3639,16,0,684, -1,1449,3640,16,0, -684,1,69,3095,1, -68,3099,1,1840,3641, -16,0,684,1,66, -3104,1,262,3108,1, -1267,3642,16,0,684, -1,1048,3113,1,447, -3117,1,1628,3643,16, -0,684,1,51,3123, -1,63,3127,1,1231, -3644,16,0,684,1, -48,3132,1,47,3136, -1,242,3645,16,0, -684,1,44,3138,1, -437,3646,16,0,684, -1,42,3647,16,0, -684,1,525,3145,1, -827,3648,16,0,684, -1,352,3151,1,1413, -3649,16,0,684,1, -1013,3156,1,1012,3650, -16,0,684,1,223, -3651,16,0,684,1, -1159,3652,16,0,684, -1,1011,3164,1,412, -3653,16,0,684,1, -1002,3169,1,1001,3173, -1,1591,3654,16,0, -684,1,1195,3655,16, -0,684,1,40,3179, -1,205,3656,16,0, -684,1,50,3181,1, -515,3657,16,0,684, -1,30,3658,19,681, -1,30,3659,5,84, -1,1377,3660,16,0, -679,1,387,3661,16, -0,679,1,188,3233, -1,380,2968,1,379, -2973,1,377,2978,1, -2792,3662,16,0,679, -1,375,2983,1,373, -2987,1,371,2991,1, -172,3238,1,67,2997, -1,1939,3663,16,0, -679,1,1737,3664,16, -0,679,1,1341,3665, -16,0,679,1,157, -3245,1,480,3006,1, -942,3011,1,49,3016, -1,143,3249,1,1521, -3666,16,0,679,1, -1123,3667,16,0,679, -1,82,3023,1,2299, -3668,16,0,679,1, -328,3029,1,130,3256, -1,1114,3034,1,1701, -3669,16,0,679,1, -1303,3670,16,0,679, -1,118,3262,1,1096, -3042,1,1882,3671,16, -0,679,1,305,3048, -1,107,3052,1,1485, -3672,16,0,679,1, -70,3057,1,1555,3673, -16,0,679,1,883, -3674,16,0,679,1, -93,3063,1,1665,3675, -16,0,679,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,3676,16, -0,679,1,1449,3677, -16,0,679,1,69, -3095,1,68,3099,1, -1840,3678,16,0,679, -1,66,3104,1,262, -3108,1,1267,3679,16, -0,679,1,1048,3113, -1,447,3117,1,1628, -3680,16,0,679,1, -51,3123,1,63,3127, -1,1231,3681,16,0, -679,1,48,3132,1, -47,3136,1,242,3682, -16,0,679,1,44, -3138,1,437,3683,16, -0,679,1,42,3684, -16,0,679,1,525, -3145,1,827,3685,16, -0,679,1,352,3151, -1,1413,3686,16,0, -679,1,1013,3156,1, -1012,3687,16,0,679, -1,223,3688,16,0, -679,1,1159,3689,16, -0,679,1,1011,3164, -1,412,3690,16,0, -679,1,1002,3169,1, -1001,3173,1,1591,3691, -16,0,679,1,1195, -3692,16,0,679,1, -40,3179,1,205,3693, -16,0,679,1,50, -3181,1,515,3694,16, -0,679,1,29,3695, -19,253,1,29,3696, -5,84,1,1377,3697, -16,0,251,1,387, -3698,16,0,251,1, -188,3233,1,380,2968, -1,379,2973,1,377, -2978,1,2792,3699,16, -0,251,1,375,2983, -1,373,2987,1,371, -2991,1,172,3238,1, -67,2997,1,1939,3700, -16,0,251,1,1737, -3701,16,0,251,1, -1341,3702,16,0,251, -1,157,3245,1,480, -3006,1,942,3011,1, -49,3016,1,143,3249, -1,1521,3703,16,0, -251,1,1123,3704,16, -0,251,1,82,3023, -1,2299,3705,16,0, -251,1,328,3029,1, -130,3256,1,1114,3034, -1,1701,3706,16,0, -251,1,1303,3707,16, -0,251,1,118,3262, -1,1096,3042,1,1882, -3708,16,0,251,1, -305,3048,1,107,3052, -1,1485,3709,16,0, -251,1,70,3057,1, -1555,3710,16,0,251, -1,883,3711,16,0, -251,1,93,3063,1, -1665,3712,16,0,251, -1,283,3068,1,479, -3072,1,478,3077,1, -477,3081,1,476,3085, -1,74,3089,1,73, -3713,16,0,251,1, -1449,3714,16,0,251, -1,69,3095,1,68, -3099,1,1840,3715,16, -0,251,1,66,3104, -1,262,3108,1,1267, -3716,16,0,251,1, -1048,3113,1,447,3117, -1,1628,3717,16,0, -251,1,51,3123,1, -63,3127,1,1231,3718, -16,0,251,1,48, -3132,1,47,3136,1, -242,3719,16,0,251, -1,44,3138,1,437, -3720,16,0,251,1, -42,3721,16,0,251, -1,525,3145,1,827, -3722,16,0,251,1, -352,3151,1,1413,3723, -16,0,251,1,1013, -3156,1,1012,3724,16, -0,251,1,223,3725, -16,0,251,1,1159, -3726,16,0,251,1, -1011,3164,1,412,3727, -16,0,251,1,1002, -3169,1,1001,3173,1, -1591,3728,16,0,251, -1,1195,3729,16,0, -251,1,40,3179,1, -205,3730,16,0,251, -1,50,3181,1,515, -3731,16,0,251,1, -28,3732,19,488,1, -28,3733,5,60,1, -283,3068,1,69,3095, -1,157,3245,1,352, -3151,1,262,3108,1, -172,3238,1,883,3269, -1,525,3145,1,74, -3089,1,68,3099,1, -70,3057,1,1048,3113, -1,464,3734,17,3735, -15,3736,4,26,37, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,76,0,105, -0,115,0,116,0, -1,-1,1,5,3737, -20,969,1,335,1, -3,1,4,1,3, -3738,22,1,171,1, -67,2997,1,66,3104, -1,242,3280,1,63, -3127,1,328,3029,1, -143,3249,1,41,3739, -17,3740,15,3736,1, --1,1,5,132,1, -0,1,0,3741,22, -1,169,1,942,3011, -1,51,3123,1,50, -3181,1,49,3016,1, -48,3132,1,47,3136, -1,1114,3034,1,223, -3292,1,1002,3169,1, -42,3742,17,3743,15, -3744,4,38,37,0, -69,0,120,0,112, -0,114,0,101,0, -115,0,115,0,105, -0,111,0,110,0, -65,0,114,0,103, -0,117,0,109,0, -101,0,110,0,116, -0,1,-1,1,5, -3745,20,963,1,336, -1,3,1,2,1, -1,3746,22,1,172, -1,130,3256,1,40, -3179,1,305,3048,1, -82,3023,1,481,3747, -17,3748,15,3736,1, --1,1,5,3749,20, -971,1,334,1,3, -1,2,1,1,3750, -22,1,170,1,480, -3006,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,118, -3262,1,1096,3042,1, -205,3300,1,827,3286, -1,380,2968,1,379, -2973,1,1001,3173,1, -377,2978,1,375,2983, -1,107,3052,1,373, -2987,1,461,3751,16, -0,486,1,371,2991, -1,459,3752,17,3753, -15,3736,1,-1,1, -5,132,1,0,1, -0,3741,1,188,3233, -1,1011,3164,1,93, -3063,1,1013,3156,1, -447,3117,1,44,3138, -1,27,3754,19,507, -1,27,3755,5,95, -1,1574,1895,1,2035, -1900,1,1371,3756,16, -0,505,1,71,3757, -16,0,505,1,1958, -3758,16,0,505,1, -381,3759,16,0,505, -1,2106,3760,16,0, -505,1,1931,1909,1, -1756,3761,16,0,505, -1,2031,1915,1,509, -3762,16,0,505,1, -2337,3763,16,0,505, -1,2029,1921,1,1153, -3764,16,0,505,1, -2136,1926,1,1933,3765, -16,0,505,1,2198, -3766,16,0,505,1, -1731,3767,16,0,505, -1,1335,3768,16,0, -505,1,2318,3769,16, -0,505,1,346,3770, -16,0,505,1,182, -3771,16,0,505,1, -137,3772,16,0,505, -1,1515,3773,16,0, -505,1,2105,1940,1, -1775,3774,16,0,505, -1,1117,3775,16,0, -505,1,525,3776,16, -0,505,1,52,3777, -16,0,505,1,1901, -3778,16,0,505,1, -2293,3779,16,0,505, -1,322,3780,16,0, -505,1,124,3781,16, -0,505,1,1695,3782, -16,0,505,1,1297, -3783,16,0,505,1, -151,3784,16,0,505, -1,112,3785,16,0, -505,1,1990,3786,16, -0,505,1,76,3787, -16,0,505,1,43, -3788,16,0,505,1, -2075,3789,16,0,505, -1,1876,3790,16,0, -505,1,299,3791,16, -0,505,1,1479,3792, -16,0,505,1,2462, -1963,1,97,3793,16, -0,505,1,2459,1969, -1,2458,1974,1,2030, -1978,1,89,3794,16, -0,505,1,1860,1983, -1,85,3795,16,0, -505,1,1659,3796,16, -0,505,1,1657,1990, -1,277,3797,16,0, -505,1,1261,3798,16, -0,505,1,166,3799, -16,0,505,1,2045, -1997,1,2043,2001,1, -2041,2005,1,2039,2009, -1,462,3800,16,0, -505,1,2037,2014,1, -459,3801,16,0,505, -1,1443,3802,16,0, -505,1,2033,2020,1, -2032,2024,1,1834,3803, -16,0,505,1,2227, -2029,1,256,3804,16, -0,505,1,447,3805, -16,0,505,1,62, -3806,16,0,505,1, -2021,2036,1,2413,3807, -16,0,505,1,1622, -3808,16,0,505,1, -2464,2042,1,1225,3809, -16,0,505,1,41, -3810,16,0,505,1, -236,3811,16,0,505, -1,431,3812,16,0, -505,1,32,3813,16, -0,505,1,1804,3814, -16,0,505,1,1803, -2052,1,1407,3815,16, -0,505,1,79,3816, -16,0,505,1,217, -3817,16,0,505,1, -1989,2060,1,102,3818, -16,0,505,1,2786, -3819,16,0,505,1, -406,3820,16,0,505, -1,1585,3821,16,0, -505,1,1189,3822,16, -0,505,1,1873,2069, -1,199,3823,16,0, -505,1,2364,2074,1, -26,3824,19,461,1, -26,3825,5,84,1, -1377,3826,16,0,667, -1,387,3827,16,0, -667,1,188,3233,1, -380,2968,1,379,2973, -1,377,2978,1,2792, -3828,16,0,667,1, -375,2983,1,373,2987, -1,371,2991,1,172, -3238,1,67,2997,1, -1939,3829,16,0,667, -1,1737,3830,16,0, -667,1,1341,3831,16, -0,667,1,157,3832, -16,0,667,1,480, -3006,1,942,3011,1, -49,3016,1,143,3833, -16,0,667,1,1521, -3834,16,0,667,1, -1123,3835,16,0,667, -1,82,3023,1,2299, -3836,16,0,667,1, -328,3029,1,130,3256, -1,1114,3034,1,1701, -3837,16,0,667,1, -1303,3838,16,0,667, -1,118,3262,1,1096, -3042,1,1882,3839,16, -0,667,1,305,3048, -1,107,3052,1,1485, -3840,16,0,667,1, -70,3057,1,1555,3841, -16,0,667,1,883, -3842,16,0,667,1, -93,3063,1,1665,3843, -16,0,667,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,3844,16, -0,667,1,1449,3845, -16,0,667,1,69, -3095,1,68,3099,1, -1840,3846,16,0,667, -1,66,3104,1,262, -3108,1,1267,3847,16, -0,667,1,1048,3113, -1,447,3117,1,1628, -3848,16,0,667,1, -51,3123,1,63,3127, -1,1231,3849,16,0, -667,1,48,3132,1, -47,3136,1,242,3850, -16,0,667,1,44, -3138,1,437,3851,16, -0,514,1,42,3852, -16,0,667,1,525, -3145,1,827,3853,16, -0,667,1,352,3151, -1,1413,3854,16,0, -667,1,1013,3156,1, -1012,3855,16,0,667, -1,223,3856,16,0, -667,1,1159,3857,16, -0,667,1,1011,3164, -1,412,3858,16,0, -667,1,1002,3169,1, -1001,3173,1,1591,3859, -16,0,667,1,1195, -3860,16,0,667,1, -40,3179,1,205,3861, -16,0,667,1,50, -3181,1,515,3862,16, -0,459,1,25,3863, -19,537,1,25,3864, -5,177,1,42,3865, -16,0,671,1,412, -3866,16,0,671,1, -1701,3867,16,0,671, -1,406,3868,16,0, -535,1,1267,3869,16, -0,671,1,1695,3870, -16,0,535,1,1261, -3871,16,0,535,1, -827,3872,16,0,671, -1,2031,1915,1,387, -3873,16,0,671,1, -2106,3874,16,0,535, -1,2105,1940,1,380, -2968,1,379,2973,1, -377,2978,1,375,2983, -1,2029,1921,1,373, -2987,1,1665,3875,16, -0,671,1,371,2991, -1,1231,3876,16,0, -671,1,1555,3877,16, -0,671,1,1659,3878, -16,0,535,1,1657, -1990,1,1225,3879,16, -0,535,1,1479,3880, -16,0,535,1,352, -3151,1,2075,3881,16, -0,535,1,346,3882, -16,0,535,1,1628, -3883,16,0,671,1, -1195,3884,16,0,671, -1,1622,3885,16,0, -535,1,328,3029,1, -1189,3886,16,0,535, -1,322,3887,16,0, -535,1,2045,1997,1, -2043,2001,1,2041,2005, -1,2039,2009,1,2037, -2014,1,2035,1900,1, -2464,2042,1,2032,2024, -1,2462,1963,1,2030, -1978,1,305,3048,1, -2459,1969,1,2458,1974, -1,299,3888,16,0, -535,1,1591,3889,16, -0,671,1,1159,3890, -16,0,671,1,1585, -3891,16,0,535,1, -1153,3892,16,0,535, -1,2136,1926,1,66, -3104,1,283,3068,1, -1574,1895,1,277,3893, -16,0,535,1,1377, -3894,16,0,671,1, -32,3895,16,0,535, -1,49,3016,1,1990, -3896,16,0,535,1, -1989,2060,1,262,3108, -1,1123,3897,16,0, -671,1,2413,3898,16, -0,535,1,256,3899, -16,0,535,1,1117, -3900,16,0,535,1, -1114,3034,1,242,3901, -16,0,671,1,1933, -3902,16,0,535,1, -236,3903,16,0,535, -1,1096,3042,1,1521, -3904,16,0,671,1, -223,3905,16,0,671, -1,1515,3906,16,0, -535,1,217,3907,16, -0,535,1,1939,3908, -16,0,671,1,70, -3057,1,2364,2074,1, -1931,1909,1,2792,3909, -16,0,671,1,205, -3910,16,0,671,1, -2786,3911,16,0,535, -1,199,3912,16,0, -535,1,942,3011,1, -1485,3913,16,0,671, -1,188,3233,1,1048, -3113,1,182,3914,16, -0,535,1,1901,3915, -16,0,535,1,172, -3238,1,2021,2036,1, -48,3132,1,166,3916, -16,0,535,1,2318, -3917,16,0,535,1, -381,3918,16,0,535, -1,1882,3919,16,0, -671,1,157,3920,16, -0,671,1,1449,3921, -16,0,671,1,1876, -3922,16,0,535,1, -151,3923,16,0,535, -1,1012,3924,16,0, -671,1,2337,3925,16, -0,535,1,2299,3926, -16,0,671,1,143, -3927,16,0,671,1, -1002,3169,1,1001,3173, -1,2293,3928,16,0, -535,1,137,3929,16, -0,535,1,1860,1983, -1,130,3256,1,79, -3930,16,0,535,1, -124,3931,16,0,535, -1,1443,3932,16,0, -535,1,1011,3164,1, -1413,3933,16,0,671, -1,118,3262,1,1840, -3934,16,0,671,1, -1407,3935,16,0,535, -1,112,3936,16,0, -535,1,1834,3937,16, -0,535,1,1958,3938, -16,0,535,1,107, -3052,1,2033,2020,1, -97,3939,16,0,535, -1,1873,2069,1,525, -3940,16,0,535,1, -93,3063,1,1371,3941, -16,0,535,1,89, -3942,16,0,535,1, -43,3943,16,0,535, -1,85,3944,16,0, -535,1,515,3945,16, -0,671,1,82,3023, -1,1804,3946,16,0, -535,1,1803,2052,1, -509,3947,16,0,535, -1,76,3948,16,0, -535,1,74,3089,1, -73,3949,16,0,671, -1,2227,2029,1,71, -3950,16,0,535,1, -1013,3156,1,69,3095, -1,68,3099,1,67, -2997,1,102,3951,16, -0,535,1,47,3136, -1,63,3127,1,62, -3952,16,0,535,1, -52,3953,16,0,535, -1,1775,3954,16,0, -535,1,50,3181,1, -480,3006,1,479,3072, -1,478,3077,1,477, -3081,1,476,3085,1, -44,3138,1,2198,3955, -16,0,535,1,1335, -3956,16,0,535,1, -41,3957,16,0,535, -1,40,3179,1,1341, -3958,16,0,671,1, -51,3123,1,1756,3959, -16,0,535,1,462, -3960,16,0,535,1, -459,3961,16,0,535, -1,883,3962,16,0, -671,1,447,3963,16, -0,535,1,1737,3964, -16,0,671,1,1303, -3965,16,0,671,1, -1731,3966,16,0,535, -1,437,3967,16,0, -671,1,1297,3968,16, -0,535,1,431,3969, -16,0,535,1,24, -3970,19,435,1,24, -3971,5,5,1,377, -3972,16,0,455,1, -44,3973,16,0,753, -1,373,3974,16,0, -548,1,40,3975,16, -0,433,1,63,3976, -16,0,740,1,23, -3977,19,658,1,23, -3978,5,38,1,2045, -1997,1,2043,2001,1, -1775,3979,16,0,656, -1,2041,2005,1,2039, -2009,1,1860,1983,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2031,1915,1, -2030,1978,1,2029,1921, -1,2106,3980,16,0, -656,1,2464,2042,1, -1931,1909,1,1574,1895, -1,2462,1963,1,2105, -1940,1,2459,1969,1, -2458,1974,1,2364,2074, -1,1958,3981,16,0, -656,1,2198,3982,16, -0,656,1,2021,2036, -1,1901,3983,16,0, -656,1,1989,2060,1, -1803,2052,1,2075,3984, -16,0,656,1,1990, -3985,16,0,656,1, -1804,3986,16,0,656, -1,2337,3987,16,0, -656,1,1657,1990,1, -2413,3988,16,0,656, -1,32,3989,16,0, -656,1,1873,2069,1, -2227,2029,1,2136,1926, -1,22,3990,19,603, -1,22,3991,5,84, -1,1377,3992,16,0, -601,1,387,3993,16, -0,601,1,188,3994, -16,0,601,1,380, -2968,1,379,2973,1, -377,2978,1,2792,3995, -16,0,601,1,375, -2983,1,373,2987,1, -371,2991,1,172,3996, -16,0,601,1,67, -2997,1,1939,3997,16, -0,601,1,1737,3998, -16,0,601,1,1341, -3999,16,0,601,1, -157,4000,16,0,601, -1,480,3006,1,942, -4001,16,0,601,1, -49,3016,1,143,4002, -16,0,601,1,1521, -4003,16,0,601,1, -1123,4004,16,0,601, -1,82,3023,1,2299, -4005,16,0,601,1, -328,4006,16,0,601, -1,130,4007,16,0, -601,1,1114,3034,1, -1701,4008,16,0,601, -1,1303,4009,16,0, -601,1,118,4010,16, -0,601,1,1096,3042, -1,1882,4011,16,0, -601,1,305,3048,1, -107,3052,1,1485,4012, -16,0,601,1,70, -3057,1,1555,4013,16, -0,601,1,883,4014, -16,0,601,1,93, -3063,1,1665,4015,16, -0,601,1,283,3068, -1,479,3072,1,478, -3077,1,477,3081,1, -476,3085,1,74,3089, -1,73,4016,16,0, -601,1,1449,4017,16, -0,601,1,69,3095, -1,68,3099,1,1840, -4018,16,0,601,1, -66,3104,1,262,3108, -1,1267,4019,16,0, -601,1,1048,4020,16, -0,601,1,447,3117, -1,1628,4021,16,0, -601,1,51,3123,1, -63,3127,1,1231,4022, -16,0,601,1,48, -3132,1,47,3136,1, -242,4023,16,0,601, -1,44,3138,1,437, -4024,16,0,601,1, -42,4025,16,0,601, -1,525,3145,1,827, -4026,16,0,601,1, -352,4027,16,0,601, -1,1413,4028,16,0, -601,1,1013,3156,1, -1012,4029,16,0,601, -1,223,4030,16,0, -601,1,1159,4031,16, -0,601,1,1011,3164, -1,412,4032,16,0, -601,1,1002,3169,1, -1001,3173,1,1591,4033, -16,0,601,1,1195, -4034,16,0,601,1, -40,3179,1,205,4035, -16,0,601,1,50, -3181,1,515,4036,16, -0,601,1,21,4037, -19,588,1,21,4038, -5,84,1,1377,4039, -16,0,586,1,387, -4040,16,0,586,1, -188,4041,16,0,586, -1,380,2968,1,379, -2973,1,377,2978,1, -2792,4042,16,0,586, -1,375,2983,1,373, -2987,1,371,2991,1, -172,4043,16,0,586, -1,67,2997,1,1939, -4044,16,0,586,1, -1737,4045,16,0,586, -1,1341,4046,16,0, -586,1,157,4047,16, -0,586,1,480,3006, -1,942,4048,16,0, -586,1,49,3016,1, -143,4049,16,0,586, -1,1521,4050,16,0, -586,1,1123,4051,16, -0,586,1,82,3023, -1,2299,4052,16,0, -586,1,328,4053,16, -0,586,1,130,4054, -16,0,586,1,1114, -3034,1,1701,4055,16, -0,586,1,1303,4056, -16,0,586,1,118, -4057,16,0,586,1, -1096,3042,1,1882,4058, -16,0,586,1,305, -3048,1,107,3052,1, -1485,4059,16,0,586, -1,70,3057,1,1555, -4060,16,0,586,1, -883,4061,16,0,586, -1,93,3063,1,1665, -4062,16,0,586,1, -283,3068,1,479,3072, -1,478,3077,1,477, -3081,1,476,3085,1, -74,3089,1,73,4063, -16,0,586,1,1449, -4064,16,0,586,1, -69,3095,1,68,3099, -1,1840,4065,16,0, -586,1,66,3104,1, -262,3108,1,1267,4066, -16,0,586,1,1048, -4067,16,0,586,1, -447,3117,1,1628,4068, -16,0,586,1,51, -3123,1,63,3127,1, -1231,4069,16,0,586, -1,48,3132,1,47, -3136,1,242,4070,16, -0,586,1,44,3138, -1,437,4071,16,0, -586,1,42,4072,16, -0,586,1,525,3145, -1,827,4073,16,0, -586,1,352,4074,16, -0,586,1,1413,4075, -16,0,586,1,1013, -3156,1,1012,4076,16, -0,586,1,223,4077, -16,0,586,1,1159, -4078,16,0,586,1, -1011,3164,1,412,4079, -16,0,586,1,1002, -3169,1,1001,3173,1, -1591,4080,16,0,586, -1,1195,4081,16,0, -586,1,40,3179,1, -205,4082,16,0,586, -1,50,3181,1,515, -4083,16,0,586,1, -20,4084,19,580,1, -20,4085,5,84,1, -1377,4086,16,0,578, -1,387,4087,16,0, -578,1,188,4088,16, -0,578,1,380,2968, -1,379,2973,1,377, -2978,1,2792,4089,16, -0,578,1,375,2983, -1,373,2987,1,371, -2991,1,172,4090,16, -0,578,1,67,2997, -1,1939,4091,16,0, -578,1,1737,4092,16, -0,578,1,1341,4093, -16,0,578,1,157, -4094,16,0,578,1, -480,3006,1,942,4095, -16,0,578,1,49, -3016,1,143,4096,16, -0,578,1,1521,4097, -16,0,578,1,1123, -4098,16,0,578,1, -82,3023,1,2299,4099, -16,0,578,1,328, -4100,16,0,578,1, -130,4101,16,0,578, -1,1114,3034,1,1701, -4102,16,0,578,1, -1303,4103,16,0,578, -1,118,4104,16,0, -578,1,1096,3042,1, -1882,4105,16,0,578, -1,305,3048,1,107, -3052,1,1485,4106,16, -0,578,1,70,3057, -1,1555,4107,16,0, -578,1,883,4108,16, -0,578,1,93,3063, -1,1665,4109,16,0, -578,1,283,3068,1, -479,3072,1,478,3077, -1,477,3081,1,476, -3085,1,74,3089,1, -73,4110,16,0,578, -1,1449,4111,16,0, -578,1,69,3095,1, -68,3099,1,1840,4112, -16,0,578,1,66, -3104,1,262,3108,1, -1267,4113,16,0,578, -1,1048,4114,16,0, -578,1,447,3117,1, -1628,4115,16,0,578, -1,51,3123,1,63, -3127,1,1231,4116,16, -0,578,1,48,3132, -1,47,3136,1,242, -4117,16,0,578,1, -44,3138,1,437,4118, -16,0,578,1,42, -4119,16,0,578,1, -525,3145,1,827,4120, -16,0,578,1,352, -4121,16,0,578,1, -1413,4122,16,0,578, -1,1013,3156,1,1012, -4123,16,0,578,1, -223,4124,16,0,578, -1,1159,4125,16,0, -578,1,1011,3164,1, -412,4126,16,0,578, -1,1002,3169,1,1001, -3173,1,1591,4127,16, -0,578,1,1195,4128, -16,0,578,1,40, -3179,1,205,4129,16, -0,578,1,50,3181, -1,515,4130,16,0, -578,1,19,4131,19, -569,1,19,4132,5, -176,1,42,4133,16, -0,567,1,412,4134, -16,0,567,1,1701, -4135,16,0,567,1, -406,4136,16,0,709, -1,1267,4137,16,0, -567,1,1695,4138,16, -0,709,1,1261,4139, -16,0,709,1,827, -4140,16,0,567,1, -2031,1915,1,387,4141, -16,0,567,1,2106, -4142,16,0,709,1, -2105,1940,1,380,2968, -1,379,2973,1,377, -2978,1,375,2983,1, -2029,1921,1,373,2987, -1,1665,4143,16,0, -567,1,371,2991,1, -1231,4144,16,0,567, -1,1555,4145,16,0, -567,1,1659,4146,16, -0,709,1,1657,1990, -1,1225,4147,16,0, -709,1,1479,4148,16, -0,709,1,352,3151, -1,2075,4149,16,0, -709,1,346,4150,16, -0,709,1,1628,4151, -16,0,567,1,1195, -4152,16,0,567,1, -1622,4153,16,0,709, -1,328,3029,1,1189, -4154,16,0,709,1, -322,4155,16,0,709, -1,2045,1997,1,2043, -2001,1,2041,2005,1, -2039,2009,1,2037,2014, -1,2035,1900,1,2464, -2042,1,2032,2024,1, -2462,1963,1,2030,1978, -1,305,3048,1,2459, -1969,1,2458,1974,1, -299,4156,16,0,709, -1,1591,4157,16,0, -567,1,1159,4158,16, -0,567,1,1585,4159, -16,0,709,1,1153, -4160,16,0,709,1, -2136,1926,1,66,3104, -1,283,3068,1,1574, -1895,1,277,4161,16, -0,709,1,1377,4162, -16,0,567,1,32, -4163,16,0,709,1, -49,3016,1,1990,4164, -16,0,709,1,1989, -2060,1,262,3108,1, -1123,4165,16,0,567, -1,2413,4166,16,0, -709,1,256,4167,16, -0,709,1,1117,4168, -16,0,709,1,1114, -3034,1,242,4169,16, -0,567,1,1933,4170, -16,0,709,1,236, -4171,16,0,709,1, -1096,3042,1,1521,4172, -16,0,567,1,223, -4173,16,0,567,1, -1515,4174,16,0,709, -1,217,4175,16,0, -709,1,1939,4176,16, -0,567,1,70,3057, -1,2364,2074,1,1931, -1909,1,2792,4177,16, -0,567,1,205,4178, -16,0,567,1,2786, -4179,16,0,709,1, -199,4180,16,0,709, -1,942,4181,16,0, -567,1,1485,4182,16, -0,567,1,188,4183, -16,0,567,1,1048, -4184,16,0,567,1, -182,4185,16,0,709, -1,1901,4186,16,0, -709,1,172,4187,16, -0,567,1,2021,2036, -1,48,3132,1,166, -4188,16,0,709,1, -2318,4189,16,0,709, -1,381,4190,16,0, -709,1,1882,4191,16, -0,567,1,157,4192, -16,0,567,1,1449, -4193,16,0,567,1, -1876,4194,16,0,709, -1,151,4195,16,0, -709,1,1012,4196,16, -0,567,1,2337,4197, -16,0,709,1,2299, -4198,16,0,567,1, -143,4199,16,0,567, -1,1002,3169,1,1001, -3173,1,2293,4200,16, -0,709,1,137,4201, -16,0,709,1,1860, -1983,1,130,4202,16, -0,567,1,79,4203, -16,0,709,1,124, -4204,16,0,709,1, -1443,4205,16,0,709, -1,1011,3164,1,1413, -4206,16,0,567,1, -118,4207,16,0,567, -1,1840,4208,16,0, -567,1,1407,4209,16, -0,709,1,112,4210, -16,0,709,1,1834, -4211,16,0,709,1, -1958,4212,16,0,709, -1,107,3052,1,2033, -2020,1,97,4213,16, -0,709,1,1873,2069, -1,525,4214,16,0, -709,1,93,3063,1, -1371,4215,16,0,709, -1,89,4216,16,0, -709,1,43,4217,16, -0,709,1,85,4218, -16,0,709,1,515, -4219,16,0,567,1, -82,3023,1,1804,4220, -16,0,709,1,1803, -2052,1,509,4221,16, -0,709,1,76,4222, -16,0,709,1,74, -3089,1,73,4223,16, -0,567,1,2227,2029, -1,71,4224,16,0, -709,1,1013,3156,1, -69,3095,1,68,3099, -1,67,2997,1,102, -4225,16,0,709,1, -47,3136,1,63,3127, -1,52,4226,16,0, -709,1,1775,4227,16, -0,709,1,50,3181, -1,480,3006,1,479, -3072,1,478,3077,1, -477,3081,1,476,3085, -1,44,3138,1,2198, -4228,16,0,709,1, -1335,4229,16,0,709, -1,41,4230,16,0, -709,1,40,3179,1, -1341,4231,16,0,567, -1,51,3123,1,1756, -4232,16,0,709,1, -462,4233,16,0,709, -1,459,4234,16,0, -709,1,883,4235,16, -0,567,1,447,4236, -16,0,709,1,1737, -4237,16,0,567,1, -1303,4238,16,0,567, -1,1731,4239,16,0, -709,1,437,4240,16, -0,567,1,1297,4241, -16,0,709,1,431, -4242,16,0,709,1, -18,4243,19,563,1, -18,4244,5,84,1, -1377,4245,16,0,561, -1,387,4246,16,0, -561,1,188,4247,16, -0,561,1,380,2968, -1,379,2973,1,377, -2978,1,2792,4248,16, -0,561,1,375,2983, -1,373,2987,1,371, -2991,1,172,4249,16, -0,561,1,67,2997, -1,1939,4250,16,0, -561,1,1737,4251,16, -0,561,1,1341,4252, -16,0,561,1,157, -4253,16,0,561,1, -480,3006,1,942,4254, -16,0,561,1,49, -3016,1,143,4255,16, -0,561,1,1521,4256, -16,0,561,1,1123, -4257,16,0,561,1, -82,3023,1,2299,4258, -16,0,561,1,328, -3029,1,130,4259,16, -0,561,1,1114,3034, -1,1701,4260,16,0, -561,1,1303,4261,16, -0,561,1,118,4262, -16,0,561,1,1096, -3042,1,1882,4263,16, -0,561,1,305,3048, -1,107,3052,1,1485, -4264,16,0,561,1, -70,3057,1,1555,4265, -16,0,561,1,883, -4266,16,0,561,1, -93,3063,1,1665,4267, -16,0,561,1,283, -3068,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,74, -3089,1,73,4268,16, -0,561,1,1449,4269, -16,0,561,1,69, -3095,1,68,3099,1, -1840,4270,16,0,561, -1,66,3104,1,262, -3108,1,1267,4271,16, -0,561,1,1048,4272, -16,0,561,1,447, -3117,1,1628,4273,16, -0,561,1,51,3123, -1,63,3127,1,1231, -4274,16,0,561,1, -48,3132,1,47,3136, -1,242,4275,16,0, -561,1,44,3138,1, -437,4276,16,0,561, -1,42,4277,16,0, -561,1,525,3145,1, -827,4278,16,0,561, -1,352,3151,1,1413, -4279,16,0,561,1, -1013,3156,1,1012,4280, -16,0,561,1,223, -4281,16,0,561,1, -1159,4282,16,0,561, -1,1011,3164,1,412, -4283,16,0,561,1, -1002,3169,1,1001,3173, -1,1591,4284,16,0, -561,1,1195,4285,16, -0,561,1,40,3179, -1,205,4286,16,0, -561,1,50,3181,1, -515,4287,16,0,561, -1,17,4288,19,139, -1,17,4289,5,134, -1,2281,4290,17,4291, -15,4292,4,34,37, -0,70,0,111,0, -114,0,76,0,111, -0,111,0,112,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,-1, -1,5,4293,20,1403, -1,251,1,3,1, -2,1,1,4294,22, -1,86,1,1377,4295, -17,4296,15,4297,4, -34,37,0,83,0, -105,0,109,0,112, -0,108,0,101,0, -65,0,115,0,115, -0,105,0,103,0, -110,0,109,0,101, -0,110,0,116,0, -1,-1,1,5,4298, -20,1369,1,260,1, -3,1,4,1,3, -4299,22,1,95,1, -67,2997,1,2556,4300, -16,0,243,1,2555, -4301,17,4302,15,4303, -4,60,37,0,86, -0,101,0,99,0, -116,0,111,0,114, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,-1,1, -5,4304,20,1659,1, -209,1,3,1,2, -1,1,4305,22,1, -44,1,1370,4306,17, -4307,15,4297,1,-1, -1,5,4308,20,1343, -1,273,1,3,1, -4,1,3,4309,22, -1,108,1,2548,4310, -16,0,257,1,380, -2968,1,379,2973,1, -377,2978,1,2543,4311, -17,4312,15,4313,4, -30,37,0,82,0, -111,0,116,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,1,-1,1,5, -4314,20,1603,1,217, -1,3,1,3,1, -2,4315,22,1,52, -1,2547,4316,17,4317, -15,4318,4,66,37, -0,73,0,110,0, -116,0,82,0,111, -0,116,0,82,0, -111,0,116,0,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -1,-1,1,5,4319, -20,1655,1,210,1, -3,1,6,1,5, -4320,22,1,45,1, -373,2987,1,371,2991, -1,172,3238,1,1550, -4321,17,4322,15,4297, -1,-1,1,5,4323, -20,1353,1,268,1, -3,1,4,1,3, -4324,22,1,103,1, -2533,4325,16,0,282, -1,2335,4326,16,0, -475,1,1152,4327,17, -4328,15,4297,1,-1, -1,5,4329,20,1299, -1,279,1,3,1, -6,1,5,4330,22, -1,114,1,1939,4331, -16,0,688,1,2528, -4332,17,4333,15,4334, -4,30,37,0,86, -0,101,0,99,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,1,-1,1, -5,4335,20,1608,1, -216,1,3,1,3, -1,2,4336,22,1, -51,1,1341,4337,17, -4338,15,4297,1,-1, -1,5,4339,20,1367, -1,261,1,3,1, -4,1,3,4340,22, -1,96,1,157,3245, -1,42,3742,1,352, -3151,1,2518,4341,16, -0,300,1,2517,4342, -17,4343,15,4344,4, -66,37,0,75,0, -101,0,121,0,73, -0,110,0,116,0, -73,0,110,0,116, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,-1,1, -5,4345,20,1647,1, -212,1,3,1,6, -1,5,4346,22,1, -47,1,1332,4347,17, -4348,15,4297,1,-1, -1,5,4349,20,1341, -1,274,1,3,1, -6,1,5,4350,22, -1,109,1,2513,4351, -17,4352,15,4353,4, -30,37,0,73,0, -110,0,116,0,68, -0,101,0,99,0, -108,0,97,0,114, -0,97,0,116,0, -105,0,111,0,110, -0,1,-1,1,5, -4354,20,1614,1,215, -1,3,1,3,1, -2,4355,22,1,50, -1,2509,4356,17,4357, -15,4358,4,30,37, -0,75,0,101,0, -121,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,1, --1,1,5,4359,20, -1622,1,214,1,3, -1,3,1,2,4360, -22,1,49,1,1001, -3173,1,1521,4361,17, -4362,15,4297,1,-1, -1,5,4363,20,1377, -1,256,1,3,1, -4,1,3,4364,22, -1,91,1,188,3233, -1,1123,4365,17,4366, -15,4297,1,-1,1, -5,4367,20,1355,1, -267,1,3,1,6, -1,5,4368,22,1, -102,1,328,3029,1, -1514,4369,17,4370,15, -4297,1,-1,1,5, -4371,20,1351,1,269, -1,3,1,4,1, -3,4372,22,1,104, -1,10,4373,17,4374, -15,4375,4,48,37, -0,65,0,114,0, -103,0,117,0,109, -0,101,0,110,0, -116,0,68,0,101, -0,99,0,108,0, -97,0,114,0,97, -0,116,0,105,0, -111,0,110,0,76, -0,105,0,115,0, -116,0,1,-1,1, -5,205,1,0,1, -0,4376,22,1,39, -1,82,3023,1,525, -3145,1,130,3256,1, -1114,3034,1,7,2314, -1,1701,4377,17,4378, -15,4292,1,-1,1, -5,4379,20,1401,1, -252,1,3,1,4, -1,3,4380,22,1, -87,1,1012,4381,16, -0,705,1,942,3011, -1,1303,4382,17,4383, -15,4297,1,-1,1, -5,4384,20,1365,1, -262,1,3,1,6, -1,5,4385,22,1, -97,1,2532,4386,17, -4387,15,4388,4,66, -37,0,73,0,110, -0,116,0,86,0, -101,0,99,0,86, -0,101,0,99,0, -65,0,114,0,103, -0,117,0,109,0, -101,0,110,0,116, -0,68,0,101,0, -99,0,108,0,97, -0,114,0,97,0, -116,0,105,0,111, -0,110,0,76,0, -105,0,115,0,116, -0,1,-1,1,5, -4389,20,1651,1,211, -1,3,1,6,1, -5,4390,22,1,46, -1,118,3262,1,1010, -4391,16,0,707,1, -1296,4392,17,4393,15, -4297,1,-1,1,5, -4394,20,1339,1,275, -1,3,1,6,1, -5,4395,22,1,110, -1,68,3099,1,1096, -3042,1,1,2367,1, -1094,4396,16,0,668, -1,305,3048,1,107, -3052,1,1485,4397,17, -4398,15,4297,1,-1, -1,5,4399,20,1375, -1,257,1,3,1, -4,1,3,4400,22, -1,92,1,2074,4401, -16,0,606,1,2467, -4402,17,4403,15,4375, -1,-1,1,5,4404, -20,1673,1,205,1, -3,1,2,1,1, -4405,22,1,40,1, -49,3016,1,6,2350, -1,70,3057,1,1478, -4406,17,4407,15,4297, -1,-1,1,5,4408, -20,1349,1,270,1, -3,1,4,1,3, -4409,22,1,105,1, -1871,4410,16,0,765, -1,143,3249,1,883, -3269,1,93,3063,1, -1665,4411,17,4412,15, -4292,1,-1,1,5, -4413,20,1405,1,250, -1,3,1,2,1, -1,4414,22,1,85, -1,481,3747,1,480, -3006,1,479,3072,1, -478,3077,1,477,3081, -1,476,3085,1,20, -4415,16,0,768,1, -1260,4416,17,4417,15, -4297,1,-1,1,5, -4418,20,1337,1,276, -1,3,1,6,1, -5,4419,22,1,111, -1,375,2983,1,74, -3089,1,73,4420,16, -0,731,1,1048,3113, -1,1882,4421,16,0, -628,1,464,3734,1, -69,3095,1,262,3108, -1,1840,4422,16,0, -723,1,66,3104,1, -459,3752,1,1267,4423, -17,4424,15,4297,1, --1,1,5,4425,20, -1363,1,263,1,3, -1,6,1,5,4426, -22,1,98,1,1442, -4427,17,4428,15,4297, -1,-1,1,5,4429, -20,1347,1,271,1, -3,1,4,1,3, -4430,22,1,106,1, -61,4431,16,0,742, -1,2197,4432,16,0, -557,1,447,3117,1, -1730,4433,17,4434,15, -4292,1,-1,1,5, -4435,20,1395,1,253, -1,3,1,4,1, -3,4436,22,1,88, -1,51,3123,1,63, -3127,1,1231,4437,17, -4438,15,4297,1,-1, -1,5,4439,20,1361, -1,264,1,3,1, -6,1,5,4440,22, -1,99,1,48,3132, -1,47,3136,1,242, -3280,1,44,3138,1, -4,2358,1,1224,4441, -17,4442,15,4297,1, --1,1,5,4443,20, -1335,1,277,1,3, -1,6,1,5,4444, -22,1,112,1,41, -3739,1,40,3179,1, -827,3286,1,1413,4445, -17,4446,15,4297,1, --1,1,5,4447,20, -1371,1,259,1,3, -1,4,1,3,4448, -22,1,94,1,2591, -4449,16,0,203,1, -2779,4450,16,0,773, -1,1013,3156,1,1406, -4451,17,4452,15,4297, -1,-1,1,5,4453, -20,1345,1,272,1, -3,1,4,1,3, -4454,22,1,107,1, -223,3292,1,1159,4455, -17,4456,15,4297,1, --1,1,5,4457,20, -1357,1,266,1,3, -1,6,1,5,4458, -22,1,101,1,2, -2336,1,3,2362,1, -2582,4459,17,4460,15, -4375,1,-1,1,5, -205,1,0,1,0, -4376,1,283,3068,1, -19,4461,17,4462,15, -4463,4,24,37,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,1,-1,1, -5,4464,20,1627,1, -213,1,3,1,3, -1,2,4465,22,1, -48,1,1002,3169,1, -2577,4466,16,0,733, -1,30,4467,17,4468, -15,4375,1,-1,1, -5,4469,20,1671,1, -206,1,3,1,4, -1,3,4470,22,1, -41,1,1195,4471,17, -4472,15,4297,1,-1, -1,5,4473,20,1359, -1,265,1,3,1, -6,1,5,4474,22, -1,100,1,2770,4475, -17,4476,15,4375,1, --1,1,5,205,1, -0,1,0,4376,1, -2572,4477,16,0,219, -1,2571,4478,17,4479, -15,4480,4,54,37, -0,75,0,101,0, -121,0,65,0,114, -0,103,0,117,0, -109,0,101,0,110, -0,116,0,68,0, -101,0,99,0,108, -0,97,0,114,0, -97,0,116,0,105, -0,111,0,110,0, -76,0,105,0,115, -0,116,0,1,-1, -1,5,4481,20,1667, -1,207,1,3,1, -2,1,1,4482,22, -1,42,1,9,4483, -17,4462,1,2,4465, -1,205,3300,1,1449, -4484,17,4485,15,4297, -1,-1,1,5,4486, -20,1373,1,258,1, -3,1,4,1,3, -4487,22,1,93,1, -1188,4488,17,4489,15, -4297,1,-1,1,5, -4490,20,1333,1,278, -1,3,1,6,1, -5,4491,22,1,113, -1,5,2354,1,50, -3181,1,2564,4492,16, -0,231,1,2563,4493, -17,4494,15,4495,4, -54,37,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -117,0,109,0,101, -0,110,0,116,0, -68,0,101,0,99, -0,108,0,97,0, -114,0,97,0,116, -0,105,0,111,0, -110,0,76,0,105, -0,115,0,116,0, -1,-1,1,5,4496, -20,1663,1,208,1, -3,1,2,1,1, -4497,22,1,43,1, -1011,3164,1,1773,4498, -16,0,137,1,16, -4499,19,117,1,16, -4500,5,147,1,2581, -4501,16,0,208,1, -2576,4502,16,0,195, -1,2568,4503,16,0, -226,1,2136,1926,1, -2474,4504,17,4505,15, -4506,4,30,37,0, -86,0,101,0,99, -0,116,0,111,0, -114,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,1,-1, -1,5,4507,20,841, -1,375,1,3,1, -2,1,1,4508,22, -1,211,1,406,4509, -16,0,747,1,2560, -4510,16,0,238,1, -1695,4511,16,0,747, -1,1261,4512,16,0, -747,1,2552,4513,16, -0,439,1,2476,4514, -17,4515,15,4506,1, --1,1,5,4516,20, -850,1,373,1,3, -1,2,1,1,4517, -22,1,209,1,2537, -4518,16,0,277,1, -2105,1940,1,381,4519, -16,0,747,1,2031, -1915,1,2522,4520,16, -0,295,1,1659,4521, -16,0,747,1,1658, -4522,16,0,213,1, -1657,1990,1,1225,4523, -16,0,747,1,151, -4524,16,0,747,1, -2075,4525,16,0,747, -1,2505,4526,17,4527, -15,4528,4,12,37, -0,69,0,118,0, -101,0,110,0,116, -0,1,-1,1,5, -4529,20,928,1,344, -1,3,1,2,1, -1,4530,22,1,180, -1,2504,4531,17,4532, -15,4528,1,-1,1, -5,4533,20,926,1, -345,1,3,1,2, -1,1,4534,22,1, -181,1,2503,4535,17, -4536,15,4528,1,-1, -1,5,4537,20,924, -1,346,1,3,1, -2,1,1,4538,22, -1,182,1,2502,4539, -17,4540,15,4528,1, --1,1,5,4541,20, -922,1,347,1,3, -1,2,1,1,4542, -22,1,183,1,2501, -4543,17,4544,15,4528, -1,-1,1,5,4545, -20,920,1,348,1, -3,1,2,1,1, -4546,22,1,184,1, -2500,4547,17,4548,15, -4528,1,-1,1,5, -4549,20,918,1,349, -1,3,1,2,1, -1,4550,22,1,185, -1,2499,4551,17,4552, -15,4528,1,-1,1, -5,4553,20,916,1, -350,1,3,1,2, -1,1,4554,22,1, -186,1,2498,4555,17, -4556,15,4528,1,-1, -1,5,4557,20,914, -1,351,1,3,1, -2,1,1,4558,22, -1,187,1,2497,4559, -17,4560,15,4528,1, --1,1,5,4561,20, -907,1,352,1,3, -1,2,1,1,4562, -22,1,188,1,2496, -4563,17,4564,15,4565, -4,26,37,0,86, -0,111,0,105,0, -100,0,65,0,114, -0,103,0,69,0, -118,0,101,0,110, -0,116,0,1,-1, -1,5,4566,20,905, -1,353,1,3,1, -2,1,1,4567,22, -1,189,1,2495,4568, -17,4569,15,4565,1, --1,1,5,4570,20, -903,1,354,1,3, -1,2,1,1,4571, -22,1,190,1,2494, -4572,17,4573,15,4565, -1,-1,1,5,4574, -20,901,1,355,1, -3,1,2,1,1, -4575,22,1,191,1, -2493,4576,17,4577,15, -4565,1,-1,1,5, -4578,20,899,1,356, -1,3,1,2,1, -1,4579,22,1,192, -1,2492,4580,17,4581, -15,4565,1,-1,1, -5,4582,20,897,1, -357,1,3,1,2, -1,1,4583,22,1, -193,1,2491,4584,17, -4585,15,4565,1,-1, -1,5,4586,20,895, -1,358,1,3,1, -2,1,1,4587,22, -1,194,1,2490,4588, -17,4589,15,4565,1, --1,1,5,4590,20, -893,1,359,1,3, -1,2,1,1,4591, -22,1,195,1,2489, -4592,17,4593,15,4565, -1,-1,1,5,4594, -20,886,1,360,1, -3,1,2,1,1, -4595,22,1,196,1, -2488,4596,17,4597,15, -4598,4,24,37,0, -75,0,101,0,121, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,1,-1,1, -5,4599,20,884,1, -361,1,3,1,2, -1,1,4600,22,1, -197,1,2487,4601,17, -4602,15,4598,1,-1, -1,5,4603,20,877, -1,362,1,3,1, -2,1,1,4604,22, -1,198,1,2486,4605, -17,4606,15,4607,4, -24,37,0,73,0, -110,0,116,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -1,-1,1,5,4608, -20,875,1,363,1, -3,1,2,1,1, -4609,22,1,199,1, -2485,4610,17,4611,15, -4607,1,-1,1,5, -4612,20,873,1,364, -1,3,1,2,1, -1,4613,22,1,200, -1,1622,4614,16,0, -747,1,2483,4615,17, -4616,15,4607,1,-1, -1,5,4617,20,869, -1,366,1,3,1, -2,1,1,4618,22, -1,202,1,2482,4619, -17,4620,15,4607,1, --1,1,5,4621,20, -867,1,367,1,3, -1,2,1,1,4622, -22,1,203,1,2481, -4623,17,4624,15,4607, -1,-1,1,5,4625, -20,865,1,368,1, -3,1,2,1,1, -4626,22,1,204,1, -2480,4627,17,4628,15, -4607,1,-1,1,5, -4629,20,863,1,369, -1,3,1,2,1, -1,4630,22,1,205, -1,2479,4631,17,4632, -15,4607,1,-1,1, -5,4633,20,861,1, -370,1,3,1,2, -1,1,4634,22,1, -206,1,2478,4635,17, -4636,15,4607,1,-1, -1,5,4637,20,859, -1,371,1,3,1, -2,1,1,4638,22, -1,207,1,322,4639, -16,0,747,1,2045, -1997,1,2475,4640,17, -4641,15,4506,1,-1, -1,5,4642,20,848, -1,374,1,3,1, -2,1,1,4643,22, -1,210,1,2043,2001, -1,2473,4644,17,4645, -15,4646,4,36,37, -0,73,0,110,0, -116,0,82,0,111, -0,116,0,82,0, -111,0,116,0,65, -0,114,0,103,0, -69,0,118,0,101, -0,110,0,116,0, -1,-1,1,5,4647, -20,834,1,376,1, -3,1,2,1,1, -4648,22,1,212,1, -2041,2005,1,2471,4649, -17,4650,15,4651,4, -36,37,0,75,0, -101,0,121,0,73, -0,110,0,116,0, -73,0,110,0,116, -0,65,0,114,0, -103,0,69,0,118, -0,101,0,110,0, -116,0,1,-1,1, -5,4652,20,820,1, -378,1,3,1,2, -1,1,4653,22,1, -214,1,2039,2009,1, -2037,2014,1,2035,1900, -1,2033,2020,1,2032, -2024,1,2462,1963,1, -2030,1978,1,2029,1921, -1,2459,1969,1,2458, -1974,1,299,4654,16, -0,747,1,2021,2036, -1,1585,4655,16,0, -747,1,1153,4656,16, -0,747,1,1574,1895, -1,277,4657,16,0, -747,1,1990,4658,16, -0,747,1,1989,2060, -1,2413,4659,16,0, -747,1,256,4660,16, -0,747,1,1117,4661, -16,0,747,1,2477, -4662,17,4663,15,4607, -1,-1,1,5,4664, -20,852,1,372,1, -3,1,2,1,1, -4665,22,1,208,1, -2106,4666,16,0,747, -1,236,4667,16,0, -747,1,1958,4668,16, -0,747,1,1756,4669, -16,0,747,1,1933, -4670,16,0,747,1, -1515,4671,16,0,747, -1,217,4672,16,0, -747,1,2364,2074,1, -1932,4673,16,0,704, -1,1931,1909,1,2464, -2042,1,2786,4674,16, -0,747,1,199,4675, -16,0,747,1,2506, -4676,16,0,317,1, -1479,4677,16,0,747, -1,2769,4678,16,0, -780,1,2337,4679,16, -0,747,1,1901,4680, -16,0,747,1,166, -4681,16,0,747,1, -2318,4682,16,0,747, -1,2198,4683,16,0, -747,1,2472,4684,17, -4685,15,4686,4,36, -37,0,73,0,110, -0,116,0,86,0, -101,0,99,0,86, -0,101,0,99,0, -65,0,114,0,103, -0,69,0,118,0, -101,0,110,0,116, -0,1,-1,1,5, -4687,20,827,1,377, -1,3,1,2,1, -1,4688,22,1,213, -1,1876,4689,16,0, -747,1,1875,4690,16, -0,762,1,1443,4691, -16,0,747,1,1873, -2069,1,2293,4692,16, -0,747,1,137,4693, -16,0,747,1,1189, -4694,16,0,747,1, -79,4695,16,0,747, -1,124,4696,16,0, -747,1,1407,4697,16, -0,747,1,112,4698, -16,0,747,1,1834, -4699,16,0,747,1, -1833,4700,16,0,115, -1,102,4701,16,0, -747,1,97,4702,16, -0,747,1,525,4703, -16,0,747,1,2484, -4704,17,4705,15,4607, -1,-1,1,5,4706, -20,871,1,365,1, -3,1,2,1,1, -4707,22,1,201,1, -1371,4708,16,0,747, -1,89,4709,16,0, -747,1,1860,1983,1, -85,4710,16,0,747, -1,1804,4711,16,0, -747,1,1803,2052,1, -509,4712,16,0,747, -1,76,4713,16,0, -747,1,182,4714,16, -0,747,1,2227,2029, -1,71,4715,16,0, -747,1,63,4716,16, -0,759,1,62,4717, -16,0,734,1,52, -4718,16,0,747,1, -1775,4719,16,0,747, -1,32,4720,16,0, -747,1,44,4721,16, -0,759,1,43,4722, -16,0,747,1,1335, -4723,16,0,747,1, -41,4724,16,0,747, -1,40,4725,16,0, -759,1,346,4726,16, -0,747,1,462,4727, -16,0,747,1,459, -4728,16,0,747,1, -447,4729,16,0,747, -1,9,4730,16,0, -783,1,1731,4731,16, -0,747,1,1297,4732, -16,0,747,1,431, -4733,16,0,747,1, -15,4734,19,272,1, -15,4735,5,6,1, -40,4736,16,0,441, -1,2785,4737,16,0, -770,1,1114,4738,16, -0,542,1,1621,4739, -16,0,270,1,9, -4483,1,19,4461,1, -14,4740,19,148,1, -14,4741,5,115,1, -2281,4290,1,1377,4295, -1,67,2997,1,387, -4742,16,0,531,1, -1370,4306,1,380,2968, -1,379,2973,1,377, -2978,1,2543,4311,1, -375,2983,1,373,2987, -1,371,2991,1,172, -3238,1,1550,4321,1, -42,3742,1,2335,4743, -16,0,197,1,1152, -4327,1,2529,4744,16, -0,287,1,2528,4332, -1,107,3052,1,2525, -4745,16,0,293,1, -1341,4337,1,157,3245, -1,2544,4746,16,0, -262,1,352,3151,1, -1730,4433,1,2540,4747, -16,0,146,1,2514, -4748,16,0,305,1, -2513,4351,1,2510,4749, -16,0,311,1,2509, -4356,1,143,3249,1, -1521,4361,1,188,3233, -1,1123,4365,1,1514, -4369,1,82,3023,1, -328,3029,1,130,3256, -1,1114,3034,1,1701, -4377,1,2582,4459,1, -942,3011,1,1303,4382, -1,9,4483,1,1694, -4750,16,0,197,1, -1296,4392,1,1096,3042, -1,1094,4751,16,0, -503,1,305,3048,1, -1332,4347,1,1485,4397, -1,2467,4402,1,70, -3057,1,1478,4406,1, -883,3269,1,93,3063, -1,1665,4411,1,481, -3747,1,480,3006,1, -479,3072,1,478,3077, -1,477,3081,1,476, -3085,1,20,4752,16, -0,776,1,118,3262, -1,1260,4416,1,68, -3099,1,74,3089,1, -1048,3113,1,464,3734, -1,69,3095,1,262, -3108,1,461,4753,16, -0,503,1,66,3104, -1,459,3752,1,1267, -4423,1,1442,4427,1, -447,3117,1,51,3123, -1,63,3127,1,1231, -4437,1,48,3132,1, -47,3136,1,242,3280, -1,44,3138,1,437, -4754,16,0,468,1, -1224,4441,1,41,3739, -1,525,3145,1,827, -3286,1,1413,4445,1, -2591,4755,16,0,776, -1,1013,3156,1,1406, -4451,1,223,3292,1, -1159,4455,1,2779,4756, -16,0,776,1,283, -3068,1,19,4461,1, -412,4757,16,0,517, -1,1002,3169,1,1001, -3173,1,30,4467,1, -1195,4471,1,2770,4475, -1,1011,3164,1,10, -4373,1,40,3179,1, -205,3300,1,1449,4484, -1,1188,4488,1,50, -3181,1,49,3016,1, -1773,4758,16,0,197, -1,13,4759,19,114, -1,13,4760,5,55, -1,2580,2373,1,2045, -1997,1,2043,2001,1, -2648,2378,1,2575,2383, -1,2039,2009,1,1860, -1983,1,2037,2014,1, -2458,1974,1,2657,2389, -1,2567,2393,1,2032, -2024,1,2654,2402,1, -2653,2406,1,2652,2410, -1,2651,2414,1,2650, -2418,1,2464,2042,1, -2559,2422,1,2647,2427, -1,2646,2431,1,2645, -2435,1,2644,2439,1, -1931,1909,1,2642,2468, -1,2641,2447,1,2462, -1963,1,2105,1940,1, -2459,1969,1,1657,1990, -1,2656,2472,1,2364, -2074,1,2029,1921,1, -2033,2020,1,2536,2457, -1,2030,1978,1,2041, -2005,1,1873,2069,1, -2703,4761,16,0,112, -1,32,4762,16,0, -429,1,1989,2060,1, -2521,2463,1,2021,2036, -1,1803,2052,1,2551, -2451,1,1574,1895,1, -2597,4763,16,0,250, -1,2595,2477,1,2643, -2443,1,2035,1900,1, -2413,4764,16,0,431, -1,2655,2398,1,2031, -1915,1,2227,2029,1, -2136,1926,1,12,4765, -19,151,1,12,4766, -5,50,1,1803,2052, -1,2578,4767,16,0, -767,1,2043,2001,1, -1775,4768,16,0,767, -1,2041,2005,1,2573, -4769,16,0,767,1, -1860,1983,1,2037,2014, -1,2658,4770,16,0, -149,1,2033,2020,1, -2032,2024,1,2565,4771, -16,0,767,1,2030, -1978,1,2029,1921,1, -2106,4772,16,0,767, -1,2469,4773,16,0, -422,1,2557,4774,16, -0,767,1,2464,2042, -1,1931,1909,1,1574, -1895,1,2462,1963,1, -2105,1940,1,2549,4775, -16,0,767,1,2459, -1969,1,2458,1974,1, -2039,2009,1,2364,2074, -1,32,4776,16,0, -767,1,2198,4777,16, -0,767,1,1958,4778, -16,0,767,1,2035, -1900,1,2534,4779,16, -0,767,1,1873,2069, -1,1657,1990,1,2021, -2036,1,1901,4780,16, -0,767,1,1989,2060, -1,1990,4781,16,0, -767,1,2075,4782,16, -0,767,1,2519,4783, -16,0,767,1,1804, -4784,16,0,767,1, -2337,4785,16,0,767, -1,2781,4786,16,0, -767,1,2593,4787,16, -0,767,1,2413,4788, -16,0,767,1,31, -4789,16,0,767,1, -2045,1997,1,2031,1915, -1,2227,2029,1,2136, -1926,1,11,4790,19, -111,1,11,4791,5, -146,1,2462,1963,1, -2136,1926,1,1701,4377, -1,1267,4423,1,1694, -4792,16,0,174,1, -1260,4416,1,1159,4455, -1,827,3286,1,2106, -4793,17,4794,15,4795, -4,30,37,0,69, -0,109,0,112,0, -116,0,121,0,83, -0,116,0,97,0, -116,0,101,0,109, -0,101,0,110,0, -116,0,1,-1,1, -5,4796,20,1557,1, -222,1,3,1,1, -1,0,4797,22,1, -57,1,2105,1940,1, -380,2968,1,379,2973, -1,377,2978,1,375, -2983,1,373,2987,1, -1665,4411,1,371,2991, -1,1231,4437,1,1555, -4798,16,0,357,1, -1659,4799,16,0,509, -1,1657,1990,1,1224, -4441,1,352,3151,1, -2075,4800,17,4794,1, -0,4797,1,328,3029, -1,1628,4801,17,4802, -15,4803,4,22,37, -0,65,0,115,0, -115,0,105,0,103, -0,110,0,109,0, -101,0,110,0,116, -0,1,-1,1,5, -4804,20,1393,1,254, -1,3,1,4,1, -3,4805,22,1,89, -1,1195,4471,1,1621, -4806,16,0,217,1, -1620,4807,17,4808,15, -4803,1,-1,1,5, -4809,20,1379,1,255, -1,3,1,2,1, -1,4810,22,1,90, -1,1188,4488,1,2045, -1997,1,2044,4811,16, -0,622,1,2043,2001, -1,2042,4812,16,0, -109,1,2041,2005,1, -2040,4813,16,0,576, -1,2039,2009,1,2038, -4814,16,0,632,1, -2037,2014,1,2036,4815, -16,0,528,1,2035, -1900,1,2034,4816,16, -0,640,1,2464,2042, -1,2032,2024,1,2031, -1915,1,2030,1978,1, -2029,1921,1,2028,4817, -17,4818,15,4819,4, -20,37,0,74,0, -117,0,109,0,112, -0,76,0,97,0, -98,0,101,0,108, -0,1,-1,1,5, -4820,20,1505,1,236, -1,3,1,3,1, -2,4821,22,1,71, -1,2458,1974,1,2026, -4822,17,4823,15,4824, -4,28,37,0,74, -0,117,0,109,0, -112,0,83,0,116, -0,97,0,116,0, -101,0,109,0,101, -0,110,0,116,0, -1,-1,1,5,4825, -20,1491,1,237,1, -3,1,3,1,2, -4826,22,1,72,1, -2024,4827,17,4828,15, -4829,4,24,37,0, -83,0,116,0,97, -0,116,0,101,0, -67,0,104,0,97, -0,110,0,103,0, -101,0,1,-1,1, -5,4830,20,1489,1, -238,1,3,1,3, -1,2,4831,22,1, -73,1,2023,4832,17, -4833,15,4829,1,-1, -1,5,4834,20,1475, -1,239,1,3,1, -3,1,2,4835,22, -1,74,1,1591,4836, -17,4837,15,4838,4, -32,37,0,82,0, -101,0,116,0,117, -0,114,0,110,0, -83,0,116,0,97, -0,116,0,101,0, -109,0,101,0,110, -0,116,0,1,-1, -1,5,4839,20,1297, -1,280,1,3,1, -3,1,2,4840,22, -1,115,1,2021,2036, -1,1585,4841,17,4842, -15,4838,1,-1,1, -5,4843,20,1283,1, -281,1,3,1,2, -1,1,4844,22,1, -116,1,1152,4327,1, -283,3068,1,1574,1895, -1,49,3016,1,479, -3072,1,1990,4845,17, -4794,1,0,4797,1, -1989,2060,1,262,3108, -1,1123,4365,1,2413, -4846,17,4794,1,0, -4797,1,1550,4321,1, -1114,3034,1,242,3280, -1,1096,3042,1,1521, -4361,1,223,3292,1, -1514,4369,1,2364,2074, -1,1931,1909,1,2792, -4847,16,0,746,1, -205,3300,1,2785,4848, -16,0,501,1,883, -3269,1,942,3011,1, -1485,4397,1,188,3233, -1,1048,3113,1,1478, -4406,1,2337,4849,17, -4794,1,0,4797,1, -1901,4850,17,4794,1, -0,4797,1,172,3238, -1,478,3077,1,157, -3245,1,1449,4484,1, -1013,3156,1,305,3048, -1,1011,3164,1,1872, -4851,16,0,764,1, -2299,4852,16,0,456, -1,143,3249,1,1002, -3169,1,1001,3173,1, -1860,1983,1,1859,4853, -16,0,775,1,130, -3256,1,2281,4290,1, -2459,1969,1,1873,2069, -1,1413,4445,1,118, -3262,1,1406,4451,1, -1958,4854,17,4794,1, -0,4797,1,107,3052, -1,2033,2020,1,525, -3145,1,93,3063,1, -1377,4295,1,82,3023, -1,1804,4855,17,4794, -1,0,4797,1,1803, -2052,1,1370,4306,1, -74,3089,1,2227,2029, -1,70,3057,1,69, -3095,1,68,3099,1, -67,2997,1,66,3104, -1,63,3127,1,1775, -4856,17,4794,1,0, -4797,1,50,3181,1, -480,3006,1,48,3132, -1,47,3136,1,477, -3081,1,476,3085,1, -44,3138,1,2198,4857, -17,4794,1,0,4797, -1,51,3123,1,40, -3179,1,1332,4347,1, -32,4858,17,4794,1, -0,4797,1,1341,4337, -1,1442,4427,1,19, -4461,1,447,3117,1, -1737,4859,16,0,144, -1,1303,4382,1,9, -4483,1,1730,4433,1, -1296,4392,1,10,4860, -19,524,1,10,4861, -5,2,1,40,4862, -16,0,522,1,1114, -4863,16,0,639,1, -9,4864,19,512,1, -9,4865,5,2,1, -40,4866,16,0,510, -1,1114,4867,16,0, -613,1,8,4868,19, -480,1,8,4869,5, -2,1,40,4870,16, -0,478,1,1114,4871, -16,0,590,1,7, -4872,19,464,1,7, -4873,5,2,1,40, -4874,16,0,462,1, -1114,4875,16,0,574, -1,6,4876,19,453, -1,6,4877,5,2, -1,40,4878,16,0, -451,1,1114,4879,16, -0,564,1,5,4880, -19,552,1,5,4881, -5,100,1,1574,1895, -1,2035,1900,1,1371, -4882,16,0,550,1, -71,4883,16,0,550, -1,1958,4884,16,0, -550,1,381,4885,16, -0,550,1,2106,4886, -16,0,550,1,1931, -1909,1,1756,4887,16, -0,550,1,2031,1915, -1,509,4888,16,0, -550,1,2337,4889,16, -0,550,1,2029,1921, -1,1153,4890,16,0, -550,1,2136,1926,1, -1933,4891,16,0,550, -1,2198,4892,16,0, -550,1,1731,4893,16, -0,550,1,1335,4894, -16,0,550,1,2318, -4895,16,0,550,1, -346,4896,16,0,550, -1,182,4897,16,0, -550,1,137,4898,16, -0,550,1,1515,4899, -16,0,550,1,2105, -1940,1,1775,4900,16, -0,550,1,1117,4901, -16,0,550,1,525, -4902,16,0,550,1, -1114,4903,16,0,751, -1,1901,4904,16,0, -550,1,2293,4905,16, -0,550,1,322,4906, -16,0,550,1,124, -4907,16,0,550,1, -1695,4908,16,0,550, -1,1297,4909,16,0, -550,1,151,4910,16, -0,550,1,44,4911, -16,0,749,1,112, -4912,16,0,550,1, -1990,4913,16,0,550, -1,76,4914,16,0, -550,1,43,4915,16, -0,550,1,2075,4916, -16,0,550,1,1876, -4917,16,0,550,1, -299,4918,16,0,550, -1,1479,4919,16,0, -550,1,2462,1963,1, -97,4920,16,0,550, -1,2459,1969,1,2458, -1974,1,2030,1978,1, -89,4921,16,0,550, -1,1860,1983,1,85, -4922,16,0,550,1, -1659,4923,16,0,550, -1,1657,1990,1,277, -4924,16,0,550,1, -1261,4925,16,0,550, -1,166,4926,16,0, -550,1,2045,1997,1, -2043,2001,1,2041,2005, -1,2039,2009,1,462, -4927,16,0,550,1, -2037,2014,1,66,4928, -16,0,738,1,459, -4929,16,0,550,1, -1443,4930,16,0,550, -1,2033,2020,1,2032, -2024,1,1834,4931,16, -0,550,1,2227,2029, -1,256,4932,16,0, -550,1,447,4933,16, -0,550,1,52,4934, -16,0,550,1,2021, -2036,1,63,4935,16, -0,736,1,2413,4936, -16,0,550,1,47, -4937,16,0,751,1, -1622,4938,16,0,550, -1,2464,2042,1,1225, -4939,16,0,550,1, -41,4940,16,0,550, -1,40,4941,16,0, -749,1,236,4942,16, -0,550,1,431,4943, -16,0,550,1,32, -4944,16,0,550,1, -1804,4945,16,0,550, -1,1803,2052,1,1407, -4946,16,0,550,1, -79,4947,16,0,550, -1,217,4948,16,0, -550,1,1989,2060,1, -102,4949,16,0,550, -1,2786,4950,16,0, -550,1,406,4951,16, -0,550,1,1585,4952, -16,0,550,1,1189, -4953,16,0,550,1, -1873,2069,1,199,4954, -16,0,550,1,2364, -2074,1,4,4955,19, -546,1,4,4956,5, -100,1,1574,1895,1, -2035,1900,1,1371,4957, -16,0,544,1,71, -4958,16,0,544,1, -1958,4959,16,0,544, -1,381,4960,16,0, -544,1,2106,4961,16, -0,544,1,1931,1909, -1,1756,4962,16,0, -544,1,2031,1915,1, -509,4963,16,0,544, -1,2337,4964,16,0, -544,1,2029,1921,1, -1153,4965,16,0,544, -1,2136,1926,1,1933, -4966,16,0,544,1, -2198,4967,16,0,544, -1,1731,4968,16,0, -544,1,1335,4969,16, -0,544,1,2318,4970, -16,0,544,1,346, -4971,16,0,544,1, -182,4972,16,0,544, -1,137,4973,16,0, -544,1,1515,4974,16, -0,544,1,2105,1940, -1,1775,4975,16,0, -544,1,1117,4976,16, -0,544,1,525,4977, -16,0,544,1,1114, -4978,16,0,750,1, -1901,4979,16,0,544, -1,2293,4980,16,0, -544,1,322,4981,16, -0,544,1,124,4982, -16,0,544,1,1695, -4983,16,0,544,1, -1297,4984,16,0,544, -1,151,4985,16,0, -544,1,44,4986,16, -0,748,1,112,4987, -16,0,544,1,1990, -4988,16,0,544,1, -76,4989,16,0,544, -1,43,4990,16,0, -544,1,2075,4991,16, -0,544,1,1876,4992, -16,0,544,1,299, -4993,16,0,544,1, -1479,4994,16,0,544, -1,2462,1963,1,97, -4995,16,0,544,1, -2459,1969,1,2458,1974, -1,2030,1978,1,89, -4996,16,0,544,1, -1860,1983,1,85,4997, -16,0,544,1,1659, -4998,16,0,544,1, -1657,1990,1,277,4999, -16,0,544,1,1261, -5000,16,0,544,1, -166,5001,16,0,544, -1,2045,1997,1,2043, -2001,1,2041,2005,1, -2039,2009,1,462,5002, -16,0,544,1,2037, -2014,1,66,5003,16, -0,737,1,459,5004, -16,0,544,1,1443, -5005,16,0,544,1, -2033,2020,1,2032,2024, -1,1834,5006,16,0, -544,1,2227,2029,1, -256,5007,16,0,544, -1,447,5008,16,0, -544,1,52,5009,16, -0,544,1,2021,2036, -1,63,5010,16,0, -735,1,2413,5011,16, -0,544,1,47,5012, -16,0,750,1,1622, -5013,16,0,544,1, -2464,2042,1,1225,5014, -16,0,544,1,41, -5015,16,0,544,1, -40,5016,16,0,748, -1,236,5017,16,0, -544,1,431,5018,16, -0,544,1,32,5019, -16,0,544,1,1804, -5020,16,0,544,1, -1803,2052,1,1407,5021, -16,0,544,1,79, -5022,16,0,544,1, -217,5023,16,0,544, -1,1989,2060,1,102, -5024,16,0,544,1, -2786,5025,16,0,544, -1,406,5026,16,0, -544,1,1585,5027,16, -0,544,1,1189,5028, -16,0,544,1,1873, -2069,1,199,5029,16, -0,544,1,2364,2074, -1,3,5030,19,500, -1,3,5031,5,95, -1,1574,1895,1,2035, -1900,1,1371,5032,16, -0,498,1,71,5033, -16,0,498,1,1958, -5034,16,0,498,1, -381,5035,16,0,498, -1,2106,5036,16,0, -498,1,1931,1909,1, -1756,5037,16,0,498, -1,2031,1915,1,509, -5038,16,0,498,1, -2337,5039,16,0,498, -1,2029,1921,1,1153, -5040,16,0,498,1, -2136,1926,1,1933,5041, -16,0,498,1,2198, -5042,16,0,498,1, -1731,5043,16,0,498, -1,1335,5044,16,0, -498,1,2318,5045,16, -0,498,1,346,5046, -16,0,498,1,182, -5047,16,0,498,1, -137,5048,16,0,498, -1,1515,5049,16,0, -498,1,2105,1940,1, -1775,5050,16,0,498, -1,1117,5051,16,0, -498,1,525,5052,16, -0,498,1,52,5053, -16,0,498,1,1901, -5054,16,0,498,1, -2293,5055,16,0,498, -1,322,5056,16,0, -498,1,124,5057,16, -0,498,1,1695,5058, -16,0,498,1,1297, -5059,16,0,498,1, -151,5060,16,0,498, -1,112,5061,16,0, -498,1,1990,5062,16, -0,498,1,76,5063, -16,0,498,1,43, -5064,16,0,498,1, -2075,5065,16,0,498, -1,1876,5066,16,0, -498,1,299,5067,16, -0,498,1,1479,5068, -16,0,498,1,2462, -1963,1,97,5069,16, -0,498,1,2459,1969, -1,2458,1974,1,2030, -1978,1,89,5070,16, -0,498,1,1860,1983, -1,85,5071,16,0, -498,1,1659,5072,16, -0,498,1,1657,1990, -1,277,5073,16,0, -498,1,1261,5074,16, -0,498,1,166,5075, -16,0,498,1,2045, -1997,1,2043,2001,1, -2041,2005,1,2039,2009, -1,462,5076,16,0, -498,1,2037,2014,1, -459,5077,16,0,498, -1,1443,5078,16,0, -498,1,2033,2020,1, -2032,2024,1,1834,5079, -16,0,498,1,2227, -2029,1,256,5080,16, -0,498,1,447,5081, -16,0,498,1,62, -5082,16,0,498,1, -2021,2036,1,2413,5083, -16,0,498,1,1622, -5084,16,0,498,1, -2464,2042,1,1225,5085, -16,0,498,1,41, -5086,16,0,498,1, -236,5087,16,0,498, -1,431,5088,16,0, -498,1,32,5089,16, -0,498,1,1804,5090, -16,0,498,1,1803, -2052,1,1407,5091,16, -0,498,1,79,5092, -16,0,498,1,217, -5093,16,0,498,1, -1989,2060,1,102,5094, -16,0,498,1,2786, -5095,16,0,498,1, -406,5096,16,0,498, -1,1585,5097,16,0, -498,1,1189,5098,16, -0,498,1,1873,2069, -1,199,5099,16,0, -498,1,2364,2074,1, -2,5100,19,572,1, -2,5101,5,6,1, -2768,2876,1,2649,2872, -1,2767,2893,1,2834, -5102,17,5103,15,5104, -4,30,37,0,76, -0,83,0,76,0, -80,0,114,0,111, -0,103,0,114,0, -97,0,109,0,82, -0,111,0,111,0, -116,0,1,-1,1, -5,5105,20,1810,1, -167,1,3,1,3, -1,2,5106,22,1, -1,1,2764,5107,17, -5108,15,5104,1,-1, -1,5,5109,20,1806, -1,168,1,3,1, -2,1,1,5110,22, -1,2,1,2755,2866, -2,0,0}; -new Sfactory(this,"IncrementDecrementExpression_1",new SCreator(IncrementDecrementExpression_1_factory)); -new Sfactory(this,"StateChange",new SCreator(StateChange_factory)); -new Sfactory(this,"ArgumentDeclarationList_3",new SCreator(ArgumentDeclarationList_3_factory)); -new Sfactory(this,"BinaryExpression",new SCreator(BinaryExpression_factory)); -new Sfactory(this,"VoidArgEvent_5",new SCreator(VoidArgEvent_5_factory)); -new Sfactory(this,"IdentDotExpression_1",new SCreator(IdentDotExpression_1_factory)); -new Sfactory(this,"StateBody_10",new SCreator(StateBody_10_factory)); -new Sfactory(this,"VectorArgEvent_1",new SCreator(VectorArgEvent_1_factory)); -new Sfactory(this,"ReturnStatement_1",new SCreator(ReturnStatement_1_factory)); -new Sfactory(this,"ReturnStatement_2",new SCreator(ReturnStatement_2_factory)); -new Sfactory(this,"Typename_7",new SCreator(Typename_7_factory)); -new Sfactory(this,"ExpressionArgument",new SCreator(ExpressionArgument_factory)); -new Sfactory(this,"ForLoop",new SCreator(ForLoop_factory)); -new Sfactory(this,"GlobalDefinitions",new SCreator(GlobalDefinitions_factory)); -new Sfactory(this,"Typename_1",new SCreator(Typename_1_factory)); -new Sfactory(this,"TypecastExpression_3",new SCreator(TypecastExpression_3_factory)); -new Sfactory(this,"IncrementDecrementExpression_6",new SCreator(IncrementDecrementExpression_6_factory)); -new Sfactory(this,"SimpleAssignment_2",new SCreator(SimpleAssignment_2_factory)); -new Sfactory(this,"IntVecVecArgEvent_1",new SCreator(IntVecVecArgEvent_1_factory)); -new Sfactory(this,"LSLProgramRoot_2",new SCreator(LSLProgramRoot_2_factory)); -new Sfactory(this,"IdentDotExpression",new SCreator(IdentDotExpression_factory)); -new Sfactory(this,"UnaryExpression_1",new SCreator(UnaryExpression_1_factory)); -new Sfactory(this,"RotationConstant",new SCreator(RotationConstant_factory)); -new Sfactory(this,"IntArgumentDeclarationList",new SCreator(IntArgumentDeclarationList_factory)); -new Sfactory(this,"ArgumentList",new SCreator(ArgumentList_factory)); -new Sfactory(this,"BinaryExpression_3",new SCreator(BinaryExpression_3_factory)); -new Sfactory(this,"Event_2",new SCreator(Event_2_factory)); -new Sfactory(this,"ArgumentList_4",new SCreator(ArgumentList_4_factory)); -new Sfactory(this,"IntVecVecArgEvent",new SCreator(IntVecVecArgEvent_factory)); -new Sfactory(this,"WhileStatement_2",new SCreator(WhileStatement_2_factory)); -new Sfactory(this,"Assignment",new SCreator(Assignment_factory)); -new Sfactory(this,"Statement_12",new SCreator(Statement_12_factory)); -new Sfactory(this,"IncrementDecrementExpression_8",new SCreator(IncrementDecrementExpression_8_factory)); -new Sfactory(this,"VectorArgEvent_2",new SCreator(VectorArgEvent_2_factory)); -new Sfactory(this,"Constant_2",new SCreator(Constant_2_factory)); -new Sfactory(this,"Statement_1",new SCreator(Statement_1_factory)); -new Sfactory(this,"VectorArgEvent",new SCreator(VectorArgEvent_factory)); -new Sfactory(this,"ForLoopStatement_1",new SCreator(ForLoopStatement_1_factory)); -new Sfactory(this,"IncrementDecrementExpression_2",new SCreator(IncrementDecrementExpression_2_factory)); -new Sfactory(this,"IntArgumentDeclarationList_1",new SCreator(IntArgumentDeclarationList_1_factory)); -new Sfactory(this,"VoidArgEvent_4",new SCreator(VoidArgEvent_4_factory)); -new Sfactory(this,"ForLoop_1",new SCreator(ForLoop_1_factory)); -new Sfactory(this,"Typename_4",new SCreator(Typename_4_factory)); -new Sfactory(this,"IdentExpression",new SCreator(IdentExpression_factory)); -new Sfactory(this,"ForLoop_2",new SCreator(ForLoop_2_factory)); -new Sfactory(this,"DoWhileStatement",new SCreator(DoWhileStatement_factory)); -new Sfactory(this,"SimpleAssignment_6",new SCreator(SimpleAssignment_6_factory)); -new Sfactory(this,"IntDeclaration_1",new SCreator(IntDeclaration_1_factory)); -new Sfactory(this,"State_1",new SCreator(State_1_factory)); -new Sfactory(this,"StateBody_9",new SCreator(StateBody_9_factory)); -new Sfactory(this,"StateBody_8",new SCreator(StateBody_8_factory)); -new Sfactory(this,"State_2",new SCreator(State_2_factory)); -new Sfactory(this,"StateBody_3",new SCreator(StateBody_3_factory)); -new Sfactory(this,"StateBody_2",new SCreator(StateBody_2_factory)); -new Sfactory(this,"StateBody_1",new SCreator(StateBody_1_factory)); -new Sfactory(this,"Typename_6",new SCreator(Typename_6_factory)); -new Sfactory(this,"StateBody_7",new SCreator(StateBody_7_factory)); -new Sfactory(this,"StateBody_4",new SCreator(StateBody_4_factory)); -new Sfactory(this,"IfStatement_1",new SCreator(IfStatement_1_factory)); -new Sfactory(this,"IfStatement_3",new SCreator(IfStatement_3_factory)); -new Sfactory(this,"IfStatement_2",new SCreator(IfStatement_2_factory)); -new Sfactory(this,"SimpleAssignment_1",new SCreator(SimpleAssignment_1_factory)); -new Sfactory(this,"VoidArgEvent_6",new SCreator(VoidArgEvent_6_factory)); -new Sfactory(this,"IfStatement",new SCreator(IfStatement_factory)); -new Sfactory(this,"ConstantExpression",new SCreator(ConstantExpression_factory)); -new Sfactory(this,"BinaryExpression_7",new SCreator(BinaryExpression_7_factory)); -new Sfactory(this,"IncrementDecrementExpression",new SCreator(IncrementDecrementExpression_factory)); -new Sfactory(this,"Statement_9",new SCreator(Statement_9_factory)); -new Sfactory(this,"IntVecVecArgStateEvent",new SCreator(IntVecVecArgStateEvent_factory)); -new Sfactory(this,"Declaration_1",new SCreator(Declaration_1_factory)); -new Sfactory(this,"KeyIntIntArgumentDeclarationList",new SCreator(KeyIntIntArgumentDeclarationList_factory)); -new Sfactory(this,"VectorArgumentDeclarationList_1",new SCreator(VectorArgumentDeclarationList_1_factory)); -new Sfactory(this,"SimpleAssignment",new SCreator(SimpleAssignment_factory)); -new Sfactory(this,"BinaryExpression_9",new SCreator(BinaryExpression_9_factory)); -new Sfactory(this,"IntDeclaration",new SCreator(IntDeclaration_factory)); -new Sfactory(this,"IntArgEvent_10",new SCreator(IntArgEvent_10_factory)); -new Sfactory(this,"ArgumentDeclarationList_2",new SCreator(ArgumentDeclarationList_2_factory)); -new Sfactory(this,"ArgumentDeclarationList_1",new SCreator(ArgumentDeclarationList_1_factory)); -new Sfactory(this,"ArgumentDeclarationList_4",new SCreator(ArgumentDeclarationList_4_factory)); -new Sfactory(this,"SimpleAssignment_9",new SCreator(SimpleAssignment_9_factory)); -new Sfactory(this,"ForLoopStatement_2",new SCreator(ForLoopStatement_2_factory)); -new Sfactory(this,"StatementList",new SCreator(StatementList_factory)); -new Sfactory(this,"StateBody_13",new SCreator(StateBody_13_factory)); -new Sfactory(this,"Typename_3",new SCreator(Typename_3_factory)); -new Sfactory(this,"KeyArgumentDeclarationList_1",new SCreator(KeyArgumentDeclarationList_1_factory)); -new Sfactory(this,"UnaryExpression_3",new SCreator(UnaryExpression_3_factory)); -new Sfactory(this,"StateBody_16",new SCreator(StateBody_16_factory)); -new Sfactory(this,"VectorArgumentDeclarationList",new SCreator(VectorArgumentDeclarationList_factory)); -new Sfactory(this,"IntArgEvent_3",new SCreator(IntArgEvent_3_factory)); -new Sfactory(this,"StatementList_2",new SCreator(StatementList_2_factory)); -new Sfactory(this,"KeyArgStateEvent",new SCreator(KeyArgStateEvent_factory)); -new Sfactory(this,"LSLProgramRoot_1",new SCreator(LSLProgramRoot_1_factory)); -new Sfactory(this,"Typename_2",new SCreator(Typename_2_factory)); -new Sfactory(this,"TypecastExpression_6",new SCreator(TypecastExpression_6_factory)); -new Sfactory(this,"Event_3",new SCreator(Event_3_factory)); -new Sfactory(this,"IntArgStateEvent",new SCreator(IntArgStateEvent_factory)); -new Sfactory(this,"StateChange_2",new SCreator(StateChange_2_factory)); -new Sfactory(this,"StateChange_1",new SCreator(StateChange_1_factory)); -new Sfactory(this,"VectorConstant_1",new SCreator(VectorConstant_1_factory)); -new Sfactory(this,"KeyDeclaration",new SCreator(KeyDeclaration_factory)); -new Sfactory(this,"States_2",new SCreator(States_2_factory)); -new Sfactory(this,"VoidArgEvent",new SCreator(VoidArgEvent_factory)); -new Sfactory(this,"WhileStatement",new SCreator(WhileStatement_factory)); -new Sfactory(this,"UnaryExpression",new SCreator(UnaryExpression_factory)); -new Sfactory(this,"BinaryExpression_6",new SCreator(BinaryExpression_6_factory)); -new Sfactory(this,"ConstantExpression_1",new SCreator(ConstantExpression_1_factory)); -new Sfactory(this,"ForLoopStatement",new SCreator(ForLoopStatement_factory)); -new Sfactory(this,"BinaryExpression_1",new SCreator(BinaryExpression_1_factory)); -new Sfactory(this,"StateEvent",new SCreator(StateEvent_factory)); -new Sfactory(this,"Event_5",new SCreator(Event_5_factory)); -new Sfactory(this,"SimpleAssignment_5",new SCreator(SimpleAssignment_5_factory)); -new Sfactory(this,"RotationConstant_1",new SCreator(RotationConstant_1_factory)); -new Sfactory(this,"Constant",new SCreator(Constant_factory)); -new Sfactory(this,"IntArgEvent_1",new SCreator(IntArgEvent_1_factory)); -new Sfactory(this,"SimpleAssignment_8",new SCreator(SimpleAssignment_8_factory)); -new Sfactory(this,"ForLoopStatement_3",new SCreator(ForLoopStatement_3_factory)); -new Sfactory(this,"IntArgEvent_2",new SCreator(IntArgEvent_2_factory)); -new Sfactory(this,"LSLProgramRoot",new SCreator(LSLProgramRoot_factory)); -new Sfactory(this,"StateBody_12",new SCreator(StateBody_12_factory)); -new Sfactory(this,"IntArgEvent_4",new SCreator(IntArgEvent_4_factory)); -new Sfactory(this,"IntArgEvent_7",new SCreator(IntArgEvent_7_factory)); -new Sfactory(this,"IntArgEvent_6",new SCreator(IntArgEvent_6_factory)); -new Sfactory(this,"IntArgEvent_9",new SCreator(IntArgEvent_9_factory)); -new Sfactory(this,"TypecastExpression_7",new SCreator(TypecastExpression_7_factory)); -new Sfactory(this,"StateBody_15",new SCreator(StateBody_15_factory)); -new Sfactory(this,"VoidArgStateEvent_1",new SCreator(VoidArgStateEvent_1_factory)); -new Sfactory(this,"error",new SCreator(error_factory)); -new Sfactory(this,"TypecastExpression_1",new SCreator(TypecastExpression_1_factory)); -new Sfactory(this,"GlobalDefinitions_4",new SCreator(GlobalDefinitions_4_factory)); -new Sfactory(this,"GlobalDefinitions_3",new SCreator(GlobalDefinitions_3_factory)); -new Sfactory(this,"GlobalDefinitions_2",new SCreator(GlobalDefinitions_2_factory)); -new Sfactory(this,"GlobalDefinitions_1",new SCreator(GlobalDefinitions_1_factory)); -new Sfactory(this,"ArgumentList_1",new SCreator(ArgumentList_1_factory)); -new Sfactory(this,"IncrementDecrementExpression_7",new SCreator(IncrementDecrementExpression_7_factory)); -new Sfactory(this,"UnaryExpression_2",new SCreator(UnaryExpression_2_factory)); -new Sfactory(this,"Argument",new SCreator(Argument_factory)); -new Sfactory(this,"SimpleAssignment_24",new SCreator(SimpleAssignment_24_factory)); -new Sfactory(this,"ExpressionArgument_1",new SCreator(ExpressionArgument_1_factory)); -new Sfactory(this,"EmptyStatement",new SCreator(EmptyStatement_factory)); -new Sfactory(this,"KeyIntIntArgStateEvent",new SCreator(KeyIntIntArgStateEvent_factory)); -new Sfactory(this,"VectorArgStateEvent_1",new SCreator(VectorArgStateEvent_1_factory)); -new Sfactory(this,"GlobalFunctionDefinition_1",new SCreator(GlobalFunctionDefinition_1_factory)); -new Sfactory(this,"FunctionCallExpression_1",new SCreator(FunctionCallExpression_1_factory)); -new Sfactory(this,"DoWhileStatement_2",new SCreator(DoWhileStatement_2_factory)); -new Sfactory(this,"VoidArgEvent_1",new SCreator(VoidArgEvent_1_factory)); -new Sfactory(this,"KeyArgumentDeclarationList",new SCreator(KeyArgumentDeclarationList_factory)); -new Sfactory(this,"KeyIntIntArgEvent",new SCreator(KeyIntIntArgEvent_factory)); -new Sfactory(this,"ListConstant_1",new SCreator(ListConstant_1_factory)); -new Sfactory(this,"StateEvent_1",new SCreator(StateEvent_1_factory)); -new Sfactory(this,"SimpleAssignment_20",new SCreator(SimpleAssignment_20_factory)); -new Sfactory(this,"SimpleAssignment_23",new SCreator(SimpleAssignment_23_factory)); -new Sfactory(this,"SimpleAssignment_22",new SCreator(SimpleAssignment_22_factory)); -new Sfactory(this,"IntArgEvent_5",new SCreator(IntArgEvent_5_factory)); -new Sfactory(this,"ParenthesisExpression",new SCreator(ParenthesisExpression_factory)); -new Sfactory(this,"JumpStatement",new SCreator(JumpStatement_factory)); -new Sfactory(this,"IntRotRotArgumentDeclarationList_1",new SCreator(IntRotRotArgumentDeclarationList_1_factory)); -new Sfactory(this,"SimpleAssignment_4",new SCreator(SimpleAssignment_4_factory)); -new Sfactory(this,"KeyArgEvent",new SCreator(KeyArgEvent_factory)); -new Sfactory(this,"Assignment_2",new SCreator(Assignment_2_factory)); -new Sfactory(this,"ForLoopStatement_4",new SCreator(ForLoopStatement_4_factory)); -new Sfactory(this,"Statement_13",new SCreator(Statement_13_factory)); -new Sfactory(this,"RotDeclaration",new SCreator(RotDeclaration_factory)); -new Sfactory(this,"StateBody_11",new SCreator(StateBody_11_factory)); -new Sfactory(this,"KeyArgEvent_2",new SCreator(KeyArgEvent_2_factory)); -new Sfactory(this,"StatementList_1",new SCreator(StatementList_1_factory)); -new Sfactory(this,"StateBody_6",new SCreator(StateBody_6_factory)); -new Sfactory(this,"Constant_1",new SCreator(Constant_1_factory)); -new Sfactory(this,"VecDeclaration",new SCreator(VecDeclaration_factory)); -new Sfactory(this,"TypecastExpression_5",new SCreator(TypecastExpression_5_factory)); -new Sfactory(this,"GlobalFunctionDefinition_2",new SCreator(GlobalFunctionDefinition_2_factory)); -new Sfactory(this,"KeyIntIntArgEvent_1",new SCreator(KeyIntIntArgEvent_1_factory)); -new Sfactory(this,"Constant_4",new SCreator(Constant_4_factory)); -new Sfactory(this,"TypecastExpression_9",new SCreator(TypecastExpression_9_factory)); -new Sfactory(this,"IntRotRotArgStateEvent_1",new SCreator(IntRotRotArgStateEvent_1_factory)); -new Sfactory(this,"IncrementDecrementExpression_3",new SCreator(IncrementDecrementExpression_3_factory)); -new Sfactory(this,"States_1",new SCreator(States_1_factory)); -new Sfactory(this,"GlobalVariableDeclaration",new SCreator(GlobalVariableDeclaration_factory)); -new Sfactory(this,"VoidArgEvent_3",new SCreator(VoidArgEvent_3_factory)); -new Sfactory(this,"Assignment_1",new SCreator(Assignment_1_factory)); -new Sfactory(this,"BinaryExpression_5",new SCreator(BinaryExpression_5_factory)); -new Sfactory(this,"IfStatement_4",new SCreator(IfStatement_4_factory)); -new Sfactory(this,"IntVecVecArgumentDeclarationList_1",new SCreator(IntVecVecArgumentDeclarationList_1_factory)); -new Sfactory(this,"KeyIntIntArgumentDeclarationList_1",new SCreator(KeyIntIntArgumentDeclarationList_1_factory)); -new Sfactory(this,"Statement",new SCreator(Statement_factory)); -new Sfactory(this,"ParenthesisExpression_1",new SCreator(ParenthesisExpression_1_factory)); -new Sfactory(this,"ParenthesisExpression_2",new SCreator(ParenthesisExpression_2_factory)); -new Sfactory(this,"DoWhileStatement_1",new SCreator(DoWhileStatement_1_factory)); -new Sfactory(this,"VoidArgStateEvent",new SCreator(VoidArgStateEvent_factory)); -new Sfactory(this,"GlobalFunctionDefinition",new SCreator(GlobalFunctionDefinition_factory)); -new Sfactory(this,"Event_4",new SCreator(Event_4_factory)); -new Sfactory(this,"IntArgEvent",new SCreator(IntArgEvent_factory)); -new Sfactory(this,"SimpleAssignment_11",new SCreator(SimpleAssignment_11_factory)); -new Sfactory(this,"SimpleAssignment_10",new SCreator(SimpleAssignment_10_factory)); -new Sfactory(this,"SimpleAssignment_13",new SCreator(SimpleAssignment_13_factory)); -new Sfactory(this,"SimpleAssignment_12",new SCreator(SimpleAssignment_12_factory)); -new Sfactory(this,"SimpleAssignment_15",new SCreator(SimpleAssignment_15_factory)); -new Sfactory(this,"SimpleAssignment_14",new SCreator(SimpleAssignment_14_factory)); -new Sfactory(this,"SimpleAssignment_17",new SCreator(SimpleAssignment_17_factory)); -new Sfactory(this,"SimpleAssignment_16",new SCreator(SimpleAssignment_16_factory)); -new Sfactory(this,"SimpleAssignment_19",new SCreator(SimpleAssignment_19_factory)); -new Sfactory(this,"SimpleAssignment_18",new SCreator(SimpleAssignment_18_factory)); -new Sfactory(this,"IntVecVecArgumentDeclarationList",new SCreator(IntVecVecArgumentDeclarationList_factory)); -new Sfactory(this,"StateBody_5",new SCreator(StateBody_5_factory)); -new Sfactory(this,"BinaryExpression_17",new SCreator(BinaryExpression_17_factory)); -new Sfactory(this,"BinaryExpression_16",new SCreator(BinaryExpression_16_factory)); -new Sfactory(this,"BinaryExpression_15",new SCreator(BinaryExpression_15_factory)); -new Sfactory(this,"BinaryExpression_14",new SCreator(BinaryExpression_14_factory)); -new Sfactory(this,"BinaryExpression_13",new SCreator(BinaryExpression_13_factory)); -new Sfactory(this,"BinaryExpression_12",new SCreator(BinaryExpression_12_factory)); -new Sfactory(this,"BinaryExpression_11",new SCreator(BinaryExpression_11_factory)); -new Sfactory(this,"BinaryExpression_10",new SCreator(BinaryExpression_10_factory)); -new Sfactory(this,"VectorArgStateEvent",new SCreator(VectorArgStateEvent_factory)); -new Sfactory(this,"Statement_10",new SCreator(Statement_10_factory)); -new Sfactory(this,"BinaryExpression_8",new SCreator(BinaryExpression_8_factory)); -new Sfactory(this,"BinaryExpression_18",new SCreator(BinaryExpression_18_factory)); -new Sfactory(this,"BinaryExpression_2",new SCreator(BinaryExpression_2_factory)); -new Sfactory(this,"FunctionCallExpression",new SCreator(FunctionCallExpression_factory)); -new Sfactory(this,"VectorArgEvent_3",new SCreator(VectorArgEvent_3_factory)); -new Sfactory(this,"IdentExpression_1",new SCreator(IdentExpression_1_factory)); -new Sfactory(this,"IntArgEvent_8",new SCreator(IntArgEvent_8_factory)); -new Sfactory(this,"VoidArgEvent_7",new SCreator(VoidArgEvent_7_factory)); -new Sfactory(this,"IncrementDecrementExpression_4",new SCreator(IncrementDecrementExpression_4_factory)); -new Sfactory(this,"FunctionCall",new SCreator(FunctionCall_factory)); -new Sfactory(this,"ArgumentList_3",new SCreator(ArgumentList_3_factory)); -new Sfactory(this,"KeyIntIntArgStateEvent_1",new SCreator(KeyIntIntArgStateEvent_1_factory)); -new Sfactory(this,"IntRotRotArgumentDeclarationList",new SCreator(IntRotRotArgumentDeclarationList_factory)); -new Sfactory(this,"KeyDeclaration_1",new SCreator(KeyDeclaration_1_factory)); -new Sfactory(this,"BinaryExpression_4",new SCreator(BinaryExpression_4_factory)); -new Sfactory(this,"FunctionCall_1",new SCreator(FunctionCall_1_factory)); -new Sfactory(this,"KeyArgStateEvent_1",new SCreator(KeyArgStateEvent_1_factory)); -new Sfactory(this,"IntArgStateEvent_1",new SCreator(IntArgStateEvent_1_factory)); -new Sfactory(this,"Event",new SCreator(Event_factory)); -new Sfactory(this,"IntRotRotArgEvent",new SCreator(IntRotRotArgEvent_factory)); -new Sfactory(this,"SimpleAssignment_7",new SCreator(SimpleAssignment_7_factory)); -new Sfactory(this,"Statement_3",new SCreator(Statement_3_factory)); -new Sfactory(this,"Expression",new SCreator(Expression_factory)); -new Sfactory(this,"CompoundStatement_2",new SCreator(CompoundStatement_2_factory)); -new Sfactory(this,"CompoundStatement_1",new SCreator(CompoundStatement_1_factory)); -new Sfactory(this,"JumpLabel",new SCreator(JumpLabel_factory)); -new Sfactory(this,"State",new SCreator(State_factory)); -new Sfactory(this,"TypecastExpression",new SCreator(TypecastExpression_factory)); -new Sfactory(this,"IntRotRotArgEvent_1",new SCreator(IntRotRotArgEvent_1_factory)); -new Sfactory(this,"Statement_11",new SCreator(Statement_11_factory)); -new Sfactory(this,"VoidArgEvent_2",new SCreator(VoidArgEvent_2_factory)); -new Sfactory(this,"Typename",new SCreator(Typename_factory)); -new Sfactory(this,"ArgumentDeclarationList",new SCreator(ArgumentDeclarationList_factory)); -new Sfactory(this,"StateBody",new SCreator(StateBody_factory)); -new Sfactory(this,"Event_8",new SCreator(Event_8_factory)); -new Sfactory(this,"Event_9",new SCreator(Event_9_factory)); -new Sfactory(this,"Event_6",new SCreator(Event_6_factory)); -new Sfactory(this,"Event_7",new SCreator(Event_7_factory)); -new Sfactory(this,"Statement_8",new SCreator(Statement_8_factory)); -new Sfactory(this,"CompoundStatement",new SCreator(CompoundStatement_factory)); -new Sfactory(this,"Event_1",new SCreator(Event_1_factory)); -new Sfactory(this,"Statement_4",new SCreator(Statement_4_factory)); -new Sfactory(this,"Statement_5",new SCreator(Statement_5_factory)); -new Sfactory(this,"Statement_6",new SCreator(Statement_6_factory)); -new Sfactory(this,"Statement_7",new SCreator(Statement_7_factory)); -new Sfactory(this,"IncrementDecrementExpression_5",new SCreator(IncrementDecrementExpression_5_factory)); -new Sfactory(this,"Statement_2",new SCreator(Statement_2_factory)); -new Sfactory(this,"ListConstant",new SCreator(ListConstant_factory)); -new Sfactory(this,"States",new SCreator(States_factory)); -new Sfactory(this,"TypecastExpression_2",new SCreator(TypecastExpression_2_factory)); -new Sfactory(this,"ArgumentList_2",new SCreator(ArgumentList_2_factory)); -new Sfactory(this,"StateBody_14",new SCreator(StateBody_14_factory)); -new Sfactory(this,"KeyArgEvent_1",new SCreator(KeyArgEvent_1_factory)); -new Sfactory(this,"VectorConstant",new SCreator(VectorConstant_factory)); -new Sfactory(this,"SimpleAssignment_3",new SCreator(SimpleAssignment_3_factory)); -new Sfactory(this,"Typename_5",new SCreator(Typename_5_factory)); -new Sfactory(this,"TypecastExpression_8",new SCreator(TypecastExpression_8_factory)); -new Sfactory(this,"SimpleAssignment_21",new SCreator(SimpleAssignment_21_factory)); -new Sfactory(this,"JumpLabel_1",new SCreator(JumpLabel_1_factory)); -new Sfactory(this,"TypecastExpression_4",new SCreator(TypecastExpression_4_factory)); -new Sfactory(this,"JumpStatement_1",new SCreator(JumpStatement_1_factory)); -new Sfactory(this,"VoidArgEvent_8",new SCreator(VoidArgEvent_8_factory)); -new Sfactory(this,"GlobalVariableDeclaration_2",new SCreator(GlobalVariableDeclaration_2_factory)); -new Sfactory(this,"GlobalVariableDeclaration_1",new SCreator(GlobalVariableDeclaration_1_factory)); -new Sfactory(this,"RotDeclaration_1",new SCreator(RotDeclaration_1_factory)); -new Sfactory(this,"WhileStatement_1",new SCreator(WhileStatement_1_factory)); -new Sfactory(this,"VecDeclaration_1",new SCreator(VecDeclaration_1_factory)); -new Sfactory(this,"IntRotRotArgStateEvent",new SCreator(IntRotRotArgStateEvent_factory)); -new Sfactory(this,"Constant_3",new SCreator(Constant_3_factory)); -new Sfactory(this,"Declaration",new SCreator(Declaration_factory)); -new Sfactory(this,"IntVecVecArgStateEvent_1",new SCreator(IntVecVecArgStateEvent_1_factory)); -new Sfactory(this,"ArgumentDeclarationList_5",new SCreator(ArgumentDeclarationList_5_factory)); -new Sfactory(this,"ReturnStatement",new SCreator(ReturnStatement_factory)); -new Sfactory(this,"EmptyStatement_1",new SCreator(EmptyStatement_1_factory)); -} -public static object IncrementDecrementExpression_1_factory(Parser yyp) { return new IncrementDecrementExpression_1(yyp); } -public static object StateChange_factory(Parser yyp) { return new StateChange(yyp); } -public static object ArgumentDeclarationList_3_factory(Parser yyp) { return new ArgumentDeclarationList_3(yyp); } -public static object BinaryExpression_factory(Parser yyp) { return new BinaryExpression(yyp); } -public static object VoidArgEvent_5_factory(Parser yyp) { return new VoidArgEvent_5(yyp); } -public static object IdentDotExpression_1_factory(Parser yyp) { return new IdentDotExpression_1(yyp); } -public static object StateBody_10_factory(Parser yyp) { return new StateBody_10(yyp); } -public static object VectorArgEvent_1_factory(Parser yyp) { return new VectorArgEvent_1(yyp); } -public static object ReturnStatement_1_factory(Parser yyp) { return new ReturnStatement_1(yyp); } -public static object ReturnStatement_2_factory(Parser yyp) { return new ReturnStatement_2(yyp); } -public static object Typename_7_factory(Parser yyp) { return new Typename_7(yyp); } -public static object ExpressionArgument_factory(Parser yyp) { return new ExpressionArgument(yyp); } -public static object ForLoop_factory(Parser yyp) { return new ForLoop(yyp); } -public static object GlobalDefinitions_factory(Parser yyp) { return new GlobalDefinitions(yyp); } -public static object Typename_1_factory(Parser yyp) { return new Typename_1(yyp); } -public static object TypecastExpression_3_factory(Parser yyp) { return new TypecastExpression_3(yyp); } -public static object IncrementDecrementExpression_6_factory(Parser yyp) { return new IncrementDecrementExpression_6(yyp); } -public static object SimpleAssignment_2_factory(Parser yyp) { return new SimpleAssignment_2(yyp); } -public static object IntVecVecArgEvent_1_factory(Parser yyp) { return new IntVecVecArgEvent_1(yyp); } -public static object LSLProgramRoot_2_factory(Parser yyp) { return new LSLProgramRoot_2(yyp); } -public static object IdentDotExpression_factory(Parser yyp) { return new IdentDotExpression(yyp); } -public static object UnaryExpression_1_factory(Parser yyp) { return new UnaryExpression_1(yyp); } -public static object RotationConstant_factory(Parser yyp) { return new RotationConstant(yyp); } -public static object IntArgumentDeclarationList_factory(Parser yyp) { return new IntArgumentDeclarationList(yyp); } -public static object ArgumentList_factory(Parser yyp) { return new ArgumentList(yyp); } -public static object BinaryExpression_3_factory(Parser yyp) { return new BinaryExpression_3(yyp); } -public static object Event_2_factory(Parser yyp) { return new Event_2(yyp); } -public static object ArgumentList_4_factory(Parser yyp) { return new ArgumentList_4(yyp); } -public static object IntVecVecArgEvent_factory(Parser yyp) { return new IntVecVecArgEvent(yyp); } -public static object WhileStatement_2_factory(Parser yyp) { return new WhileStatement_2(yyp); } -public static object Assignment_factory(Parser yyp) { return new Assignment(yyp); } -public static object Statement_12_factory(Parser yyp) { return new Statement_12(yyp); } -public static object IncrementDecrementExpression_8_factory(Parser yyp) { return new IncrementDecrementExpression_8(yyp); } -public static object VectorArgEvent_2_factory(Parser yyp) { return new VectorArgEvent_2(yyp); } -public static object Constant_2_factory(Parser yyp) { return new Constant_2(yyp); } -public static object Statement_1_factory(Parser yyp) { return new Statement_1(yyp); } -public static object VectorArgEvent_factory(Parser yyp) { return new VectorArgEvent(yyp); } -public static object ForLoopStatement_1_factory(Parser yyp) { return new ForLoopStatement_1(yyp); } -public static object IncrementDecrementExpression_2_factory(Parser yyp) { return new IncrementDecrementExpression_2(yyp); } -public static object IntArgumentDeclarationList_1_factory(Parser yyp) { return new IntArgumentDeclarationList_1(yyp); } -public static object VoidArgEvent_4_factory(Parser yyp) { return new VoidArgEvent_4(yyp); } -public static object ForLoop_1_factory(Parser yyp) { return new ForLoop_1(yyp); } -public static object Typename_4_factory(Parser yyp) { return new Typename_4(yyp); } -public static object IdentExpression_factory(Parser yyp) { return new IdentExpression(yyp); } -public static object ForLoop_2_factory(Parser yyp) { return new ForLoop_2(yyp); } -public static object DoWhileStatement_factory(Parser yyp) { return new DoWhileStatement(yyp); } -public static object SimpleAssignment_6_factory(Parser yyp) { return new SimpleAssignment_6(yyp); } -public static object IntDeclaration_1_factory(Parser yyp) { return new IntDeclaration_1(yyp); } -public static object State_1_factory(Parser yyp) { return new State_1(yyp); } -public static object StateBody_9_factory(Parser yyp) { return new StateBody_9(yyp); } -public static object StateBody_8_factory(Parser yyp) { return new StateBody_8(yyp); } -public static object State_2_factory(Parser yyp) { return new State_2(yyp); } -public static object StateBody_3_factory(Parser yyp) { return new StateBody_3(yyp); } -public static object StateBody_2_factory(Parser yyp) { return new StateBody_2(yyp); } -public static object StateBody_1_factory(Parser yyp) { return new StateBody_1(yyp); } -public static object Typename_6_factory(Parser yyp) { return new Typename_6(yyp); } -public static object StateBody_7_factory(Parser yyp) { return new StateBody_7(yyp); } -public static object StateBody_4_factory(Parser yyp) { return new StateBody_4(yyp); } -public static object IfStatement_1_factory(Parser yyp) { return new IfStatement_1(yyp); } -public static object IfStatement_3_factory(Parser yyp) { return new IfStatement_3(yyp); } -public static object IfStatement_2_factory(Parser yyp) { return new IfStatement_2(yyp); } -public static object SimpleAssignment_1_factory(Parser yyp) { return new SimpleAssignment_1(yyp); } -public static object VoidArgEvent_6_factory(Parser yyp) { return new VoidArgEvent_6(yyp); } -public static object IfStatement_factory(Parser yyp) { return new IfStatement(yyp); } -public static object ConstantExpression_factory(Parser yyp) { return new ConstantExpression(yyp); } -public static object BinaryExpression_7_factory(Parser yyp) { return new BinaryExpression_7(yyp); } -public static object IncrementDecrementExpression_factory(Parser yyp) { return new IncrementDecrementExpression(yyp); } -public static object Statement_9_factory(Parser yyp) { return new Statement_9(yyp); } -public static object IntVecVecArgStateEvent_factory(Parser yyp) { return new IntVecVecArgStateEvent(yyp); } -public static object Declaration_1_factory(Parser yyp) { return new Declaration_1(yyp); } -public static object KeyIntIntArgumentDeclarationList_factory(Parser yyp) { return new KeyIntIntArgumentDeclarationList(yyp); } -public static object VectorArgumentDeclarationList_1_factory(Parser yyp) { return new VectorArgumentDeclarationList_1(yyp); } -public static object SimpleAssignment_factory(Parser yyp) { return new SimpleAssignment(yyp); } -public static object BinaryExpression_9_factory(Parser yyp) { return new BinaryExpression_9(yyp); } -public static object IntDeclaration_factory(Parser yyp) { return new IntDeclaration(yyp); } -public static object IntArgEvent_10_factory(Parser yyp) { return new IntArgEvent_10(yyp); } -public static object ArgumentDeclarationList_2_factory(Parser yyp) { return new ArgumentDeclarationList_2(yyp); } -public static object ArgumentDeclarationList_1_factory(Parser yyp) { return new ArgumentDeclarationList_1(yyp); } -public static object ArgumentDeclarationList_4_factory(Parser yyp) { return new ArgumentDeclarationList_4(yyp); } -public static object SimpleAssignment_9_factory(Parser yyp) { return new SimpleAssignment_9(yyp); } -public static object ForLoopStatement_2_factory(Parser yyp) { return new ForLoopStatement_2(yyp); } -public static object StatementList_factory(Parser yyp) { return new StatementList(yyp); } -public static object StateBody_13_factory(Parser yyp) { return new StateBody_13(yyp); } -public static object Typename_3_factory(Parser yyp) { return new Typename_3(yyp); } -public static object KeyArgumentDeclarationList_1_factory(Parser yyp) { return new KeyArgumentDeclarationList_1(yyp); } -public static object UnaryExpression_3_factory(Parser yyp) { return new UnaryExpression_3(yyp); } -public static object StateBody_16_factory(Parser yyp) { return new StateBody_16(yyp); } -public static object VectorArgumentDeclarationList_factory(Parser yyp) { return new VectorArgumentDeclarationList(yyp); } -public static object IntArgEvent_3_factory(Parser yyp) { return new IntArgEvent_3(yyp); } -public static object StatementList_2_factory(Parser yyp) { return new StatementList_2(yyp); } -public static object KeyArgStateEvent_factory(Parser yyp) { return new KeyArgStateEvent(yyp); } -public static object LSLProgramRoot_1_factory(Parser yyp) { return new LSLProgramRoot_1(yyp); } -public static object Typename_2_factory(Parser yyp) { return new Typename_2(yyp); } -public static object TypecastExpression_6_factory(Parser yyp) { return new TypecastExpression_6(yyp); } -public static object Event_3_factory(Parser yyp) { return new Event_3(yyp); } -public static object IntArgStateEvent_factory(Parser yyp) { return new IntArgStateEvent(yyp); } -public static object StateChange_2_factory(Parser yyp) { return new StateChange_2(yyp); } -public static object StateChange_1_factory(Parser yyp) { return new StateChange_1(yyp); } -public static object VectorConstant_1_factory(Parser yyp) { return new VectorConstant_1(yyp); } -public static object KeyDeclaration_factory(Parser yyp) { return new KeyDeclaration(yyp); } -public static object States_2_factory(Parser yyp) { return new States_2(yyp); } -public static object VoidArgEvent_factory(Parser yyp) { return new VoidArgEvent(yyp); } -public static object WhileStatement_factory(Parser yyp) { return new WhileStatement(yyp); } -public static object UnaryExpression_factory(Parser yyp) { return new UnaryExpression(yyp); } -public static object BinaryExpression_6_factory(Parser yyp) { return new BinaryExpression_6(yyp); } -public static object ConstantExpression_1_factory(Parser yyp) { return new ConstantExpression_1(yyp); } -public static object ForLoopStatement_factory(Parser yyp) { return new ForLoopStatement(yyp); } -public static object BinaryExpression_1_factory(Parser yyp) { return new BinaryExpression_1(yyp); } -public static object StateEvent_factory(Parser yyp) { return new StateEvent(yyp); } -public static object Event_5_factory(Parser yyp) { return new Event_5(yyp); } -public static object SimpleAssignment_5_factory(Parser yyp) { return new SimpleAssignment_5(yyp); } -public static object RotationConstant_1_factory(Parser yyp) { return new RotationConstant_1(yyp); } -public static object Constant_factory(Parser yyp) { return new Constant(yyp); } -public static object IntArgEvent_1_factory(Parser yyp) { return new IntArgEvent_1(yyp); } -public static object SimpleAssignment_8_factory(Parser yyp) { return new SimpleAssignment_8(yyp); } -public static object ForLoopStatement_3_factory(Parser yyp) { return new ForLoopStatement_3(yyp); } -public static object IntArgEvent_2_factory(Parser yyp) { return new IntArgEvent_2(yyp); } -public static object LSLProgramRoot_factory(Parser yyp) { return new LSLProgramRoot(yyp); } -public static object StateBody_12_factory(Parser yyp) { return new StateBody_12(yyp); } -public static object IntArgEvent_4_factory(Parser yyp) { return new IntArgEvent_4(yyp); } -public static object IntArgEvent_7_factory(Parser yyp) { return new IntArgEvent_7(yyp); } -public static object IntArgEvent_6_factory(Parser yyp) { return new IntArgEvent_6(yyp); } -public static object IntArgEvent_9_factory(Parser yyp) { return new IntArgEvent_9(yyp); } -public static object TypecastExpression_7_factory(Parser yyp) { return new TypecastExpression_7(yyp); } -public static object StateBody_15_factory(Parser yyp) { return new StateBody_15(yyp); } -public static object VoidArgStateEvent_1_factory(Parser yyp) { return new VoidArgStateEvent_1(yyp); } -public static object error_factory(Parser yyp) { return new error(yyp); } -public static object TypecastExpression_1_factory(Parser yyp) { return new TypecastExpression_1(yyp); } -public static object GlobalDefinitions_4_factory(Parser yyp) { return new GlobalDefinitions_4(yyp); } -public static object GlobalDefinitions_3_factory(Parser yyp) { return new GlobalDefinitions_3(yyp); } -public static object GlobalDefinitions_2_factory(Parser yyp) { return new GlobalDefinitions_2(yyp); } -public static object GlobalDefinitions_1_factory(Parser yyp) { return new GlobalDefinitions_1(yyp); } -public static object ArgumentList_1_factory(Parser yyp) { return new ArgumentList_1(yyp); } -public static object IncrementDecrementExpression_7_factory(Parser yyp) { return new IncrementDecrementExpression_7(yyp); } -public static object UnaryExpression_2_factory(Parser yyp) { return new UnaryExpression_2(yyp); } -public static object Argument_factory(Parser yyp) { return new Argument(yyp); } -public static object SimpleAssignment_24_factory(Parser yyp) { return new SimpleAssignment_24(yyp); } -public static object ExpressionArgument_1_factory(Parser yyp) { return new ExpressionArgument_1(yyp); } -public static object EmptyStatement_factory(Parser yyp) { return new EmptyStatement(yyp); } -public static object KeyIntIntArgStateEvent_factory(Parser yyp) { return new KeyIntIntArgStateEvent(yyp); } -public static object VectorArgStateEvent_1_factory(Parser yyp) { return new VectorArgStateEvent_1(yyp); } -public static object GlobalFunctionDefinition_1_factory(Parser yyp) { return new GlobalFunctionDefinition_1(yyp); } -public static object FunctionCallExpression_1_factory(Parser yyp) { return new FunctionCallExpression_1(yyp); } -public static object DoWhileStatement_2_factory(Parser yyp) { return new DoWhileStatement_2(yyp); } -public static object VoidArgEvent_1_factory(Parser yyp) { return new VoidArgEvent_1(yyp); } -public static object KeyArgumentDeclarationList_factory(Parser yyp) { return new KeyArgumentDeclarationList(yyp); } -public static object KeyIntIntArgEvent_factory(Parser yyp) { return new KeyIntIntArgEvent(yyp); } -public static object ListConstant_1_factory(Parser yyp) { return new ListConstant_1(yyp); } -public static object StateEvent_1_factory(Parser yyp) { return new StateEvent_1(yyp); } -public static object SimpleAssignment_20_factory(Parser yyp) { return new SimpleAssignment_20(yyp); } -public static object SimpleAssignment_23_factory(Parser yyp) { return new SimpleAssignment_23(yyp); } -public static object SimpleAssignment_22_factory(Parser yyp) { return new SimpleAssignment_22(yyp); } -public static object IntArgEvent_5_factory(Parser yyp) { return new IntArgEvent_5(yyp); } -public static object ParenthesisExpression_factory(Parser yyp) { return new ParenthesisExpression(yyp); } -public static object JumpStatement_factory(Parser yyp) { return new JumpStatement(yyp); } -public static object IntRotRotArgumentDeclarationList_1_factory(Parser yyp) { return new IntRotRotArgumentDeclarationList_1(yyp); } -public static object SimpleAssignment_4_factory(Parser yyp) { return new SimpleAssignment_4(yyp); } -public static object KeyArgEvent_factory(Parser yyp) { return new KeyArgEvent(yyp); } -public static object Assignment_2_factory(Parser yyp) { return new Assignment_2(yyp); } -public static object ForLoopStatement_4_factory(Parser yyp) { return new ForLoopStatement_4(yyp); } -public static object Statement_13_factory(Parser yyp) { return new Statement_13(yyp); } -public static object RotDeclaration_factory(Parser yyp) { return new RotDeclaration(yyp); } -public static object StateBody_11_factory(Parser yyp) { return new StateBody_11(yyp); } -public static object KeyArgEvent_2_factory(Parser yyp) { return new KeyArgEvent_2(yyp); } -public static object StatementList_1_factory(Parser yyp) { return new StatementList_1(yyp); } -public static object StateBody_6_factory(Parser yyp) { return new StateBody_6(yyp); } -public static object Constant_1_factory(Parser yyp) { return new Constant_1(yyp); } -public static object VecDeclaration_factory(Parser yyp) { return new VecDeclaration(yyp); } -public static object TypecastExpression_5_factory(Parser yyp) { return new TypecastExpression_5(yyp); } -public static object GlobalFunctionDefinition_2_factory(Parser yyp) { return new GlobalFunctionDefinition_2(yyp); } -public static object KeyIntIntArgEvent_1_factory(Parser yyp) { return new KeyIntIntArgEvent_1(yyp); } -public static object Constant_4_factory(Parser yyp) { return new Constant_4(yyp); } -public static object TypecastExpression_9_factory(Parser yyp) { return new TypecastExpression_9(yyp); } -public static object IntRotRotArgStateEvent_1_factory(Parser yyp) { return new IntRotRotArgStateEvent_1(yyp); } -public static object IncrementDecrementExpression_3_factory(Parser yyp) { return new IncrementDecrementExpression_3(yyp); } -public static object States_1_factory(Parser yyp) { return new States_1(yyp); } -public static object GlobalVariableDeclaration_factory(Parser yyp) { return new GlobalVariableDeclaration(yyp); } -public static object VoidArgEvent_3_factory(Parser yyp) { return new VoidArgEvent_3(yyp); } -public static object Assignment_1_factory(Parser yyp) { return new Assignment_1(yyp); } -public static object BinaryExpression_5_factory(Parser yyp) { return new BinaryExpression_5(yyp); } -public static object IfStatement_4_factory(Parser yyp) { return new IfStatement_4(yyp); } -public static object IntVecVecArgumentDeclarationList_1_factory(Parser yyp) { return new IntVecVecArgumentDeclarationList_1(yyp); } -public static object KeyIntIntArgumentDeclarationList_1_factory(Parser yyp) { return new KeyIntIntArgumentDeclarationList_1(yyp); } -public static object Statement_factory(Parser yyp) { return new Statement(yyp); } -public static object ParenthesisExpression_1_factory(Parser yyp) { return new ParenthesisExpression_1(yyp); } -public static object ParenthesisExpression_2_factory(Parser yyp) { return new ParenthesisExpression_2(yyp); } -public static object DoWhileStatement_1_factory(Parser yyp) { return new DoWhileStatement_1(yyp); } -public static object VoidArgStateEvent_factory(Parser yyp) { return new VoidArgStateEvent(yyp); } -public static object GlobalFunctionDefinition_factory(Parser yyp) { return new GlobalFunctionDefinition(yyp); } -public static object Event_4_factory(Parser yyp) { return new Event_4(yyp); } -public static object IntArgEvent_factory(Parser yyp) { return new IntArgEvent(yyp); } -public static object SimpleAssignment_11_factory(Parser yyp) { return new SimpleAssignment_11(yyp); } -public static object SimpleAssignment_10_factory(Parser yyp) { return new SimpleAssignment_10(yyp); } -public static object SimpleAssignment_13_factory(Parser yyp) { return new SimpleAssignment_13(yyp); } -public static object SimpleAssignment_12_factory(Parser yyp) { return new SimpleAssignment_12(yyp); } -public static object SimpleAssignment_15_factory(Parser yyp) { return new SimpleAssignment_15(yyp); } -public static object SimpleAssignment_14_factory(Parser yyp) { return new SimpleAssignment_14(yyp); } -public static object SimpleAssignment_17_factory(Parser yyp) { return new SimpleAssignment_17(yyp); } -public static object SimpleAssignment_16_factory(Parser yyp) { return new SimpleAssignment_16(yyp); } -public static object SimpleAssignment_19_factory(Parser yyp) { return new SimpleAssignment_19(yyp); } -public static object SimpleAssignment_18_factory(Parser yyp) { return new SimpleAssignment_18(yyp); } -public static object IntVecVecArgumentDeclarationList_factory(Parser yyp) { return new IntVecVecArgumentDeclarationList(yyp); } -public static object StateBody_5_factory(Parser yyp) { return new StateBody_5(yyp); } -public static object BinaryExpression_17_factory(Parser yyp) { return new BinaryExpression_17(yyp); } -public static object BinaryExpression_16_factory(Parser yyp) { return new BinaryExpression_16(yyp); } -public static object BinaryExpression_15_factory(Parser yyp) { return new BinaryExpression_15(yyp); } -public static object BinaryExpression_14_factory(Parser yyp) { return new BinaryExpression_14(yyp); } -public static object BinaryExpression_13_factory(Parser yyp) { return new BinaryExpression_13(yyp); } -public static object BinaryExpression_12_factory(Parser yyp) { return new BinaryExpression_12(yyp); } -public static object BinaryExpression_11_factory(Parser yyp) { return new BinaryExpression_11(yyp); } -public static object BinaryExpression_10_factory(Parser yyp) { return new BinaryExpression_10(yyp); } -public static object VectorArgStateEvent_factory(Parser yyp) { return new VectorArgStateEvent(yyp); } -public static object Statement_10_factory(Parser yyp) { return new Statement_10(yyp); } -public static object BinaryExpression_8_factory(Parser yyp) { return new BinaryExpression_8(yyp); } -public static object BinaryExpression_18_factory(Parser yyp) { return new BinaryExpression_18(yyp); } -public static object BinaryExpression_2_factory(Parser yyp) { return new BinaryExpression_2(yyp); } -public static object FunctionCallExpression_factory(Parser yyp) { return new FunctionCallExpression(yyp); } -public static object VectorArgEvent_3_factory(Parser yyp) { return new VectorArgEvent_3(yyp); } -public static object IdentExpression_1_factory(Parser yyp) { return new IdentExpression_1(yyp); } -public static object IntArgEvent_8_factory(Parser yyp) { return new IntArgEvent_8(yyp); } -public static object VoidArgEvent_7_factory(Parser yyp) { return new VoidArgEvent_7(yyp); } -public static object IncrementDecrementExpression_4_factory(Parser yyp) { return new IncrementDecrementExpression_4(yyp); } -public static object FunctionCall_factory(Parser yyp) { return new FunctionCall(yyp); } -public static object ArgumentList_3_factory(Parser yyp) { return new ArgumentList_3(yyp); } -public static object KeyIntIntArgStateEvent_1_factory(Parser yyp) { return new KeyIntIntArgStateEvent_1(yyp); } -public static object IntRotRotArgumentDeclarationList_factory(Parser yyp) { return new IntRotRotArgumentDeclarationList(yyp); } -public static object KeyDeclaration_1_factory(Parser yyp) { return new KeyDeclaration_1(yyp); } -public static object BinaryExpression_4_factory(Parser yyp) { return new BinaryExpression_4(yyp); } -public static object FunctionCall_1_factory(Parser yyp) { return new FunctionCall_1(yyp); } -public static object KeyArgStateEvent_1_factory(Parser yyp) { return new KeyArgStateEvent_1(yyp); } -public static object IntArgStateEvent_1_factory(Parser yyp) { return new IntArgStateEvent_1(yyp); } -public static object Event_factory(Parser yyp) { return new Event(yyp); } -public static object IntRotRotArgEvent_factory(Parser yyp) { return new IntRotRotArgEvent(yyp); } -public static object SimpleAssignment_7_factory(Parser yyp) { return new SimpleAssignment_7(yyp); } -public static object Statement_3_factory(Parser yyp) { return new Statement_3(yyp); } -public static object Expression_factory(Parser yyp) { return new Expression(yyp); } -public static object CompoundStatement_2_factory(Parser yyp) { return new CompoundStatement_2(yyp); } -public static object CompoundStatement_1_factory(Parser yyp) { return new CompoundStatement_1(yyp); } -public static object JumpLabel_factory(Parser yyp) { return new JumpLabel(yyp); } -public static object State_factory(Parser yyp) { return new State(yyp); } -public static object TypecastExpression_factory(Parser yyp) { return new TypecastExpression(yyp); } -public static object IntRotRotArgEvent_1_factory(Parser yyp) { return new IntRotRotArgEvent_1(yyp); } -public static object Statement_11_factory(Parser yyp) { return new Statement_11(yyp); } -public static object VoidArgEvent_2_factory(Parser yyp) { return new VoidArgEvent_2(yyp); } -public static object Typename_factory(Parser yyp) { return new Typename(yyp); } -public static object ArgumentDeclarationList_factory(Parser yyp) { return new ArgumentDeclarationList(yyp); } -public static object StateBody_factory(Parser yyp) { return new StateBody(yyp); } -public static object Event_8_factory(Parser yyp) { return new Event_8(yyp); } -public static object Event_9_factory(Parser yyp) { return new Event_9(yyp); } -public static object Event_6_factory(Parser yyp) { return new Event_6(yyp); } -public static object Event_7_factory(Parser yyp) { return new Event_7(yyp); } -public static object Statement_8_factory(Parser yyp) { return new Statement_8(yyp); } -public static object CompoundStatement_factory(Parser yyp) { return new CompoundStatement(yyp); } -public static object Event_1_factory(Parser yyp) { return new Event_1(yyp); } -public static object Statement_4_factory(Parser yyp) { return new Statement_4(yyp); } -public static object Statement_5_factory(Parser yyp) { return new Statement_5(yyp); } -public static object Statement_6_factory(Parser yyp) { return new Statement_6(yyp); } -public static object Statement_7_factory(Parser yyp) { return new Statement_7(yyp); } -public static object IncrementDecrementExpression_5_factory(Parser yyp) { return new IncrementDecrementExpression_5(yyp); } -public static object Statement_2_factory(Parser yyp) { return new Statement_2(yyp); } -public static object ListConstant_factory(Parser yyp) { return new ListConstant(yyp); } -public static object States_factory(Parser yyp) { return new States(yyp); } -public static object TypecastExpression_2_factory(Parser yyp) { return new TypecastExpression_2(yyp); } -public static object ArgumentList_2_factory(Parser yyp) { return new ArgumentList_2(yyp); } -public static object StateBody_14_factory(Parser yyp) { return new StateBody_14(yyp); } -public static object KeyArgEvent_1_factory(Parser yyp) { return new KeyArgEvent_1(yyp); } -public static object VectorConstant_factory(Parser yyp) { return new VectorConstant(yyp); } -public static object SimpleAssignment_3_factory(Parser yyp) { return new SimpleAssignment_3(yyp); } -public static object Typename_5_factory(Parser yyp) { return new Typename_5(yyp); } -public static object TypecastExpression_8_factory(Parser yyp) { return new TypecastExpression_8(yyp); } -public static object SimpleAssignment_21_factory(Parser yyp) { return new SimpleAssignment_21(yyp); } -public static object JumpLabel_1_factory(Parser yyp) { return new JumpLabel_1(yyp); } -public static object TypecastExpression_4_factory(Parser yyp) { return new TypecastExpression_4(yyp); } -public static object JumpStatement_1_factory(Parser yyp) { return new JumpStatement_1(yyp); } -public static object VoidArgEvent_8_factory(Parser yyp) { return new VoidArgEvent_8(yyp); } -public static object GlobalVariableDeclaration_2_factory(Parser yyp) { return new GlobalVariableDeclaration_2(yyp); } -public static object GlobalVariableDeclaration_1_factory(Parser yyp) { return new GlobalVariableDeclaration_1(yyp); } -public static object RotDeclaration_1_factory(Parser yyp) { return new RotDeclaration_1(yyp); } -public static object WhileStatement_1_factory(Parser yyp) { return new WhileStatement_1(yyp); } -public static object VecDeclaration_1_factory(Parser yyp) { return new VecDeclaration_1(yyp); } -public static object IntRotRotArgStateEvent_factory(Parser yyp) { return new IntRotRotArgStateEvent(yyp); } -public static object Constant_3_factory(Parser yyp) { return new Constant_3(yyp); } -public static object Declaration_factory(Parser yyp) { return new Declaration(yyp); } -public static object IntVecVecArgStateEvent_1_factory(Parser yyp) { return new IntVecVecArgStateEvent_1(yyp); } -public static object ArgumentDeclarationList_5_factory(Parser yyp) { return new ArgumentDeclarationList_5(yyp); } -public static object ReturnStatement_factory(Parser yyp) { return new ReturnStatement(yyp); } -public static object EmptyStatement_1_factory(Parser yyp) { return new EmptyStatement_1(yyp); } -} -public class LSLSyntax -: Parser { -public LSLSyntax -():base(new yyLSLSyntax -(),new LSLTokens()) {} -public LSLSyntax -(YyParser syms):base(syms,new LSLTokens()) {} -public LSLSyntax -(YyParser syms,ErrorHandler erh):base(syms,new LSLTokens(erh)) {} - - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index c6fcf894452..38d98811682 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -202,11 +202,7 @@ public void Populate(Scene scene) Owner = Key; Position = new LSL_Types.Vector3(presence.AbsolutePosition); - Rotation = new LSL_Types.Quaternion( - presence.Rotation.X, - presence.Rotation.Y, - presence.Rotation.Z, - presence.Rotation.W); + Rotation = new LSL_Types.Quaternion(presence.Rotation); Velocity = new LSL_Types.Vector3(presence.Velocity); Type = 0x01; // Avatar diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/OpenSim.Region.ScriptEngine.Shared.Instance.csproj b/OpenSim/Region/ScriptEngine/Shared/Instance/OpenSim.Region.ScriptEngine.Shared.Instance.csproj index 8be905dbfcf..75b4ead7125 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/OpenSim.Region.ScriptEngine.Shared.Instance.csproj +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/OpenSim.Region.ScriptEngine.Shared.Instance.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.ScriptEngine.Shared.Instance http://opensimulator.org OpenSim diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs deleted file mode 100644 index 411d49c7592..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +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("OpenSim.Region.ScriptEngine.Shared.Instance")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://opensimulator.org")] -[assembly: AssemblyProduct("OpenSim")] -[assembly: AssemblyCopyright("OpenSimulator developers")] -[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("b776d846-68c1-43a2-9e72-9bd1fe20fd41")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] - diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs deleted file mode 100644 index d9c10c02caa..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ /dev/null @@ -1,1405 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Globalization; -using System.IO; -using System.Reflection; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Lifetime; -using System.Security.Policy; -using System.Text; -using System.Threading; -using System.Xml; -using OpenMetaverse; -using log4net; -using Nini.Config; -using Amib.Threading; -using OpenSim.Framework; -using OpenSim.Region.CoreModules; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Region.ScriptEngine.Interfaces; - -using System.Diagnostics; //for [DebuggerNonUserCode] - -namespace OpenSim.Region.ScriptEngine.Shared.Instance -{ - public class ScriptInstance : MarshalByRefObject, IScriptInstance - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public bool StatePersistedHere { get { return m_AttachedAvatar.IsZero(); } } - - /// - /// The current work item if an event for this script is running or waiting to run, - /// - /// - /// Null if there is no running or waiting to run event. Must be changed only under an EventQueue lock. - /// - private IScriptWorkItem m_CurrentWorkItem; - - private IScript m_Script; - private DetectParams[] m_DetectParams; - private bool m_TimerQueued; - private DateTime m_EventStart; - private bool m_InEvent; - private string m_assemblyPath; - private string m_dataPath; - private string m_CurrentEvent = String.Empty; - private bool m_InSelfDelete; - private int m_MaxScriptQueue; - private bool m_SaveState; - private int m_ControlEventsInQueue; - private int m_LastControlLevel; - private bool m_CollisionInQueue; - private bool m_StateChangeInProgress; - - // The following is for setting a minimum delay between events - private double m_minEventDelay; - - private long m_eventDelayTicks; - private long m_nextEventTimeTicks; - private bool m_startOnInit = true; - private UUID m_AttachedAvatar; - private StateSource m_stateSource; - private bool m_postOnRez; - private bool m_startedFromSavedState; - private UUID m_CurrentStateHash; - private UUID m_RegionID; - - public int DebugLevel { get; set; } - - public WaitHandle CoopWaitHandle { get; private set; } - public Stopwatch ExecutionTimer { get; private set; } - - public Dictionary, KeyValuePair> LineMap { get; set; } - - private Dictionary m_Apis = new Dictionary(); - - public Object[] PluginData = new Object[0]; - - /// - /// Used by llMinEventDelay to suppress events happening any faster than this speed. - /// This currently restricts all events in one go. Not sure if each event type has - /// its own check so take the simple route first. - /// - public double MinEventDelay - { - get { return m_minEventDelay; } - set - { - if (value > 0.001) - m_minEventDelay = value; - else - m_minEventDelay = 0.0; - - m_eventDelayTicks = (long)(m_minEventDelay * 10000000L); - m_nextEventTimeTicks = DateTime.Now.Ticks; - } - } - - public bool Running - { - get { return m_running; } - - set - { - m_running = value; - if (m_running) - StayStopped = false; - } - } - private bool m_running; - - public bool Suspended - { - get { return m_Suspended; } - - set - { - // Need to do this inside a lock in order to avoid races with EventProcessor() - lock (m_Script) - { - bool wasSuspended = m_Suspended; - m_Suspended = value; - - if (wasSuspended && !m_Suspended) - { - lock (EventQueue) - { - // Need to place ourselves back in a work item if there are events to process - if (EventQueue.Count > 0 && Running && !ShuttingDown) - m_CurrentWorkItem = Engine.QueueEventHandler(this); - } - } - } - } - } - private bool m_Suspended; - - public bool ShuttingDown { get; set; } - - public string State { get; set; } - - public bool StayStopped { get; set; } - - public IScriptEngine Engine { get; private set; } - - public UUID AppDomain { get; set; } - - public SceneObjectPart Part { get; private set; } - - public string PrimName { get; private set; } - - public string ScriptName { get; private set; } - - public UUID ItemID { get; private set; } - - public UUID ObjectID { get { return Part.UUID; } } - - public uint LocalID { get { return Part.LocalId; } } - - public UUID RootObjectID { get { return Part.ParentGroup.UUID; } } - - public uint RootLocalID { get { return Part.ParentGroup.LocalId; } } - - public UUID AssetID { get; private set; } - - public Queue EventQueue { get; private set; } - - public long EventsQueued - { - get - { - lock (EventQueue) - return EventQueue.Count; - } - } - - public long EventsProcessed { get; private set; } - - public int StartParam { get; set; } - - public TaskInventoryItem ScriptTask { get; private set; } - - public DateTime TimeStarted { get; private set; } - - public MetricsCollectorTime ExecutionTime { get; private set; } - - private static readonly int MeasurementWindow = 30 * 1000; // show the *recent* time used by the script, to find currently active scripts - - private bool m_coopTermination; - - private EventWaitHandle m_coopSleepHandle; - - public void ClearQueue() - { - m_TimerQueued = false; - m_StateChangeInProgress = false; - EventQueue.Clear(); - } - - public ScriptInstance( - IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item, - int startParam, bool postOnRez, - int maxScriptQueue) - { - State = "default"; - EventQueue = new Queue(32); - ExecutionTimer = new Stopwatch(); - - Engine = engine; - Part = part; - ScriptTask = item; - - // This is currently only here to allow regression tests to get away without specifying any inventory - // item when they are testing script logic that doesn't require an item. - if (ScriptTask != null) - { - ScriptName = ScriptTask.Name; - ItemID = ScriptTask.ItemID; - AssetID = ScriptTask.AssetID; - } - - PrimName = part.ParentGroup.Name; - StartParam = startParam; - m_MaxScriptQueue = maxScriptQueue; - m_postOnRez = postOnRez; - m_AttachedAvatar = part.ParentGroup.AttachedAvatar; - m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; - - m_SaveState = StatePersistedHere; - - ExecutionTime = new MetricsCollectorTime(MeasurementWindow, 10); - - //m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Instantiated script instance {0} (id {1}) in part {2} (id {3}) in object {4} attached avatar {5} in {6}", - // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, m_AttachedAvatar, Engine.World.Name); - } - - /// - /// Load the script from an assembly into an AppDomain. - /// - /// - /// - /// - /// Path for all script associated data (state, etc.). In a multi-region set up - /// with all scripts loading into the same AppDomain this may not be the same place as the DLL itself. - /// - /// - /// false if load failed, true if suceeded - public bool Load( - IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, - string dataPath, StateSource stateSource, bool coopTermination) - { - m_Script = script; - m_coopSleepHandle = coopSleepHandle; - m_assemblyPath = assemblyPath; - m_dataPath = dataPath; - m_stateSource = stateSource; - m_coopTermination = coopTermination; - - if (m_coopTermination) - CoopWaitHandle = coopSleepHandle; - else - CoopWaitHandle = null; - - ApiManager am = new ApiManager(); - - foreach (string api in am.GetApis()) - { - m_Apis[api] = am.CreateApi(api); - m_Apis[api].Initialize(Engine, Part, ScriptTask); - } - - try - { - foreach (KeyValuePair kv in m_Apis) - { - m_Script.InitApi(kv.Key, kv.Value); - } - } - catch (Exception e) - { - m_log.ErrorFormat( - "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error initializing script instance. Exception {6}{7}", - ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, e.Message, e.StackTrace); - - return false; - } - - // For attachments, XEngine saves the state into a .state file when XEngine.SetXMLState() is called. - string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); - - if (File.Exists(savedState)) - { - // m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", - // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); - - string xml = String.Empty; - - try - { - FileInfo fi = new FileInfo(savedState); - int size = (int)fi.Length; - if (size < 512000) - { - using (FileStream fs = File.Open(savedState, - FileMode.Open, FileAccess.Read, FileShare.None)) - { - Byte[] data = new Byte[size]; - fs.Read(data, 0, size); - - xml = Encoding.UTF8.GetString(data); - - ScriptSerializer.Deserialize(xml, this); - - AsyncCommandManager.CreateFromData(Engine, - LocalID, ItemID, ObjectID, - PluginData); - - //m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); - - if (!Running) - m_startOnInit = false; - - Running = false; - - // we get new rez events on sim restart, too - // but if there is state, then we fire the change - // event - - // We loaded state, don't force a re-save - m_SaveState = false; - m_startedFromSavedState = true; - } - - // If this script is in an attachment then we no longer need the state file. - if (!StatePersistedHere) - RemoveState(); - } - //else - //{ - // m_log.WarnFormat( - // "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", - // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); - //} - } - catch (Exception e) - { - m_log.ErrorFormat( - "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. XML is {7}. Exception {8}{9}", - ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState, xml, e.Message, e.StackTrace); - } - } - //else - //{ - // m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", - // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); - //} - try - { - Part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State)); - } - catch - { - m_log.ErrorFormat("[SCRIPT INSTANCE]: failed to SetScriptEvents {0}", ItemID); - } - - return true; - } - - public void Init() - { - if (ShuttingDown) - return; - - if (m_startOnInit) - Start(); - - if (m_startedFromSavedState) - { - if (m_postOnRez) - { - PostEvent(new EventParams("on_rez", - new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); - } - switch(m_stateSource) - { - case StateSource.AttachedRez: - PostEvent(new EventParams("attach", - new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); - break; - case StateSource.RegionStart: - //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); - PostEvent(new EventParams("changed", - new Object[] {new LSL_Types.LSLInteger((int)Changed.REGION_RESTART)}, new DetectParams[0])); - break; - case StateSource.PrimCrossing: - PostEvent(new EventParams("changed", - new Object[] {new LSL_Types.LSLInteger((int)Changed.REGION)}, new DetectParams[0])); - break; - case StateSource.Teleporting: - PostEvent(new EventParams("changed", - new Object[] {new LSL_Types.LSLInteger((int)Changed.REGION | (int)Changed.TELEPORT) }, new DetectParams[0])); - break; - } - } - else - { - if(Running & ScriptTask.ScriptRunning) - PostEvent(EventParams.StateEntryParams); - else - QueueEvent(EventParams.StateEntryParams); - - if (m_postOnRez) - { - PostEvent(new EventParams("on_rez", - new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); - } - - if (m_stateSource == StateSource.AttachedRez) - { - PostEvent(new EventParams("attach", - new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0])); - } - } - } - - private void ReleaseControlsorPermissions(bool fullpermissions) - { - SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); - - if (part != null && part.TaskInventory != null) - { - int permsMask; - UUID permsGranter; - part.TaskInventory.LockItemsForWrite(true); - if (!part.TaskInventory.TryGetValue(ItemID, out TaskInventoryItem item)) - { - part.TaskInventory.LockItemsForWrite(false); - return; - } - permsGranter = item.PermsGranter; - permsMask = item.PermsMask; - if(fullpermissions) - { - item.PermsGranter = UUID.Zero; - item.PermsMask = 0; - } - else - item.PermsMask = permsMask & ~(ScriptBaseClass.PERMISSION_TAKE_CONTROLS | ScriptBaseClass.PERMISSION_CONTROL_CAMERA); - part.TaskInventory.LockItemsForWrite(false); - - if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) - { - ScenePresence presence = Engine.World.GetScenePresence(permsGranter); - if (presence != null) - presence.UnRegisterControlEventsToScript(LocalID, ItemID); - } - } - } - - public void DestroyScriptInstance() - { - ReleaseControlsorPermissions(false); - AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); - SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); - if (part != null) - part.RemoveScriptEvents(ItemID); - } - - public void RemoveState() - { - string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); - -// m_log.DebugFormat( -// "[SCRIPT INSTANCE]: Deleting state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}.", -// savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name); - - try - { - File.Delete(savedState); - } - catch (Exception e) - { - m_log.Warn( - string.Format( - "[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ", - savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name), - e); - } - } - - public void VarDump(Dictionary vars) - { - // m_log.Info("Variable dump for script "+ ItemID.ToString()); - // foreach (KeyValuePair v in vars) - // { - // m_log.Info("Variable: "+v.Key+" = "+v.Value.ToString()); - // } - } - - public void Start() - { - lock (EventQueue) - { - if (Running) - return; - - Running = true; - - TimeStarted = DateTime.Now; - - // Note: we don't reset ExecutionTime. The reason is that runaway scripts are stopped and restarted - // automatically, and we *do* want to show that they had high CPU in that case. If we had reset - // ExecutionTime here then runaway scripts, paradoxically, would never show up in the "Top Scripts" dialog. - - if (EventQueue.Count > 0) - { - if (m_CurrentWorkItem == null) - m_CurrentWorkItem = Engine.QueueEventHandler(this); - // else - // m_log.Error("[Script] Tried to start a script that was already queued"); - } - } - } - - public bool Stop(int timeout, bool clearEventQueue = false) - { - if (DebugLevel >= 1) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Stopping script {0} {1} in {2} {3} with timeout {4} {5} {6}", - ScriptName, ItemID, PrimName, ObjectID, timeout, m_InSelfDelete, DateTime.Now.Ticks); - - IScriptWorkItem workItem; - - lock (EventQueue) - { - if (clearEventQueue) - ClearQueue(); - - if (!Running) - return true; - - // If we're not running or waiting to run an event then we can safely stop. - if (m_CurrentWorkItem == null) - { - Running = false; - return true; - } - - // If we are waiting to run an event then we can try to cancel it. - if (m_CurrentWorkItem.Cancel()) - { - m_CurrentWorkItem = null; - Running = false; - return true; - } - - workItem = m_CurrentWorkItem; - Running = false; - } - - // Wait for the current event to complete. - if (!m_InSelfDelete) - { - if (!m_coopTermination) - { - // If we're not co-operative terminating then try and wait for the event to complete before stopping - if (workItem.Wait(timeout)) - return true; - } - else - { - if (DebugLevel >= 1) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", - ScriptName, ItemID, PrimName, ObjectID); - - // This will terminate the event on next handle check by the script. - m_coopSleepHandle.Set(); - - // For now, we will wait forever since the event should always cleanly terminate once LSL loop - // checking is implemented. May want to allow a shorter timeout option later. - if (workItem.Wait(Timeout.Infinite)) - { - if (DebugLevel >= 1) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", - ScriptName, ItemID, PrimName, ObjectID); - - return true; - } - } - } - - lock (EventQueue) - { - workItem = m_CurrentWorkItem; - } - - if (workItem == null) - return true; - - // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then - // forcibly abort the work item (this aborts the underlying thread). - // Co-operative termination should never reach this point. - if (!m_InSelfDelete) - { - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", - ScriptName, ItemID, PrimName, LocalID, timeout); - - workItem.Abort(); - } - - lock (EventQueue) - { - m_CurrentWorkItem = null; - } - - return true; - } - - [DebuggerNonUserCode] //Prevents the debugger from farting in this function - public void SetState(string state) - { - if (state == State) - return; - - EventParams lastTimerEv = null; - - lock (EventQueue) - { - // Remove all queued events, remembering the last timer event - while (EventQueue.Count > 0) - { - EventParams tempv = (EventParams)EventQueue.Dequeue(); - if (tempv.EventName == "timer") lastTimerEv = tempv; - } - - // Post events - PostEvent(new EventParams("state_exit", new Object[0], - new DetectParams[0])); - PostEvent(new EventParams("state", new Object[] { state }, - new DetectParams[0])); - PostEvent(EventParams.StateEntryParams); - - // Requeue the timer event after the state changing events - if (lastTimerEv != null) EventQueue.Enqueue(lastTimerEv); - - // This will stop events from being queued and processed - // until the new state is started - m_StateChangeInProgress = true; - } - - throw new EventAbortException(); - } - - public void QueueEvent(EventParams data) - { - lock (EventQueue) - { - // The only events that persist across state changes are timers - if (m_StateChangeInProgress && data.EventName != "timer") - return; - if (EventQueue.Count >= m_MaxScriptQueue) - return; - if (data.EventName == "timer") - { - if (m_TimerQueued) - return; - m_TimerQueued = true; - } - if (data.EventName == "control") - { - int held = ((LSL_Types.LSLInteger)data.Params[1]).value; - // int changed = ((LSL_Types.LSLInteger)data.Params[2]).value; - - // If the last message was a 0 (nothing held) - // and this one is also nothing held, drop it - // - if (m_LastControlLevel == held && held == 0) - return; - - // If there is one or more queued, then queue - // only changed ones, else queue unconditionally - // - if (m_ControlEventsInQueue > 0) - { - if (m_LastControlLevel == held) - return; - } - - m_LastControlLevel = held; - m_ControlEventsInQueue++; - } - - if (data.EventName == "collision") - { - if (m_CollisionInQueue) - return; - if (data.DetectParams == null) - return; - - m_CollisionInQueue = true; - } - EventQueue.Enqueue(data); - } - } - - /// - /// Post an event to this script instance. - /// - /// - /// The request to run the event is sent - /// - /// - public void PostEvent(EventParams data) - { -// m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}", -// PrimName, ScriptName, data.EventName, State); - - if (!Running) - return; - - // If min event delay is set then ignore any events untill the time has expired - // This currently only allows 1 event of any type in the given time period. - // This may need extending to allow for a time for each individual event type. - if (m_eventDelayTicks != 0 && - data.EventName != "state" && data.EventName != "state_entry" && data.EventName != "state_exit" - && data.EventName != "run_time_permissions" && data.EventName != "http_request" && data.EventName != "link_message") - { - if (DateTime.Now.Ticks < m_nextEventTimeTicks) - return; - m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks; - } - - lock (EventQueue) - { - // The only events that persist across state changes are timers - if (m_StateChangeInProgress && data.EventName != "timer") - return; - - if (EventQueue.Count >= m_MaxScriptQueue) - return; - - if (data.EventName == "timer") - { - if (m_TimerQueued) - return; - m_TimerQueued = true; - } - - if (data.EventName == "control") - { - int held = ((LSL_Types.LSLInteger)data.Params[1]).value; - // int changed = ((LSL_Types.LSLInteger)data.Params[2]).value; - - // If the last message was a 0 (nothing held) - // and this one is also nothing held, drop it - // - if (m_LastControlLevel == held && held == 0) - return; - - // If there is one or more queued, then queue - // only changed ones, else queue unconditionally - // - if (m_ControlEventsInQueue > 0) - { - if (m_LastControlLevel == held) - return; - } - - m_LastControlLevel = held; - m_ControlEventsInQueue++; - } - - if (data.EventName == "collision") - { - if (m_CollisionInQueue) - return; - if (data.DetectParams == null) - return; - - m_CollisionInQueue = true; - } - - EventQueue.Enqueue(data); - - if (m_CurrentWorkItem == null) - { - m_CurrentWorkItem = Engine.QueueEventHandler(this); - } - } - } - - /// - /// Process the next event queued for this script - /// - /// - public void EventProcessor() - { - // We check here as the thread stopping this instance from running may itself hold the m_Script lock. - if (!Running) - return; - - lock (m_Script) - { -// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); - - if (Suspended) - return; - - ExecutionTimer.Restart(); - - try - { - EventProcessorInt(); - return; - } - finally - { - ExecutionTimer.Stop(); - ExecutionTime.AddSample(ExecutionTimer); - Part.ParentGroup.Scene.AddScriptExecutionTime(ExecutionTimer.ElapsedTicks); - } - } - } - - private void EventProcessorInt() - { - EventParams data = null; - - lock (EventQueue) - { - data = (EventParams)EventQueue.Dequeue(); - if (data == null) - { - // check if a null event was enqueued or if its really empty - if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) - { - m_CurrentWorkItem = Engine.QueueEventHandler(this); - } - else - { - m_CurrentWorkItem = null; - } - return; - } - - if (data.EventName == "timer") - m_TimerQueued = false; - if (data.EventName == "control") - { - if (m_ControlEventsInQueue > 0) - m_ControlEventsInQueue--; - } - if (data.EventName == "collision") - m_CollisionInQueue = false; - } - - if (DebugLevel >= 2) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", - data.EventName, - ScriptName, - Part.Name, - Part.LocalId, - Part.ParentGroup.Name, - Part.ParentGroup.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name); - - m_DetectParams = data.DetectParams; - - if (data.EventName == "state") // Hardcoded state change - { - State = data.Params[0].ToString(); - - if (DebugLevel >= 1) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", - State, - ScriptName, - Part.Name, - Part.LocalId, - Part.ParentGroup.Name, - Part.ParentGroup.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name); - AsyncCommandManager.StateChange(Engine, - LocalID, ItemID); - // we are effectively in the new state now, so we can resume queueing - // and processing other non-timer events - m_StateChangeInProgress = false; - - Part.RemoveScriptTargets(ItemID); - Part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State)); - } - else - { - Exception e = null; - - if (Engine.World.PipeEventsForScript(LocalID) || - data.EventName == "control") // Don't freeze avies! - { - //m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", - // PrimName, ScriptName, data.EventName, State); - - try - { - m_CurrentEvent = data.EventName; - m_EventStart = DateTime.UtcNow; - m_InEvent = true; - - try - { - m_Script.ExecuteEvent(State, data.EventName, data.Params); - } - finally - { - m_InEvent = false; - m_CurrentEvent = String.Empty; - lock (EventQueue) - m_CurrentWorkItem = null; // no longer in a event that can be canceled - } - - if (m_SaveState) - { - // This will be the very first event we deliver - // (state_entry) in default state - // - SaveState(); - - m_SaveState = false; - } - } - catch (Exception exx) - { - e = exx; - } - - if(e != null) - { - // m_log.DebugFormat( - // "[SCRIPT] Exception in script {0} {1}: {2}{3}", - // ScriptName, ItemID, e.Message, e.StackTrace); - - if ((!(e is TargetInvocationException) - || (!(e.InnerException is SelfDeleteException) - && !(e.InnerException is ScriptDeleteException) - && !(e.InnerException is ScriptCoopStopException))) - && !(e is ThreadAbortException)) - { - try - { - if(e.InnerException != null && e.InnerException is ScriptException) - { - bool toowner = false; - string text = e.InnerException.Message; - if(text.StartsWith("(OWNER)")) - { - text = text.Substring(7); - toowner = true; - } - text += "(script: " + ScriptName + - " event: " + data.EventName + - " primID:" + Part.UUID.ToString() + - " at " + Part.AbsolutePosition + ")"; - if (text.Length > 1000) - text = text.Substring(0, 1000); - if (toowner) - { - ScenePresence sp = Engine.World.GetScenePresence(Part.OwnerID); - if (sp != null && !sp.IsNPC) - Engine.World.SimChatToAgent(Part.OwnerID, Utils.StringToBytes(text), 0x7FFFFFFF, Part.AbsolutePosition, - Part.Name, Part.UUID, false); - } - else - Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - Part.AbsolutePosition, - Part.Name, Part.UUID, false); - m_log.Debug(string.Format( - "[SCRIPT ERROR]: {0} (at event {1}, part {2} {3} at {4} in {5}", - e.InnerException.Message, - data.EventName, - PrimName, - Part.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name)); - - } - else - { - - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - Part.AbsolutePosition, - Part.Name, Part.UUID, false); - - - m_log.Debug(string.Format( - "[SCRIPT ERROR]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", - ScriptName, - data.EventName, - PrimName, - Part.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name), - e); - } - } - catch (Exception) - { - } - } - else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) - { - m_InSelfDelete = true; - Engine.World.DeleteSceneObject(Part.ParentGroup, false); - } - else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) - { - m_InSelfDelete = true; - Part.Inventory.RemoveInventoryItem(ItemID); - } - else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) - { - if (DebugLevel >= 1) - m_log.DebugFormat( - "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", - PrimName, ScriptName, data.EventName, State); - } - } - } - } - - // If there are more events and we are currently running and not shutting down, then ask the - // script engine to run the next event. - lock (EventQueue) - { - // Increase processed events counter and prevent wrap; - if (++EventsProcessed == 1000000) - EventsProcessed = 100000; - - if ((EventsProcessed % 100000) == 0 && DebugLevel > 0) - { - m_log.DebugFormat("[SCRIPT INSTANCE]: Script \"{0}\" (Object \"{1}\" {2} @ {3}.{4}, Item ID {5}, Asset {6}) in event {7}: processed {8:n0} script events", - ScriptTask.Name, - Part.ParentGroup.Name, Part.ParentGroup.UUID, Part.ParentGroup.AbsolutePosition, Part.ParentGroup.Scene.Name, - ScriptTask.ItemID, ScriptTask.AssetID, data.EventName, EventsProcessed); - } - - if (EventQueue.Count > 0 && Running && !ShuttingDown && !m_InSelfDelete) - { - m_CurrentWorkItem = Engine.QueueEventHandler(this); - } - else - { - m_CurrentWorkItem = null; - } - } - - m_DetectParams = null; - } - - public int EventTime() - { - if (!m_InEvent) - return 0; - - return (DateTime.UtcNow - m_EventStart).Seconds; - } - - public void ResetScript(int timeout) - { - if (m_Script == null) - return; - - bool running = Running; - - RemoveState(); - ReleaseControlsorPermissions(true); - - Stop(timeout); - AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); - - m_TimerQueued = false; - m_StateChangeInProgress = false; - EventQueue.Clear(); - - m_Script.ResetVars(); - StartParam = 0; - State = "default"; - - SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); - if (part == null) - return; - - part.CollisionSound = UUID.Zero; - part.RemoveScriptTargets(ItemID); - part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State)); - if (running & ScriptTask.ScriptRunning) - { - Start(); - PostEvent(EventParams.StateEntryParams); - } - else - QueueEvent(EventParams.StateEntryParams); - m_SaveState = StatePersistedHere; - } - - [DebuggerNonUserCode] //Stops the VS debugger from farting in this function - public void ApiResetScript() - { - // bool running = Running; - - RemoveState(); - ReleaseControlsorPermissions(true); - - AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); - - m_TimerQueued = false; - m_StateChangeInProgress = false; - EventQueue.Clear(); - m_Script.ResetVars(); - string oldState = State; - StartParam = 0; - State = "default"; - - SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); - if(part != null) - { - part.CollisionSound = UUID.Zero; - part.RemoveScriptTargets(ItemID); - part.SetScriptEvents(ItemID, m_Script.GetStateEventFlags(State)); - } - if (m_CurrentEvent != "state_entry" || oldState != "default") - { - m_SaveState = StatePersistedHere; - PostEvent(EventParams.StateEntryParams); - throw new EventAbortException(); - } - } - - public Dictionary GetVars() - { - if (m_Script != null) - return m_Script.GetVars(); - else - return new Dictionary(); - } - - public void SetVars(Dictionary vars) - { -// foreach (KeyValuePair kvp in vars) -// m_log.DebugFormat("[SCRIPT INSTANCE]: Setting var {0}={1}", kvp.Key, kvp.Value); - - m_Script.SetVars(vars); - } - - public DetectParams GetDetectParams(int idx) - { - if (m_DetectParams == null) - return null; - if (idx < 0 || idx >= m_DetectParams.Length) - return null; - - return m_DetectParams[idx]; - } - - public UUID GetDetectID(int idx) - { - if (m_DetectParams == null) - return UUID.Zero; - if (idx < 0 || idx >= m_DetectParams.Length) - return UUID.Zero; - - return m_DetectParams[idx].Key; - } - - public void SaveState() - { - if (!Running && !StayStopped) - return; - - // We cannot call this inside the EventQueue lock since it will currently take AsyncCommandManager.staticLock. - // This may already be held by AsyncCommandManager.DoOneCmdHandlerPass() which in turn can take EventQueue - // lock via ScriptInstance.PostEvent(). - PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); - - // We need to lock here to avoid any race with a thread that is removing this script. - lock (EventQueue) - { - // Check again to avoid a race with a thread in Stop() - if (!Running && !StayStopped) - return; - - // If we're currently in an event, just tell it to save upon return - // - if (m_InEvent) - { - m_SaveState = true; - return; - } - - // m_log.DebugFormat( - // "[SCRIPT INSTANCE]: Saving state for script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}", - // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name); - - string xml = ScriptSerializer.Serialize(this); - - // Compare hash of the state we just just created with the state last written to disk - // If the state is different, update the disk file. - UUID hash = UUID.Parse(Utils.MD5String(xml)); - - if (hash != m_CurrentStateHash) - { - try - { - using (FileStream fs = File.Create(Path.Combine(m_dataPath, ItemID.ToString() + ".state"))) - { - Byte[] buf = Util.UTF8NoBomEncoding.GetBytes(xml); - fs.Write(buf, 0, buf.Length); - } - } - catch(Exception) - { - // m_log.Error("Unable to save xml\n"+e.ToString()); - } - //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"))) - //{ - // throw new Exception("Completed persistence save, but no file was created"); - //} - m_CurrentStateHash = hash; - } - - StayStopped = false; - } - } - - public IScriptApi GetApi(string name) - { - if (m_Apis.ContainsKey(name)) - { -// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); - - return m_Apis[name]; - } - -// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); - - return null; - } - - public override string ToString() - { - return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); - } - - string FormatException(Exception e) - { - if (e.InnerException == null) // Not a normal runtime error - return e.ToString(); - - string message = "Runtime error:\n" + e.InnerException.StackTrace; - string[] lines = message.Split(new char[] {'\n'}); - - foreach (string line in lines) - { - if (line.Contains("SecondLife.Script")) - { - int idx = line.IndexOf(':'); - if (idx != -1) - { - string val = line.Substring(idx+1); - int lineNum = 0; - if (int.TryParse(val, out lineNum)) - { - KeyValuePair pos = - Compiler.FindErrorPosition( - lineNum, 0, LineMap); - - int scriptLine = pos.Key; - int col = pos.Value; - if (scriptLine == 0) - scriptLine++; - if (col == 0) - col++; - message = string.Format("Runtime error:\n" + - "({0}): {1}", scriptLine - 1, - e.InnerException.Message); - - return message; - } - } - } - } - - // m_log.ErrorFormat("Scripting exception:"); - // m_log.ErrorFormat(e.ToString()); - - return e.ToString(); - } - - public string GetAssemblyName() - { - return m_assemblyPath; - } - - public string GetXMLState() - { - bool run = Running; - Stop(100); - Running = run; - - // We should not be doing this, but since we are about to - // dispose this, it really doesn't make a difference - // This is meant to work around a Windows only race - // - m_InEvent = false; - - // Force an update of the in-memory plugin data - // - PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); - - return ScriptSerializer.Serialize(this); - } - - public UUID RegionID - { - get { return m_RegionID; } - } - - public void Suspend() - { - Suspended = true; - } - - public void Resume() - { - Suspended = false; - } - } - - /// - /// Xengine event wait handle. - /// - /// - /// This class exists becase XEngineScriptBase gets a reference to this wait handle. We need to make sure that - /// when scripts are running in different AppDomains the lease does not expire. - /// FIXME: Like LSL_Api, etc., this effectively leaks memory since the GC will never collect it. To avoid this, - /// proper remoting sponsorship needs to be implemented across the board. - /// - public class XEngineEventWaitHandle : EventWaitHandle - { - public XEngineEventWaitHandle(bool initialState, EventResetMode mode) : base(initialState, mode) {} - - public override Object InitializeLifetimeService() - { - return null; - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs deleted file mode 100644 index 9c5c0ac7cdf..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using System.Threading; -using System.Collections; -using System.Collections.Generic; -using System.Security.Policy; -using System.Reflection; -using System.Globalization; -using System.Xml; -using OpenMetaverse; -using log4net; -using Nini.Config; -using Amib.Threading; -using OpenSim.Framework; -using OpenSim.Region.CoreModules; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Region.ScriptEngine.Interfaces; - -namespace OpenSim.Region.ScriptEngine.Shared.Instance -{ - public class ScriptSerializer - { - public static string Serialize(ScriptInstance instance) - { - bool running = instance.Running; - - XmlDocument xmldoc = new XmlDocument(); - - XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, - "", ""); - xmldoc.AppendChild(xmlnode); - - XmlElement rootElement = xmldoc.CreateElement("", "ScriptState", - ""); - xmldoc.AppendChild(rootElement); - - XmlElement state = xmldoc.CreateElement("", "State", ""); - state.AppendChild(xmldoc.CreateTextNode(instance.State)); - - rootElement.AppendChild(state); - - XmlElement run = xmldoc.CreateElement("", "Running", ""); - run.AppendChild(xmldoc.CreateTextNode( - running.ToString())); - - rootElement.AppendChild(run); - - Dictionary vars = instance.GetVars(); - - XmlElement variables = xmldoc.CreateElement("", "Variables", ""); - - foreach (KeyValuePair var in vars) - WriteTypedValue(xmldoc, variables, "Variable", var.Key, - var.Value); - - rootElement.AppendChild(variables); - - XmlElement queue = xmldoc.CreateElement("", "Queue", ""); - - int count = instance.EventQueue.Count; - - while (count > 0) - { - EventParams ep = (EventParams)instance.EventQueue.Dequeue(); - instance.EventQueue.Enqueue(ep); - count--; - - XmlElement item = xmldoc.CreateElement("", "Item", ""); - XmlAttribute itemEvent = xmldoc.CreateAttribute("", "event", - ""); - itemEvent.Value = ep.EventName; - item.Attributes.Append(itemEvent); - - XmlElement parms = xmldoc.CreateElement("", "Params", ""); - - foreach (Object o in ep.Params) - WriteTypedValue(xmldoc, parms, "Param", String.Empty, o); - - item.AppendChild(parms); - - XmlElement detect = xmldoc.CreateElement("", "Detected", ""); - - foreach (DetectParams det in ep.DetectParams) - { - XmlElement objectElem = xmldoc.CreateElement("", "Object", ""); - XmlAttribute pos = xmldoc.CreateAttribute("", "pos", ""); - pos.Value = det.OffsetPos.ToString(); - objectElem.Attributes.Append(pos); - - XmlAttribute d_linkNum = xmldoc.CreateAttribute("", "linkNum", ""); - d_linkNum.Value = det.LinkNum.ToString(); - objectElem.Attributes.Append(d_linkNum); - - XmlAttribute d_group = xmldoc.CreateAttribute("", "group", ""); - d_group.Value = det.Group.ToString(); - objectElem.Attributes.Append(d_group); - - XmlAttribute d_name = xmldoc.CreateAttribute("", "name", ""); - d_name.Value = det.Name.ToString(); - objectElem.Attributes.Append(d_name); - - XmlAttribute d_owner = xmldoc.CreateAttribute("", "owner", ""); - d_owner.Value = det.Owner.ToString(); - objectElem.Attributes.Append(d_owner); - - XmlAttribute d_position = xmldoc.CreateAttribute("", "position", ""); - d_position.Value = det.Position.ToString(); - objectElem.Attributes.Append(d_position); - - XmlAttribute d_rotation = xmldoc.CreateAttribute("", "rotation", ""); - d_rotation.Value = det.Rotation.ToString(); - objectElem.Attributes.Append(d_rotation); - - XmlAttribute d_type = xmldoc.CreateAttribute("", "type", ""); - d_type.Value = det.Type.ToString(); - objectElem.Attributes.Append(d_type); - - XmlAttribute d_velocity = xmldoc.CreateAttribute("", "velocity", ""); - d_velocity.Value = det.Velocity.ToString(); - objectElem.Attributes.Append(d_velocity); - - objectElem.AppendChild( - xmldoc.CreateTextNode(det.Key.ToString())); - - detect.AppendChild(objectElem); - } - - item.AppendChild(detect); - - queue.AppendChild(item); - } - - rootElement.AppendChild(queue); - - XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); - DumpList(xmldoc, plugins, - new LSL_Types.list(instance.PluginData)); - - rootElement.AppendChild(plugins); - - if (instance.ScriptTask != null) - { - if (instance.ScriptTask.PermsMask != 0 && !instance.ScriptTask.PermsGranter.IsZero()) - { - XmlNode permissions = xmldoc.CreateElement("", "Permissions", ""); - XmlAttribute granter = xmldoc.CreateAttribute("", "granter", ""); - granter.Value = instance.ScriptTask.PermsGranter.ToString(); - permissions.Attributes.Append(granter); - XmlAttribute mask = xmldoc.CreateAttribute("", "mask", ""); - mask.Value = instance.ScriptTask.PermsMask.ToString(); - permissions.Attributes.Append(mask); - rootElement.AppendChild(permissions); - } - } - - if (instance.MinEventDelay > 0.0) - { - XmlElement eventDelay = xmldoc.CreateElement("", "MinEventDelay", ""); - eventDelay.AppendChild(xmldoc.CreateTextNode(instance.MinEventDelay.ToString())); - rootElement.AppendChild(eventDelay); - } - - return xmldoc.InnerXml; - } - - public static void Deserialize(string xml, ScriptInstance instance) - { - XmlDocument doc = new XmlDocument(); - - Dictionary vars = instance.GetVars(); - - instance.PluginData = new Object[0]; - - doc.LoadXml(xml); - - XmlNodeList rootL = doc.GetElementsByTagName("ScriptState"); - if (rootL.Count != 1) - { - return; - } - XmlNode rootNode = rootL[0]; - - if (rootNode != null) - { - object varValue; - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - switch (part.Name) - { - case "State": - instance.State=part.InnerText; - break; - case "Running": - instance.Running = bool.Parse(part.InnerText); - break; - case "Variables": - XmlNodeList varL = part.ChildNodes; - foreach (XmlNode var in varL) - { - string varName; - varValue=ReadTypedValue(var, out varName); - - if (vars.ContainsKey(varName)) - vars[varName] = varValue; - } - instance.SetVars(vars); - break; - case "Queue": - XmlNodeList itemL = part.ChildNodes; - foreach (XmlNode item in itemL) - { - List parms = new List(); - List detected = - new List(); - - string eventName = - item.Attributes.GetNamedItem("event").Value; - XmlNodeList eventL = item.ChildNodes; - foreach (XmlNode evt in eventL) - { - switch (evt.Name) - { - case "Params": - XmlNodeList prms = evt.ChildNodes; - foreach (XmlNode pm in prms) - parms.Add(ReadTypedValue(pm)); - - break; - case "Detected": - XmlNodeList detL = evt.ChildNodes; - foreach (XmlNode det in detL) - { - string vect = - det.Attributes.GetNamedItem( - "pos").Value; - LSL_Types.Vector3 v = - new LSL_Types.Vector3(vect); - - int d_linkNum=0; - UUID d_group = UUID.Zero; - string d_name = String.Empty; - UUID d_owner = UUID.Zero; - LSL_Types.Vector3 d_position = - new LSL_Types.Vector3(); - LSL_Types.Quaternion d_rotation = - new LSL_Types.Quaternion(); - int d_type = 0; - LSL_Types.Vector3 d_velocity = - new LSL_Types.Vector3(); - - try - { - string tmp; - - tmp = det.Attributes.GetNamedItem( - "linkNum").Value; - int.TryParse(tmp, out d_linkNum); - - tmp = det.Attributes.GetNamedItem( - "group").Value; - UUID.TryParse(tmp, out d_group); - - d_name = det.Attributes.GetNamedItem( - "name").Value; - - tmp = det.Attributes.GetNamedItem( - "owner").Value; - UUID.TryParse(tmp, out d_owner); - - tmp = det.Attributes.GetNamedItem( - "position").Value; - d_position = - new LSL_Types.Vector3(tmp); - - tmp = det.Attributes.GetNamedItem( - "rotation").Value; - d_rotation = - new LSL_Types.Quaternion(tmp); - - tmp = det.Attributes.GetNamedItem( - "type").Value; - int.TryParse(tmp, out d_type); - - tmp = det.Attributes.GetNamedItem( - "velocity").Value; - d_velocity = - new LSL_Types.Vector3(tmp); - - } - catch (Exception) // Old version XML - { - } - - UUID uuid = new UUID(); - UUID.TryParse(det.InnerText, - out uuid); - - DetectParams d = new DetectParams(); - d.Key = uuid; - d.OffsetPos = v; - d.LinkNum = d_linkNum; - d.Group = d_group; - d.Name = d_name; - d.Owner = d_owner; - d.Position = d_position; - d.Rotation = d_rotation; - d.Type = d_type; - d.Velocity = d_velocity; - - detected.Add(d); - } - break; - } - } - EventParams ep = new EventParams( - eventName, parms.ToArray(), - detected.ToArray()); - instance.EventQueue.Enqueue(ep); - } - break; - case "Plugins": - instance.PluginData = ReadList(part).Data; - break; - case "Permissions": - string tmpPerm; - int mask = 0; - tmpPerm = part.Attributes.GetNamedItem("mask").Value; - if (tmpPerm != null) - { - int.TryParse(tmpPerm, out mask); - if (mask != 0) - { - tmpPerm = part.Attributes.GetNamedItem("granter").Value; - if (tmpPerm != null) - { - UUID granter = new UUID(); - UUID.TryParse(tmpPerm, out granter); - if (!granter.IsZero()) - { - instance.ScriptTask.PermsMask = mask; - instance.ScriptTask.PermsGranter = granter; - } - } - } - } - break; - case "MinEventDelay": - double minEventDelay = 0.0; - double.TryParse(part.InnerText, NumberStyles.Float, Culture.NumberFormatInfo, out minEventDelay); - instance.MinEventDelay = minEventDelay; - break; - } - } - } - } - - private static void DumpList(XmlDocument doc, XmlNode parent, - LSL_Types.list l) - { - foreach (Object o in l.Data) - WriteTypedValue(doc, parent, "ListItem", "", o); - } - - private static LSL_Types.list ReadList(XmlNode parent) - { - List olist = new List(); - - XmlNodeList itemL = parent.ChildNodes; - foreach (XmlNode item in itemL) - olist.Add(ReadTypedValue(item)); - - return new LSL_Types.list(olist.ToArray()); - } - - private static void WriteTypedValue(XmlDocument doc, XmlNode parent, - string tag, string name, object value) - { - Type t=value.GetType(); - XmlAttribute typ = doc.CreateAttribute("", "type", ""); - XmlNode n = doc.CreateElement("", tag, ""); - - if (value is LSL_Types.list) - { - typ.Value = "list"; - n.Attributes.Append(typ); - - DumpList(doc, n, (LSL_Types.list) value); - - if (name != String.Empty) - { - XmlAttribute nam = doc.CreateAttribute("", "name", ""); - nam.Value = name; - n.Attributes.Append(nam); - } - - parent.AppendChild(n); - return; - } - - n.AppendChild(doc.CreateTextNode(value.ToString())); - - typ.Value = t.ToString(); - n.Attributes.Append(typ); - if (name != String.Empty) - { - XmlAttribute nam = doc.CreateAttribute("", "name", ""); - nam.Value = name; - n.Attributes.Append(nam); - } - - parent.AppendChild(n); - } - - private static object ReadTypedValue(XmlNode tag, out string name) - { - name = tag.Attributes.GetNamedItem("name").Value; - - return ReadTypedValue(tag); - } - - private static object ReadTypedValue(XmlNode tag) - { - Object varValue; - string assembly; - - string itemType = tag.Attributes.GetNamedItem("type").Value; - - if (itemType == "list") - return ReadList(tag); - - if (itemType == "OpenMetaverse.UUID") - { - UUID val = new UUID(); - UUID.TryParse(tag.InnerText, out val); - - return val; - } - - Type itemT = Type.GetType(itemType); - if (itemT == null) - { - Object[] args = - new Object[] { tag.InnerText }; - - assembly = itemType+", OpenSim.Region.ScriptEngine.Shared"; - itemT = Type.GetType(assembly); - if (itemT == null) - return null; - - varValue = Activator.CreateInstance(itemT, args); - - if (varValue == null) - return null; - } - else - { - varValue = Convert.ChangeType(tag.InnerText, itemT); - } - return varValue; - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs deleted file mode 100644 index 574bc49c8c4..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs +++ /dev/null @@ -1,519 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region; -using OpenSim.Region.CoreModules.Scripting.WorldComm; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.ScriptEngine.XEngine; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests -{ - /// - /// Test that co-operative script thread termination is working correctly. - /// - [TestFixture] - public class CoopTerminationTests : OpenSimTestCase - { - private TestScene m_scene; - private ScriptEngine.XEngine.XEngine m_xEngine; - - private AutoResetEvent m_chatEvent; - private AutoResetEvent m_stoppedEvent; - - private OSChatMessage m_osChatMessageReceived; - - /// - /// Number of chat messages received so far. Reset before each test. - /// - private int m_chatMessagesReceived; - - /// - /// Number of chat messages expected. m_chatEvent is not fired until this number is reached or exceeded. - /// - private int m_chatMessagesThreshold; - - [SetUp] - public void Init() - { - m_osChatMessageReceived = null; - m_chatMessagesReceived = 0; - m_chatMessagesThreshold = 0; - m_chatEvent = new AutoResetEvent(false); - m_stoppedEvent = new AutoResetEvent(false); - - //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); -// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); - m_xEngine = new ScriptEngine.XEngine.XEngine(); - m_xEngine.DebugLevel = 1; - - IniConfigSource configSource = new IniConfigSource(); - - IConfig startupConfig = configSource.AddConfig("Startup"); - startupConfig.Set("DefaultScriptEngine", "XEngine"); - - IConfig xEngineConfig = configSource.AddConfig("XEngine"); - xEngineConfig.Set("Enabled", "true"); - xEngineConfig.Set("StartDelay", "0"); - - // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call - // to AssemblyResolver.OnAssemblyResolve fails. - xEngineConfig.Set("AppDomainLoading", "false"); - - xEngineConfig.Set("ScriptStopStrategy", "co-op"); - - // Make sure loops aren't actually being terminated by a script delay wait. - xEngineConfig.Set("ScriptDelayFactor", 0); - - // This is really just set for debugging the test. - xEngineConfig.Set("WriteScriptSourceToDebugFile", true); - - // Set to false if we need to debug test so the old scripts don't get wiped before each separate test -// xEngineConfig.Set("DeleteScriptsOnStartup", false); - - // This is not currently used at all for co-op termination. Bumping up to demonstrate that co-op termination - // has an effect - without it tests will fail due to a 120 second wait for the event to finish. - xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000); - - IConfig config = configSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - m_scene = new SceneHelpers().SetupScene("My Test", TestHelpers.ParseTail(0x9999), 1000, 1000, configSource); - SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine); - m_scene.StartScripts(); - } - - /// - /// Test co-operative termination on derez of an object containing a script with a long-running event. - /// - /// - /// TODO: Actually compiling the script is incidental to this test. Really want a way to compile test scripts - /// within the build itself. - /// - [Test] - public void TestStopOnLongSleep() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - llSay(0, ""Thin Lizzy""); - llSleep(60); - } -}"; - - TestStop(script); - } - - [Test] - public void TestNoStopOnSingleStatementForLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - for (i = 0; i <= 1; i++) llSay(0, ""Iter "" + (string)i); - } -}"; - - TestSingleStatementNoStop(script); - } - - [Test] - public void TestStopOnLongSingleStatementForLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - for (i = 0; i < 2147483647; i++) llSay(0, ""Iter "" + (string)i); - } -}"; - - TestStop(script); - } - - [Test] - public void TestStopOnLongCompoundStatementForLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - for (i = 0; i < 2147483647; i++) - { - llSay(0, ""Iter "" + (string)i); - } - } -}"; - - TestStop(script); - } - - [Test] - public void TestNoStopOnSingleStatementWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - while (i < 2) llSay(0, ""Iter "" + (string)i++); - } -}"; - - TestSingleStatementNoStop(script); - } - - [Test] - public void TestStopOnLongSingleStatementWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - while (1 == 1) - llSay(0, ""Iter "" + (string)i++); - } -}"; - - TestStop(script); - } - - [Test] - public void TestStopOnLongCompoundStatementWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - while (1 == 1) - { - llSay(0, ""Iter "" + (string)i++); - } - } -}"; - - TestStop(script); - } - - [Test] - public void TestNoStopOnSingleStatementDoWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - - do llSay(0, ""Iter "" + (string)i++); - while (i < 2); - } -}"; - - TestSingleStatementNoStop(script); - } - - [Test] - public void TestStopOnLongSingleStatementDoWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - do llSay(0, ""Iter "" + (string)i++); - while (1 == 1); - } -}"; - - TestStop(script); - } - - [Test] - public void TestStopOnLongCompoundStatementDoWhileLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - do - { - llSay(0, ""Iter "" + (string)i++); - } while (1 == 1); - } -}"; - - TestStop(script); - } - - [Test] - public void TestStopOnInfiniteJumpLoop() - { - TestHelpers.InMethod(); - TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - @p1; - llSay(0, ""Iter "" + (string)i++); - jump p1; - } -}"; - - TestStop(script); - } - - // Disabling for now as these are not particularly useful tests (since they fail due to stack overflow before - // termination can even be tried. -// [Test] - public void TestStopOnInfiniteUserFunctionCallLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@" -integer i = 0; - -ufn1() -{ - llSay(0, ""Iter ufn1() "" + (string)i++); - ufn1(); -} - -default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - ufn1(); - } -}"; - - TestStop(script); - } - - // Disabling for now as these are not particularly useful tests (since they fail due to stack overflow before - // termination can even be tried. -// [Test] - public void TestStopOnInfiniteManualEventCallLoop() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string script = -@"default -{ - state_entry() - { - integer i = 0; - llSay(0, ""Thin Lizzy""); - - llSay(0, ""Iter"" + (string)i++); - default_event_state_entry(); - } -}"; - - TestStop(script); - } - - private SceneObjectPart CreateScript(string script, string itemName, UUID userId) - { -// UUID objectId = TestHelpers.ParseTail(0x100); -// UUID itemId = TestHelpers.ParseTail(0x3); - - SceneObjectGroup so - = SceneHelpers.CreateSceneObject(1, userId, string.Format("Object for {0}", itemName), 0x100); - m_scene.AddNewSceneObject(so, true); - - InventoryItemBase itemTemplate = new InventoryItemBase(); -// itemTemplate.ID = itemId; - itemTemplate.Name = itemName; - itemTemplate.Folder = so.UUID; - itemTemplate.InvType = (int)InventoryType.LSL; - - m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; - - return m_scene.RezNewScript(userId, itemTemplate, script); - } - - private void TestSingleStatementNoStop(string script) - { - // In these tests we expect to see at least 2 chat messages to confirm that the loop is working properly. - m_chatMessagesThreshold = 2; - - UUID userId = TestHelpers.ParseTail(0x1); -// UUID objectId = TestHelpers.ParseTail(0x100); -// UUID itemId = TestHelpers.ParseTail(0x3); - string itemName = "TestNoStop"; - - SceneObjectPart partWhereRezzed = CreateScript(script, itemName, userId); - - // Wait for the script to start the event before we try stopping it. - m_chatEvent.WaitOne(60000); - - if (m_osChatMessageReceived == null) - Assert.Fail("Script did not start"); - else - Assert.That(m_chatMessagesReceived, Is.EqualTo(2)); - - bool running; - TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); - Assert.That( - SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True); - Assert.That(running, Is.True); - } - - private void TestStop(string script) - { - // In these tests we're only interested in the first message to confirm that the script has started. - m_chatMessagesThreshold = 1; - - UUID userId = TestHelpers.ParseTail(0x1); -// UUID objectId = TestHelpers.ParseTail(0x100); -// UUID itemId = TestHelpers.ParseTail(0x3); - string itemName = "TestStop"; - - SceneObjectPart partWhereRezzed = CreateScript(script, itemName, userId); - TaskInventoryItem rezzedItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); - - // Wait for the script to start the event before we try stopping it. - m_chatEvent.WaitOne(60000); - - if (m_osChatMessageReceived != null) - Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message); - else - Assert.Fail("Script did not start"); - - // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script - // executes llSay() but has not started the next statement before we try to stop it. - Thread.Sleep(1000); - - // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually - // stopped. This kind of multi-threading is far from ideal in a regression test. - new Thread(() => { m_xEngine.StopScript(rezzedItem.ItemID); m_stoppedEvent.Set(); }).Start(); - - if (!m_stoppedEvent.WaitOne(30000)) - Assert.Fail("Script did not co-operatively stop."); - - bool running; - TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); - Assert.That( - SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True); - Assert.That(running, Is.False); - } - - private void OnChatFromWorld(object sender, OSChatMessage oscm) - { - Console.WriteLine("Got chat [{0}]", oscm.Message); - m_osChatMessageReceived = oscm; - - if (++m_chatMessagesReceived >= m_chatMessagesThreshold) - { - m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; - m_chatEvent.Set(); - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index e5215f2d7f3..4284c5304a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using OpenSim.Framework; @@ -36,13 +37,14 @@ using OMV_Vector3 = OpenMetaverse.Vector3; using OMV_Vector3d = OpenMetaverse.Vector3d; using OMV_Quaternion = OpenMetaverse.Quaternion; +using System.Runtime.InteropServices; namespace OpenSim.Region.ScriptEngine.Shared { public partial class LSL_Types { // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static bool IsBadNumber(double d) { return (*(long*)(&d) & 0x7FFFFFFFFFFFFFFF) >= 0x7FF0000000000000; @@ -85,29 +87,81 @@ public Vector3(double X, double Y, double Z) z = Z; } - public Vector3(string str) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector3(string str) : this(MemoryExtensions.AsSpan(str)) { } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector3(LSLString str) : this(MemoryExtensions.AsSpan(str.m_string)) { } + + public Vector3(ReadOnlySpan str) { - str = str.Replace('<', ' '); - str = str.Replace('>', ' '); - string[] tmps = str.Split(new Char[] {','}); - if (tmps.Length < 3) + if (str.Length < 5) + { + z = y = x = 0; + return; + } + + int start = 0; + int comma = 0; + char c; + do + { + c = Unsafe.Add(ref MemoryMarshal.GetReference(str), comma); + if (c == ',' || c == '<') + break; + } + while (++comma < str.Length); + + if (c == '<') + { + start = ++comma; + while (++comma < str.Length) + { + if (Unsafe.Add(ref MemoryMarshal.GetReference(str), comma) == ',') + break; + } + } + if (comma > str.Length - 3) { z = y = x = 0; return; } - if (!Double.TryParse(tmps[0], NumberStyles.Float, Culture.NumberFormatInfo, out x)) + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out x)) { z = y = 0; return; } - if (!Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y)) + + start = ++comma; + while (++comma < str.Length) + { + if (Unsafe.Add(ref MemoryMarshal.GetReference(str), comma) == ',') + break; + } + if (comma > str.Length - 1) + { + z = y = x = 0; + return; + } + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out y)) { z = x = 0; return; } - if (!Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z)) + + start = ++comma; + while (++comma < str.Length) + { + c = Unsafe.Add(ref MemoryMarshal.GetReference(str), comma); + if (c == ' ' || c == '>') + break; + } + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out z)) { y = x = 0; + return; } } @@ -115,23 +169,20 @@ public Vector3(string str) #region Overriders + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Boolean(Vector3 vec) { - if (vec.x != 0) - return true; - if (vec.y != 0) - return true; - if (vec.z != 0) - return true; - return false; + return vec.x != 0 || vec.y != 0 || vec.z != 0; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string ToString() { string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z); return s; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator LSLString(Vector3 vec) { string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z); @@ -186,16 +237,14 @@ public static implicit operator Vector3(OMV_Vector3d vec) public override int GetHashCode() { - return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode()); + return x.GetHashCode() + y.GetHashCode() + z.GetHashCode(); } public override bool Equals(object o) { - if (!(o is Vector3)) return false; - - Vector3 vector = (Vector3)o; - - return (x == vector.x && y == vector.y && z == vector.z); + if (o is Vector3 vector) + return (x == vector.x && y == vector.y && z == vector.z); + return false; } public static Vector3 operator -(Vector3 vector) @@ -357,13 +406,13 @@ public static double Mag(Vector3 v) public static Vector3 Norm(Vector3 vector) { - double mag = Mag(vector); - if (mag > 0.0) + double mag = MagSquare(vector); + if (mag > float.Epsilon) { - double invMag = 1.0 / mag; + double invMag = 1.0 / Math.Sqrt(mag); return vector * invMag; } - return new Vector3(0, 0, 0); + return Vector3.Zero; } public static Vector3 Slerp(Vector3 v1, Vector3 v2, double amount) @@ -390,6 +439,8 @@ public static Vector3 Slerp(Vector3 v1, Vector3 v2, double amount) v1.z * scale + v2.z * invscale ); } + + public static readonly Vector3 Zero = new(0, 0, 0); #endregion } @@ -405,10 +456,10 @@ public struct Quaternion public Quaternion(Quaternion Quat) { - x = (float)Quat.x; - y = (float)Quat.y; - z = (float)Quat.z; - s = (float)Quat.s; + x = Quat.x; + y = Quat.y; + z = Quat.z; + s = Quat.s; if (s == 0 && x == 0 && y == 0 && z == 0) s = 1; } @@ -423,43 +474,117 @@ public Quaternion(double X, double Y, double Z, double S) s = 1; } - public Quaternion(string str) + public Quaternion(OMV_Quaternion rot) { - str = str.Replace('<', ' '); - str = str.Replace('>', ' '); - string[] tmps = str.Split(new Char[] {','}); - if (tmps.Length < 4 || - !Double.TryParse(tmps[3], NumberStyles.Float, Culture.NumberFormatInfo, out s)) + x = rot.X; + y = rot.Y; + z = rot.Z; + s = rot.W; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Quaternion(string str) : this(MemoryExtensions.AsSpan(str)) { } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Quaternion(LSLString str) : this(MemoryExtensions.AsSpan(str.m_string)) { } + + public Quaternion(ReadOnlySpan str) + { + if (str.Length < 7) + { + z = y = x = 0; + s = 1; + return; + } + + int start = 0; + int comma = 0; + char c; + + do + { + c = Unsafe.Add(ref MemoryMarshal.GetReference(str), comma); + if (c == ',' || c == '<') + break; + } + while (++comma < str.Length); + + if (c == '<') + { + start = ++comma; + while (++comma < str.Length) + { + if (Unsafe.Add(ref MemoryMarshal.GetReference(str), comma) == ',') + break; + } + } + if (comma > str.Length - 5) { z = y = x = 0; s = 1; return; } - if (!Double.TryParse(tmps[0], NumberStyles.Float, Culture.NumberFormatInfo, out x)) + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out x)) { z = y = 0; s = 1; return; } - if (!Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y)) + + start = ++comma; + while (++comma < str.Length) + { + if (Unsafe.Add(ref MemoryMarshal.GetReference(str), comma) == ',') + break; + } + if (comma > str.Length - 3) + { + z = y = x = 0; + s = 1; + return; + } + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out y)) { z = x = 0; s = 1; return; } - if (!Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z)) + start = ++comma; + while (++comma < str.Length) + { + if (Unsafe.Add(ref MemoryMarshal.GetReference(str), comma) == ',') + break; + } + if (comma > str.Length - 1) + { + z = y = x = 0; + s = 1; + return; + } + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out z)) { y = x = 0; s = 1; + return; } - } - public Quaternion(OMV_Quaternion rot) - { - x = rot.X; - y = rot.Y; - z = rot.Z; - s = rot.W; + start = ++comma; + while (++comma < str.Length) + { + c = Unsafe.Add(ref MemoryMarshal.GetReference(str), comma); + if (c == ' ' || c == '>') + break; + } + + if (!double.TryParse(str[start..comma], NumberStyles.Float, Utils.EnUsCulture, out s)) + { + z = y = x = 0; + s = 1; + return; + } } #endregion @@ -562,28 +687,27 @@ public override int GetHashCode() public override bool Equals(object o) { - if (!(o is Quaternion)) return false; - - Quaternion quaternion = (Quaternion)o; + if (o is Quaternion qo) + return x == qo.x && y == qo.y && z == qo.z && s == qo.s; - return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; + return false; } public override string ToString() { - string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); + string st = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s); return st; } public static explicit operator string(Quaternion r) { - string st=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); + string st = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); return st; } public static explicit operator LSLString(Quaternion r) { - string st=String.Format(Culture.FormatProvider,"<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); + string st = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s); return new LSLString(st); } @@ -603,7 +727,7 @@ public static implicit operator OMV_Quaternion(Quaternion rot) if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) return OMV_Quaternion.Identity; // ZERO_ROTATION = 0,0,0,1 - OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); + OMV_Quaternion omvrot = new((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); omvrot.Normalize(); return omvrot; } @@ -662,6 +786,8 @@ public static double Mag(Quaternion q) c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z; return c; } + + public static readonly Quaternion Identity = new(0, 0, 0, 1); } [Serializable] @@ -678,9 +804,9 @@ public int Length { get { - if (m_data == null) + if (m_data is null) { - m_data=new object[0]; + m_data = new object[0]; return 0; } return m_data.Length; @@ -691,39 +817,42 @@ public int Size { get { - if (m_data == null) + if (m_data is null) return 0; int size = IntPtr.Size * m_data.Length; foreach (object o in m_data) { - if (o is LSL_Types.LSLInteger) - size += 4; - else if (o is LSL_Types.LSLFloat) - size += 8; - else if (o is LSL_Types.LSLString) - size += ((LSL_Types.LSLString)o).m_string == null ? 0 : ((LSL_Types.LSLString)o).m_string.Length * sizeof(char); - else if (o is LSL_Types.key) - size += ((LSL_Types.key)o).value.Length; - else if (o is LSL_Types.Vector3) - size += 32; - else if (o is LSL_Types.Quaternion) - size += 64; - else if (o is int) - size += 4; - else if (o is uint) - size += 4; - else if (o is string) - size += ((string)o).Length * sizeof(char); - else if (o is float) - size += 8; - else if (o is double) - size += 16; - else if (o is list) - size += ((list)o).Size; - else - throw new Exception("Unknown type in List.Size: " + o.GetType().ToString()); + // here modern sugar alternatives with switch or switch statement generate crap code on dotnet6 + if (o is null) // this explicit test does improve release jit code, otherwise it is present on ALL its + throw new Exception("null entry in List.Size"); + else if (o is LSL_Types.LSLInteger) + size += sizeof(int); + else if (o is LSL_Types.LSLFloat) + size += sizeof(double); + else if (o is LSL_Types.LSLString lso) + size += lso.m_string is null ? 0 : lso.m_string.Length * sizeof(char); + else if (o is LSL_Types.key ko) + size += ko.value.Length; + else if (o is LSL_Types.Vector3) + size += 3 * sizeof(double); + else if (o is LSL_Types.Quaternion) + size += 4 * sizeof(double); + else if (o is int) + size += sizeof(int); + else if (o is uint) + size += sizeof(uint); + else if (o is string so) + size += so.Length * sizeof(char); + else if (o is float) + size += sizeof(float); + else if (o is double) + size += sizeof(double); + else if (o is list lo) + size += lo.Size; + else + throw new Exception("Unknown type in List.Size: " + o.GetType().ToString()); } return size; } @@ -731,13 +860,13 @@ public int Size public object[] Data { - get { - if (m_data == null) - m_data=new object[0]; + get + { + m_data ??= new object[0]; return m_data; } - set {m_data = value; } + set { m_data = value; } } /// @@ -769,118 +898,183 @@ public Type GetLSLListItemType(int itemIndex) public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.LSLInteger) - return (LSL_Types.LSLInteger)o; - if (o is Int32) - return new LSL_Types.LSLFloat((int)o); - if (o is float) - return new LSL_Types.LSLFloat((float)o); - if (o is Double) - return new LSL_Types.LSLFloat((Double)o); - if (o is LSL_Types.LSLString) - return new LSL_Types.LSLFloat(o.ToString()); + if (o is LSL_Types.LSLFloat lfo) + return lfo; + if (o is LSL_Types.LSLInteger lio) + return new LSL_Types.LSLFloat(lio.value); + if (o is int io) + return new LSL_Types.LSLFloat(io); + if (o is float fo) + return new LSL_Types.LSLFloat(fo); + if (o is Double dov) + return new LSL_Types.LSLFloat(dov); + if (o is LSL_Types.LSLString lso) + return new LSL_Types.LSLFloat(lso.m_string); return (LSL_Types.LSLFloat)o; } + public float GetFloatItem(int itemIndex) + { + object o = Data[itemIndex]; + if (o is LSL_Types.LSLFloat lfo) + return (float)lfo.value; + if (o is LSL_Types.LSLInteger lio) + return lio.value; + if (o is int io) + return io; + if (o is float fo) + return fo; + if (o is Double dov) + return (float)dov; + if (o is LSL_Types.LSLString lso) + return Convert.ToSingle(lso.m_string); + return Convert.ToSingle(o.ToString()); + } + + public float GetStrictFloatItem(int itemIndex) + { + object o = Data[itemIndex]; + if (o is LSL_Types.LSLFloat lfo) + return (float)lfo.value; + if (o is LSL_Types.LSLInteger lio) + return lio.value; + if (o is int io) + return io; + if (o is float fo) + return fo; + if (o is double dov) + return (float)dov; + if (o is LSL_Types.LSLString lso) + return Convert.ToSingle(lso.m_string); + throw new InvalidCastException(string.Format($"LSL float expected but {0} given", o is not null ? o.GetType().Name : "null")); + } + public LSL_Types.LSLString GetLSLStringItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.key) - return (LSL_Types.key)o; + if (o is LSL_Types.key ko) + return ko; + if (o is LSL_Types.LSLString lso) + return lso; + if (o is string s) + return new LSL_Types.LSLString(s); return new LSL_Types.LSLString(o.ToString()); } public string GetStringItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.key) - return ((LSL_Types.key)o).value; + if (o is LSL_Types.LSLString lso) + return lso.m_string; + if (o is LSL_Types.key lk) + return (lk.value); + if (o is string s) + return s; return o.ToString(); } public LSL_Types.LSLString GetStrictLSLStringItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.LSLString) - return ((LSL_Types.LSLString)o); - if (o is string) - return new LSL_Types.LSLString((string)o); - if (o is LSL_Types.key) - return ((LSL_Types.key)o).value; + if (o is LSL_Types.LSLString lso) + return lso; + if (o is string so) + return new LSL_Types.LSLString(so); + if (o is LSL_Types.key lko) + return new LSL_Types.LSLString(lko.value); throw new InvalidCastException(string.Format( "{0} expected but {1} given", typeof(LSL_Types.LSLString).Name, - o != null ? - o.GetType().Name : "null")); + o is not null ? o.GetType().Name : "null")); } public string GetStrictStringItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.LSLString) - return ((LSL_Types.LSLString)o).m_string; - if (o is string) - return (string)o; - if (o is LSL_Types.key) - return ((LSL_Types.key)o).value; + if (o is LSL_Types.LSLString lso) + return lso.m_string; + if (o is string s) + return s; + if (o is LSL_Types.key lko) + return lko.value; throw new InvalidCastException(string.Format( "{0} expected but {1} given", typeof(LSL_Types.LSLString).Name, - o != null ? - o.GetType().Name : "null")); + o is not null ? o.GetType().Name : "null")); } public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.LSLInteger) - return (LSL_Types.LSLInteger)o; - if (o is LSL_Types.LSLFloat) - return new LSLInteger((int)o); - if (o is Int32) - return new LSLInteger((int)o); - if (o is LSL_Types.LSLString) - return new LSLInteger(o.ToString()); + if (o is LSL_Types.LSLInteger lio) + return lio; + if (o is int io) + return new LSLInteger(io); + if (o is LSL_Types.LSLFloat lfo) + return new LSLInteger((int)lfo.value); + if (o is float fo) + return new LSLInteger((int)fo); + if (o is double duo) + return new LSLInteger((int)duo); + if (o is LSL_Types.LSLString lso) + return new LSLInteger(lso.m_string); throw new InvalidCastException(string.Format( "{0} expected but {1} given", typeof(LSL_Types.LSLInteger).Name, - o != null ? - o.GetType().Name : "null")); + o is not null ? o.GetType().Name : "null")); + } + + public int GetIntegerItem(int itemIndex) + { + object o = Data[itemIndex]; + if (o is LSL_Types.LSLInteger lio) + return lio.value; + if (o is int io) + return io; + if (o is LSL_Types.LSLFloat lfo) + return (int)lfo.value; + if (o is float fo) + return (int)fo; + if (o is double duo) + return (int)duo; + if (o is LSL_Types.LSLString lso) + return Convert.ToInt32(lso.m_string); + + throw new InvalidCastException(string.Format( + "{0} expected but {1} given", + typeof(LSL_Types.LSLInteger).Name, + o is not null ? o.GetType().Name : "null")); } public LSL_Types.Vector3 GetVector3Item(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.Vector3) - return (LSL_Types.Vector3)o; - if(o is OpenMetaverse.Vector3) - return new LSL_Types.Vector3((OpenMetaverse.Vector3)o); + if (o is LSL_Types.Vector3 vo) + return vo; + if (o is OMV_Vector3 ov) + return new LSL_Types.Vector3(ov); throw new InvalidCastException(string.Format( "{0} expected but {1} given", typeof(LSL_Types.Vector3).Name, - o != null ? - o.GetType().Name : "null")); + o != null ? o.GetType().Name : "null")); } // use LSL_Types.Quaternion to parse and store a vector4 for lightShare public LSL_Types.Quaternion GetVector4Item(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.Quaternion) - { - LSL_Types.Quaternion q = (LSL_Types.Quaternion)o; + if (o is LSL_Types.Quaternion q) return q; - } - if(o is OpenMetaverse.Quaternion) + + if (o is OMV_Quaternion qo) { - LSL_Types.Quaternion q = new LSL_Types.Quaternion((OpenMetaverse.Quaternion)o); - q.Normalize(); - return q; + qo.Normalize(); + return new LSL_Types.Quaternion(qo); ; } throw new InvalidCastException(string.Format( @@ -893,17 +1087,15 @@ public LSL_Types.Quaternion GetVector4Item(int itemIndex) public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) { object o = Data[itemIndex]; - if (o is LSL_Types.Quaternion) + if (o is LSL_Types.Quaternion q) { - LSL_Types.Quaternion q = (LSL_Types.Quaternion)o; q.Normalize(); return q; } - if(o is OpenMetaverse.Quaternion) + if (o is OMV_Quaternion oq) { - LSL_Types.Quaternion q = new LSL_Types.Quaternion((OpenMetaverse.Quaternion)o); - q.Normalize(); - return q; + oq.Normalize(); + return new LSL_Types.Quaternion(oq); } throw new InvalidCastException(string.Format( @@ -915,7 +1107,7 @@ public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) public LSL_Types.key GetKeyItem(int itemIndex) { - return (LSL_Types.key)Data[itemIndex]; + return (LSL_Types.key)Data[itemIndex]; } public static list operator +(list a, list b) @@ -930,10 +1122,9 @@ public LSL_Types.key GetKeyItem(int itemIndex) private void ExtendAndAdd(object o) { object[] tmp; - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) { - tmp = new object[1]; - tmp.SetValue(o, 0); + tmp = new object[] {o}; } else { @@ -944,6 +1135,22 @@ private void ExtendAndAdd(object o) m_data = tmp; } + public object this[int i] + { + get + { + if(m_data is null || i >= m_data.Length) + return null; + return m_data[i]; + } + set + { + if (m_data is null || i >= m_data.Length) + return; + m_data[i] = value; + } + } + public static implicit operator Boolean(list l) { return l.Length != 0; @@ -971,23 +1178,22 @@ public static implicit operator Boolean(list l) { if (b is null) return (a is null); - return (a is null) ? false : a.Length == b.Length; + return a is not null && a.Length == b.Length; } public static bool operator !=(list a, list b) { if (b is null) - return !(a is null); - return (a is null) ? true : a.Length != b.Length; + return a is not null; + return (a is null) || a.Length != b.Length; } public void Add(object o) { object[] tmp; - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) { - tmp = new object[1]; - tmp[0] = o; + tmp = new object[] { o }; } else { @@ -1000,7 +1206,7 @@ public void Add(object o) public bool Contains(object o) { - if (m_data == null) + if (m_data is null) return false; foreach (object i in m_data) { @@ -1016,21 +1222,21 @@ public list DeleteSublist(int start, int end) // If start <= end, remove that part // if either is negative, count from the end of the array // if the resulting start > end, keep [end + 1, start - 1] - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) return new list(new object[0]); int len = m_data.Length; object[] ret; if (start < 0) - start= len + start; + start = len + start; if (start < 0) - start=0; + start = 0; if (end < 0) - end= len + end; + end = len + end; if (end < 0) - end=0; + end = 0; if (start > end) { @@ -1043,7 +1249,7 @@ public list DeleteSublist(int start, int end) start = len - 1; int num = start - end + 1; - if(num <= 0) + if (num <= 0) return new list(new object[0]); ret = new object[num]; @@ -1067,7 +1273,7 @@ public list DeleteSublist(int start, int end) // now, this makes the math easier int remove = end - start; - if(remove >= len) + if (remove >= len) return new list(new object[0]); ret = new object[len - remove]; @@ -1075,7 +1281,7 @@ public list DeleteSublist(int start, int end) if (start > 0) Array.Copy(m_data, 0, ret, 0, start); - if(end >= len) + if (end >= len) return new list(ret); Array.Copy(m_data, end, ret, start, len - end); @@ -1096,14 +1302,10 @@ public list GetSublist(int start, int end) // longer relative to the end of the list. if (start < 0) - { - start = Data.Length + start; - } + start += Data.Length; if (end < 0) - { - end = Data.Length + end; - } + end += Data.Length; // The conventional case is start <= end // NOTE that the case of an empty list is @@ -1117,21 +1319,15 @@ public list GetSublist(int start, int end) // Start sublist beyond length // Also deals with start AND end still negative if (start >= Data.Length || end < 0) - { return new list(); - } // Sublist extends beyond the end of the supplied list if (end >= Data.Length) - { end = Data.Length - 1; - } // Sublist still starts before the beginning of the list if (start < 0) - { start = 0; - } ret = new object[end - start + 1]; @@ -1162,7 +1358,7 @@ public list GetSublist(int start, int end) } else { - result = GetSublist(0,end); + result = GetSublist(0, end); } // If start is outside of list, then just return @@ -1179,6 +1375,9 @@ public list GetSublist(int start, int end) private static int compare(object left, object right, bool ascending) { + if(left is null) + return 0; + if (!left.GetType().Equals(right.GetType())) { // unequal types are always "equal" for comparison purposes. @@ -1187,47 +1386,43 @@ private static int compare(object left, object right, bool ascending) return 0; } - int ret = 0; + int ret; - if (left is LSLInteger) + if (left is LSLInteger l) { - LSLInteger l = (LSLInteger)left; LSLInteger r = (LSLInteger)right; ret = Math.Sign(l.value - r.value); } - else if (left is LSLString) + else if (left is LSLString lsl) { - LSLString l = (LSLString)left; LSLString r = (LSLString)right; - ret = string.CompareOrdinal(l.m_string, r.m_string); + ret = string.CompareOrdinal(lsl.m_string, r.m_string); + } + else if (left is string ssl) + { + ret = string.CompareOrdinal(ssl, right as string); } - else if (left is LSLFloat) + else if (left is LSLFloat fl) { - LSLFloat l = (LSLFloat)left; LSLFloat r = (LSLFloat)right; - ret = Math.Sign(l.value - r.value); + ret = Math.Sign(fl.value - r.value); } - else if (left is Vector3) + else if (left is Vector3 vl) { - Vector3 l = (Vector3)left; Vector3 r = (Vector3)right; - ret = Math.Sign(Vector3.Mag(l) - Vector3.Mag(r)); + ret = Math.Sign(Vector3.Mag(vl) - Vector3.Mag(r)); } - else if (left is key) + else if (left is key kl) { - key l = (key)left; key r = (key)right; - ret = string.CompareOrdinal(l.value, r.value); + ret = string.CompareOrdinal(kl.value, r.value); } else //if (left is Quaternion) and unknown types { return 0; } - if (ascending) - return ret; - - return -ret; + return ascending ? ret : -ret; } class HomogeneousComparer : IComparer @@ -1241,36 +1436,38 @@ public HomogeneousComparer(bool ascend) public int Compare(object left, object right) { - int ret = 0; - if (left is LSLInteger) + if (left is null) + return 0; + + int ret; + if (left is LSLInteger il) { - LSLInteger l = (LSLInteger)left; LSLInteger r = (LSLInteger)right; - ret = Math.Sign(l.value - r.value); + ret = Math.Sign(il.value - r.value); } - else if (left is LSLString) + else if (left is LSLString lsl) { - LSLString l = (LSLString)left; LSLString r = (LSLString)right; - ret = string.CompareOrdinal(l.m_string, r.m_string); + ret = string.CompareOrdinal(lsl.m_string, r.m_string); } - else if (left is LSLFloat) + else if (left is string ssl) + { + ret = string.CompareOrdinal(ssl, right as string); + } + else if (left is LSLFloat fl) { - LSLFloat l = (LSLFloat)left; LSLFloat r = (LSLFloat)right; - ret = Math.Sign(l.value - r.value); + ret = Math.Sign(fl.value - r.value); } - else if (left is Vector3) + else if (left is Vector3 vl) { - Vector3 l = (Vector3)left; Vector3 r = (Vector3)right; - ret = Math.Sign(Vector3.MagSquare(l) - Vector3.MagSquare(r)); + ret = Math.Sign(Vector3.MagSquare(vl) - Vector3.MagSquare(r)); } - else if (left is key) + else if (left is key kl) { - key l = (key)left; key r = (key)right; - ret = string.CompareOrdinal(l.value, r.value); + ret = string.CompareOrdinal(kl.value, r.value); } else //if (left is Quaternion) and unknown types { @@ -1286,85 +1483,90 @@ public int Compare(object left, object right) private static bool needSwapAscending(object left, object right) { - if (left is LSLInteger) + if (left is null) + return false; + + if (left is LSLInteger li) { - LSLInteger l = (LSLInteger)left; LSLInteger r = (LSLInteger)right; - return l.value > r.value; + return li.value > r.value; } - else if (left is LSLString) + if (left is LSLString lsl) { - LSLString l = (LSLString)left; LSLString r = (LSLString)right; - return string.CompareOrdinal(l.m_string, r.m_string) > 0; + return string.CompareOrdinal(lsl.m_string, r.m_string) > 0; } - else if (left is LSLFloat) + else if (left is string ssl) + { + return string.CompareOrdinal(ssl, right as string) > 0; + } + if (left is LSLFloat lf) { - LSLFloat l = (LSLFloat)left; LSLFloat r = (LSLFloat)right; - return l.value > r.value; + return lf.value > r.value; } - else if (left is Vector3) + if (left is Vector3 lv) { - Vector3 l = (Vector3)left; Vector3 r = (Vector3)right; - return Vector3.MagSquare(l) > Vector3.Mag(r); + return Vector3.MagSquare(lv) > Vector3.MagSquare(r); } - else if (left is key) + if (left is key lk) { - key l = (key)left; key r = (key)right; - return string.CompareOrdinal(l.value, r.value) > 0; + return string.CompareOrdinal(lk.value, r.value) > 0; } return false; } private static bool needSwapDescending(object left, object right) { - if (left is LSLInteger) + if (left is null) + return false; + + if (left is LSLInteger li) { - LSLInteger l = (LSLInteger)left; LSLInteger r = (LSLInteger)right; - return l.value < r.value; + return li.value < r.value; } - else if (left is LSLString) + if (left is LSLString lsl) { - LSLString l = (LSLString)left; LSLString r = (LSLString)right; - return string.CompareOrdinal(l.m_string, r.m_string) < 0; + return string.CompareOrdinal(lsl.m_string, r.m_string) < 0; + } + else if (left is string ssl) + { + string sr = right as string; + return string.CompareOrdinal(ssl, sr) < 0; } - else if (left is LSLFloat) + if (left is LSLFloat lf) { - LSLFloat l = (LSLFloat)left; LSLFloat r = (LSLFloat)right; - return l.value < r.value; + return lf.value < r.value; } - else if (left is Vector3) + if (left is Vector3 lv) { - Vector3 l = (Vector3)left; Vector3 r = (Vector3)right; - return Vector3.MagSquare(l) < Vector3.MagSquare(r); + return Vector3.MagSquare(lv) < Vector3.MagSquare(r); } - else if (left is key) + if (left is key lk) { - key l = (key)left; key r = (key)right; - return string.CompareOrdinal(l.value, r.value) < 0; + return string.CompareOrdinal(lk.value, r.value) < 0; } return false; } public list Sort(int stride, bool ascending) { - if (m_data == null) + if (m_data is null) return new list(); // Don't even bother int len = m_data.Length; - if(len == 0) + if (len == 0) return new list(); // Don't even bother object[] ret = new object[len]; - Array.Copy(m_data, 0, ret, 0, len); + m_data.CopyTo(ret, 0); if (stride < 1) stride = 1; @@ -1376,9 +1578,52 @@ public list Sort(int stride, bool ascending) return new list(ret); } + public list Sort(int stride, int stride_index, bool ascending) + { + if (m_data is null) + return new list(); // Don't even bother + + int len = m_data.Length; + if (len == 0) + return new list(); // Don't even bother + + if (stride < 1) + stride = 1; + + if (stride_index < 0) + { + stride_index += stride; + if (stride_index < 0) + return new list(); + } + else if (stride_index >= stride) + return new list(); + + object[] ret = new object[len]; + m_data.CopyTo(ret, 0); + + if (len <= stride) + return new list(ret); + + if (stride == 1) + { + Sort(ret, stride, ascending); + return new list(ret); + } + + if (len % stride == 0) + { + if (stride_index == 0) + Sort(ret, stride, ascending); + else + Sort(ret, stride, stride_index, ascending); + } + return new list(ret); + } + public void SortInPlace(int stride, bool ascending) { - if (m_data == null) + if (m_data is null) return; // Don't even bother if (stride < 1) @@ -1391,6 +1636,33 @@ public void SortInPlace(int stride, bool ascending) Sort(m_data, stride, ascending); } + public void SortInPlace(int stride, int stride_index, bool ascending) + { + if (m_data is null) + return; // Don't even bother + + if (stride < 1) + stride = 1; + + if (stride_index < 0) + { + stride_index += stride; + if (stride_index < 0) + return; + } + else if (stride_index >= stride) + return; + + int len = m_data.Length; + if ((len <= stride) || (len % stride) != 0) + return; + + if(stride_index == 0) + Sort(m_data, stride, ascending); + else + Sort(m_data, stride,stride_index, ascending); + } + public void Sort(object[] ret, int stride, bool ascending) { // if list does not consists of homogeneous types @@ -1426,7 +1698,7 @@ public void Sort(object[] ret, int stride, bool ascending) for (int j = i + 1; j < ret.Length; ++j) { object tmp = ret[j]; - if (tmp.GetType() == pivotType && needSwapAscending(pivot, tmp)) + if (pivotType.Equals(tmp.GetType()) && needSwapAscending(pivot, tmp)) { ret[j] = pivot; pivot = tmp; @@ -1444,7 +1716,7 @@ public void Sort(object[] ret, int stride, bool ascending) for (int j = i + 1; j < ret.Length; ++j) { object tmp = ret[j]; - if (tmp.GetType() == pivotType && needSwapDescending(pivot, tmp)) + if (pivotType.Equals(tmp.GetType()) && needSwapDescending(pivot, tmp)) { ret[j] = pivot; pivot = tmp; @@ -1519,6 +1791,64 @@ public void Sort(object[] ret, int stride, bool ascending) } } + public void Sort(object[] ret, int stride, int stride_index, bool ascending) + { + if (ascending) + { + for (int i = stride_index; i < ret.Length - stride; i += stride) + { + object pivot = ret[i]; + Type pivotType = pivot.GetType(); + for (int j = i + stride; j < ret.Length; j += stride) + { + object tmp = ret[j]; + if (pivotType.Equals(tmp.GetType()) && needSwapAscending(pivot, tmp)) + { + pivot = tmp; + int ik = i - stride_index; + int end = ik + stride; + int jk = j - stride_index; + while (ik < end) + { + tmp = ret[ik]; + ret[ik] = ret[jk]; + ret[jk] = tmp; + ++ik; + ++jk; + } + } + } + } + } + else + { + for (int i = stride_index; i < ret.Length - stride; i += stride) + { + object pivot = ret[i]; + Type pivotType = pivot.GetType(); + for (int j = i + stride; j < ret.Length; j += stride) + { + object tmp = ret[j]; + if (pivotType.Equals(tmp.GetType()) && needSwapDescending(pivot, tmp)) + { + pivot = tmp; + int ik = i - stride_index; + int end = ik + stride; + int jk = j - stride_index; + while (ik < end) + { + tmp = ret[ik]; + ret[ik] = ret[jk]; + ret[jk] = tmp; + ++ik; + ++jk; + } + } + } + } + } + } + #region CSV Methods public static list FromCSV(string csv) @@ -1528,35 +1858,35 @@ public static list FromCSV(string csv) public string ToCSV() { - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) return String.Empty; Object o = m_data[0]; int len = m_data.Length; - if(len == 1) + if (len == 1) return o.ToString(); - StringBuilder sb = new StringBuilder(1024); + StringBuilder sb = osStringBuilderCache.Acquire(); sb.Append(o.ToString()); - for(int i = 1 ; i < len; i++) + for (int i = 1; i < len; i++) { - sb.Append(","); + sb.Append(','); sb.Append(o.ToString()); } - return sb.ToString(); + return osStringBuilderCache.GetStringAndRelease(sb); } private string ToSoup() { - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) return String.Empty; - StringBuilder sb = new StringBuilder(1024); + StringBuilder sb = osStringBuilderCache.Acquire(); foreach (object o in m_data) { sb.Append(o.ToString()); } - return sb.ToString(); + return osStringBuilderCache.GetStringAndRelease(sb); } public static explicit operator String(list l) @@ -1581,10 +1911,9 @@ public override string ToString() public double Min() { double minimum = double.PositiveInfinity; - double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double entry)) { if (entry < minimum) minimum = entry; } @@ -1595,10 +1924,9 @@ public double Min() public double Max() { double maximum = double.NegativeInfinity; - double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double entry)) { if (entry > maximum) maximum = entry; } @@ -1614,10 +1942,9 @@ public double Range() public int NumericLength() { int count = 0; - double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out _)) { count++; } @@ -1627,11 +1954,10 @@ public int NumericLength() public static list ToDoubleList(list src) { - list ret = new list(); - double entry; + list ret = new(); for (int i = 0; i < src.Data.Length; i++) { - if (double.TryParse(src.m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(src.m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double entry)) { ret.Add(entry); } @@ -1642,12 +1968,11 @@ public static list ToDoubleList(list src) public double Sum() { double sum = 0; - double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double entry)) { - sum = sum + entry; + sum += entry; } } return sum; @@ -1656,12 +1981,11 @@ public double Sum() public double SumSqrs() { double sum = 0; - double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) + if (double.TryParse(m_data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double entry)) { - sum = sum + Math.Pow(entry, 2); + sum += (entry * entry); } } return sum; @@ -1746,33 +2070,33 @@ public double Qi(double i) public string ToPrettyString() { - if(m_data == null || m_data.Length == 0) + if (m_data is null || m_data.Length == 0) return "[]"; - StringBuilder sb = new StringBuilder(1024); + StringBuilder sb = osStringBuilderCache.Acquire(); int len = m_data.Length; int last = len - 1; object o; - sb.Append("["); - for(int i = 0; i < len; i++ ) + sb.Append('['); + for (int i = 0; i < len; i++) { o = m_data[i]; - if (o is String) + if (o is string so) { - sb.Append("\""); - sb.Append((String)o); - sb.Append("\""); + sb.Append('\"'); + sb.Append(so); + sb.Append('\"'); } else { sb.Append(o.ToString()); } - if(i < last) - sb.Append(","); + if (i < last) + sb.Append(','); } - sb.Append("]"); - return sb.ToString(); + sb.Append(']'); + return osStringBuilderCache.GetStringAndRelease(sb); } public class AlphaCompare : IComparer @@ -1787,13 +2111,11 @@ public class NumericComparer : IComparer { int IComparer.Compare(object x, object y) { - double a; - double b; - if (!double.TryParse(x.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out a)) + if (!double.TryParse(x.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double a)) { a = 0.0; } - if (!double.TryParse(y.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out b)) + if (!double.TryParse(y.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out double b)) { b = 0.0; } @@ -1814,10 +2136,9 @@ int IComparer.Compare(object x, object y) public override bool Equals(object o) { - if (!(o is list)) - return false; - - return Data.Length == ((list)o).Data.Length; + if (o is list lo) + return Data.Length == lo.Data.Length; + return false; } public override int GetHashCode() @@ -1843,7 +2164,7 @@ public key(string s) static public bool Parse2Key(string s) { - Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); + Regex isuuid = new(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); if (isuuid.IsMatch(s)) { return true; @@ -1869,7 +2190,7 @@ static public implicit operator Boolean(key k) { return false; } - Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); + Regex isuuid = new(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled); if (isuuid.IsMatch(k.value)) { return true; @@ -1934,6 +2255,7 @@ public override string ToString() } #endregion + public static readonly key NullKey = new("00000000-0000-0000-0000-000000000000"); } [Serializable] @@ -1948,6 +2270,11 @@ public LSLString(string s) m_string = s; } + public LSLString(ReadOnlySpan s) + { + m_string = s.ToString(); + } + public LSLString(double d) { string s = String.Format(Culture.FormatProvider, "{0:0.000000}", d); @@ -1966,7 +2293,7 @@ public LSLString(int i) m_string = s; } - public LSLString(LSLInteger i) : this(i.value) {} + public LSLString(LSLInteger i) : this(i.value) { } #endregion @@ -1993,6 +2320,11 @@ static public implicit operator LSLString(string s) return new LSLString(s); } + static public implicit operator LSLString(ReadOnlySpan s) + { + return new LSLString(s); + } + public static string ToString(LSLString s) { return s.m_string; @@ -2045,20 +2377,17 @@ public static explicit operator LSLString(LSLFloat f) static public explicit operator LSLString(bool b) { - if (b) - return new LSLString("1"); - else - return new LSLString("0"); + return new LSLString( b ? "1" : "0"); } public static implicit operator Vector3(LSLString s) { - return new Vector3(s.m_string); + return new Vector3(s); } public static implicit operator Quaternion(LSLString s) { - return new Quaternion(s.m_string); + return new Quaternion(s); } public static implicit operator LSLFloat(LSLString s) @@ -2068,7 +2397,12 @@ public static implicit operator LSLFloat(LSLString s) public static implicit operator list(LSLString s) { - return new list(new object[]{s}); + return new list(new object[] { s }); + } + + public static implicit operator ReadOnlySpan(LSLString s) + { + return s.m_string.AsSpan(); } #endregion @@ -2098,13 +2432,15 @@ public override int GetHashCode() #endregion + public static readonly LSLString Empty = new(string.Empty); + public static readonly LSLString NullKey = new("00000000-0000-0000-0000-000000000000"); + } [Serializable] public struct LSLInteger { public int value; - private static readonly Regex castRegex = new Regex(@"(^[ ]*0[xX][0-9A-Fa-f][0-9A-Fa-f]*)|(^[ ]*(-?|\+?)[0-9][0-9]*)"); #region Constructors public LSLInteger(int i) @@ -2122,34 +2458,94 @@ public LSLInteger(double d) value = (int)d; } - public LSLInteger(string s) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSLInteger(string s) : this(MemoryExtensions.AsSpan(s)) { } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSLInteger(LSLString s) : this(MemoryExtensions.AsSpan(s.m_string)) { } + public LSLInteger(ReadOnlySpan s) { - Match m = castRegex.Match(s); - string v = m.Groups[0].Value; - // Leading plus sign is allowed, but ignored - v = v.Replace("+", ""); + value = 0; + if (s.Length == 0) + return; - if (v.Length == 0) - { - value = 0; - } - else + int indx = 0; + char c; + bool neg = false; + int rc; + try { - try + do { - if (v.Contains("x") || v.Contains("X")) - { - value = int.Parse(v.Substring(2), System.Globalization.NumberStyles.HexNumber); - } - else + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); + if (c != ' ') + break; + } + while (++indx < s.Length); + + if (c == '0') + { + if (++indx >= s.Length) + return; + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); + if (c == 'x' || c == 'X') { - value = int.Parse(v, System.Globalization.NumberStyles.Integer); + uint uvalue = 0; + while (++indx < s.Length) + { + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); + rc = Utils.HexNibbleWithChk(c); + if (rc < 0) + break; + checked + { + uvalue *= 16; + uvalue += (uint)rc; + } + } + value = (int)uvalue; + return; } } - catch (OverflowException) + else if (c == '+') + { + if (++indx >= s.Length) + return; + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); + } + else if (c == '-') { - value = -1; + if (++indx >= s.Length) + return; + + neg = true; + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); + } + + while (c >= '0' && c <= '9') + { + rc = c - '0'; + checked + { + value *= 10; + value += rc; + } + if(++indx >= s.Length) + break; + c = Unsafe.Add(ref MemoryMarshal.GetReference(s), indx); } + + if(neg) + value = -value; + return; + } + catch (OverflowException) + { + value = -1; + } + catch + { + value = 0; } } @@ -2328,19 +2724,13 @@ static public implicit operator LSLInteger(bool b) public override bool Equals(Object o) { - if (!(o is LSLInteger)) - { - if (o is int) - { - return value == (int)o; - } - else - { - return false; - } - } + if (o is LSLInteger lio) + return value == lio.value; + + if (o is int io) + return value == io; - return value == ((LSLInteger)o).value; + return false; } public override int GetHashCode() @@ -2410,12 +2800,12 @@ public override int GetHashCode() return i; } - public static LSLInteger operator << (LSLInteger i, int s) + public static LSLInteger operator <<(LSLInteger i, int s) { return i.value << s; } - public static LSLInteger operator >> (LSLInteger i, int s) + public static LSLInteger operator >>(LSLInteger i, int s) { return i.value >> s; } @@ -2444,6 +2834,7 @@ public override string ToString() return this.value.ToString(); } + public static readonly LSLInteger Zero = new(0); #endregion } @@ -2456,31 +2847,21 @@ public struct LSLFloat public LSLFloat(int i) { - this.value = (double)i; + value = i; } public LSLFloat(double d) { - this.value = d; + value = d; } - public LSLFloat(string s) - { - Regex r = new Regex("^ *(\\+|-)?([0-9]+\\.?[0-9]*|\\.[0-9]+)([eE](\\+|-)?[0-9]+)?"); - Match m = r.Match(s); - string v = m.Groups[0].Value; + public LSLFloat(string s) : this(MemoryExtensions.AsSpan(s)) { } + public LSLFloat(LSLString s) : this(MemoryExtensions.AsSpan(s.m_string)) { } - v = v.Trim(); - - if (v.Length == 0 || v == null) - v = "0.0"; - else - if (!v.Contains(".") && !v.ToLower().Contains("e")) - v = v + ".0"; - else - if (v.EndsWith(".")) - v = v + "0"; - this.value = double.Parse(v, System.Globalization.NumberStyles.Float, Culture.NumberFormatInfo); + public LSLFloat(ReadOnlySpan s) + { + if (!double.TryParse(s, NumberStyles.Float, Culture.NumberFormatInfo, out value)) + value = 0; } #endregion @@ -2499,19 +2880,22 @@ static public explicit operator int(LSLFloat f) static public explicit operator uint(LSLFloat f) { - return (uint) Math.Abs(f.value); + return (uint)Math.Abs(f.value); + } + + static public explicit operator string(LSLFloat f) + { + return string.Format(Culture.FormatProvider, "{0:0.000000}", f.value); + } + + static public explicit operator LSLString(LSLFloat f) + { + return new LSLString(string.Format(Culture.FormatProvider, "{0:0.000000}", f.value)); } static public implicit operator Boolean(LSLFloat f) { - if (f.value == 0.0) - { - return false; - } - else - { - return true; - } + return f.value != 0.0; } static public implicit operator LSLFloat(int i) @@ -2541,10 +2925,7 @@ static public implicit operator LSLFloat(double d) static public implicit operator LSLFloat(bool b) { - if (b) - return new LSLFloat(1.0); - else - return new LSLFloat(0.0); + return b ? new LSLFloat(1.0) : new LSLFloat(0.0); } static public bool operator ==(LSLFloat f1, LSLFloat f2) @@ -2636,11 +3017,13 @@ static public implicit operator LSLFloat(bool b) return new LSLFloat(-f.value); } - static public implicit operator System.Double(LSLFloat f) + static public implicit operator double(LSLFloat f) { return f.value; } + public static readonly LSLFloat Zero = new(0); + #endregion #region Overriders @@ -2652,9 +3035,9 @@ public override string ToString() public override bool Equals(Object o) { - if (!(o is LSLFloat)) - return false; - return value == ((LSLFloat)o).value; + if (o is LSLFloat fo) + return value == fo.value; + return false; } public override int GetHashCode() diff --git a/OpenSim/Region/ScriptEngine/Shared/OpenSim.Region.ScriptEngine.Shared.csproj b/OpenSim/Region/ScriptEngine/Shared/OpenSim.Region.ScriptEngine.Shared.csproj index 1dc5dea9feb..1b38087d25e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/OpenSim.Region.ScriptEngine.Shared.csproj +++ b/OpenSim/Region/ScriptEngine/Shared/OpenSim.Region.ScriptEngine.Shared.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.ScriptEngine.Shared http://opensimulator.org OpenSim diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs index f55ba7e6c56..653658ebfeb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs +++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs @@ -39,6 +39,5 @@ public ScriptException(string message) : base(message) {} public ScriptException(string message, Exception innerException) : base(message, innerException) {} - public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {} } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs deleted file mode 100644 index 1e0a0f47abb..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; -using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests relating directly to avatars - /// - [TestFixture] - public class LSL_ApiAvatarTests : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - /// - /// Test llSetLinkPrimtiveParams for agents. - /// - /// - /// Also testing entity updates here as well. Possibly that's putting 2 different concerns into one test and - /// this should be separated. - /// - [Test] - public void TestllSetLinkPrimitiveParamsForAgent() - { -/* siting avatars position changed - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID userId = TestHelpers.ParseTail(0x1); - - SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; - part.RotationOffset = new Quaternion(0.7071068f, 0, 0, 0.7071068f); - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, part, null); - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - - // sp has to be less than 10 meters away from 0, 0, 0 (default part position) - Vector3 startPos = new Vector3(3, 2, 1); - sp.AbsolutePosition = startPos; - - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); - - int entityUpdates = 0; - ((TestClient)sp.ControllingClient).OnReceivedEntityUpdate += (entity, flags) => { if (entity is ScenePresence) { entityUpdates++; }}; - - // Test position - { - Vector3 newPos = new Vector3(1, 2, 3); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); - - Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); - - m_scene.Update(1); - Assert.That(entityUpdates, Is.EqualTo(1)); - } - - // Test small reposition - { - Vector3 newPos = new Vector3(1.001f, 2, 3); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); - - Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); - - m_scene.Update(1); - Assert.That(entityUpdates, Is.EqualTo(2)); - } - - // Test world rotation - { - Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); - - Assert.That( - sp.Rotation, new QuaternionToleranceConstraint(part.GetWorldRotation() * newRot, 0.000001)); - - m_scene.Update(1); - Assert.That(entityUpdates, Is.EqualTo(3)); - } - - // Test local rotation - { - Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROT_LOCAL, newRot)); - - Assert.That( - sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); - - m_scene.Update(1); - Assert.That(entityUpdates, Is.EqualTo(4)); - } -*/ - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs deleted file mode 100644 index 7fa2bea0132..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.CoreModules.Scripting.LSLHttp; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for HTTP related functions in LSL - /// - [TestFixture] - public class LSL_ApiHttpTests : OpenSimTestCase - { - private Scene m_scene; - private MockScriptEngine m_engine; - private UrlModule m_urlModule; - - private TaskInventoryItem m_scriptItem; - private LSL_Api m_lslApi; - - [OneTimeSetUp] - public void TestFixtureSetUp() - { - // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. - Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; - } - - [OneTimeTearDown] - public void TestFixureTearDown() - { - // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple - // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression - // tests really shouldn't). - Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; - } - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - // This is an unfortunate bit of clean up we have to do because MainServer manages things through static - // variables and the VM is not restarted between tests. - uint port = 9999; - MainServer.RemoveHttpServer(port); - - m_engine = new MockScriptEngine(); - m_urlModule = new UrlModule(); - - IConfigSource config = new IniConfigSource(); - config.AddConfig("Network"); - config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1"); - m_scene = new SceneHelpers().SetupScene(); - - BaseHttpServer server = new BaseHttpServer(port); - MainServer.AddHttpServer(server); - MainServer.Instance = server; - - server.Start(); - - SceneHelpers.SetupSceneModules(m_scene, config, m_engine, m_urlModule); - - SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); - m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); - - // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. - // Possibly this could be done and we could obtain it directly from the MockScriptEngine. - m_lslApi = new LSL_Api(); - m_lslApi.Initialize(m_engine, so.RootPart, m_scriptItem); - } - - [TearDown] - public void TearDown() - { - MainServer.Instance.Stop(); - } - - [Test] - public void TestLlReleaseUrl() - { - TestHelpers.InMethod(); - - m_lslApi.llRequestURL(); - string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString(); - - { - // Check that the initial number of URLs is correct - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); - } - - { - // Check releasing a non-url - m_lslApi.llReleaseURL("GARBAGE"); - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); - } - - { - // Check releasing a non-existing url - m_lslApi.llReleaseURL("http://example.com"); - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); - } - - { - // Check URL release - m_lslApi.llReleaseURL(returnedUri); - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); - - HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); - - bool gotExpectedException = false; - - try - { - using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) - {} - } - catch (WebException) - { -// using (HttpWebResponse response = (HttpWebResponse)e.Response) -// gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; - gotExpectedException = true; - } - - Assert.That(gotExpectedException, Is.True); - } - - { - // Check releasing the same URL again - m_lslApi.llReleaseURL(returnedUri); - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); - } - } - - [Test] - public void TestLlRequestUrl() - { - TestHelpers.InMethod(); - - string requestId = m_lslApi.llRequestURL(); - Assert.That(requestId, Is.Not.EqualTo(UUID.Zero.ToString())); - string returnedUri; - - { - // Check that URL is correctly set up - Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); - - Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); - - List events = m_engine.PostedEvents[m_scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("http_request")); - - UUID returnKey; - string rawReturnKey = eventParams.Params[0].ToString(); - string method = eventParams.Params[1].ToString(); - returnedUri = eventParams.Params[2].ToString(); - - Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); - Assert.That(method, Is.EqualTo(ScriptBaseClass.URL_REQUEST_GRANTED)); - Assert.That(Uri.IsWellFormedUriString(returnedUri, UriKind.Absolute), Is.True); - } - - { - // Check that request to URL works. - string testResponse = "Hello World"; - - m_engine.ClearPostedEvents(); - m_engine.PostEventHook - += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse); - -// Console.WriteLine("Trying {0}", returnedUri); - - AssertHttpResponse(returnedUri, testResponse); - - Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); - - List events = m_engine.PostedEvents[m_scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("http_request")); - - UUID returnKey; - string rawReturnKey = eventParams.Params[0].ToString(); - string method = eventParams.Params[1].ToString(); - string body = eventParams.Params[2].ToString(); - - Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); - Assert.That(method, Is.EqualTo("GET")); - Assert.That(body, Is.EqualTo("")); - } - } - - private void AssertHttpResponse(string uri, string expectedResponse) - { - HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); - - using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) - { - using (Stream stream = webResponse.GetResponseStream()) - { - using (StreamReader reader = new StreamReader(stream)) - { - Assert.That(reader.ReadToEnd(), Is.EqualTo(expectedResponse)); - } - } - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs deleted file mode 100644 index 5edd3db8c1e..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.World.Permissions; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; -using PermissionMask = OpenSim.Framework.PermissionMask; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for inventory functions in LSL - /// - [TestFixture] - public class LSL_ApiInventoryTests : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("Startup"); - config.Set("serverside_object_permissions", true); - config =initConfigSource.AddConfig("Permissions"); - config.Set("permissionmodules", "DefaultPermissionsModule"); - config.Set("serverside_object_permissions", true); - config.Set("propagate_permissions", true); - - config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new object[] { new DefaultPermissionsModule() }); - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - /// - /// Test giving inventory from an object to an object where both are owned by the same user. - /// - [Test] - public void TestLlGiveInventoryO2OSameOwner() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - UUID userId = TestHelpers.ParseTail(0x1); - string inventoryItemName = "item1"; - - SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId, "so1", 0x10); - m_scene.AddSceneObject(so1); - - // Create an object embedded inside the first - UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, userId); - - LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, null); - - // Create a second object - SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); - m_scene.AddSceneObject(so2); - - api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); - - // Item has copy permissions so original should stay intact. - List originalItems = so1.RootPart.Inventory.GetInventoryItems(); - Assert.That(originalItems.Count, Is.EqualTo(1)); - - List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); - Assert.That(copiedItems.Count, Is.EqualTo(1)); - Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); - } - - /// - /// Test giving inventory from an object to an object where they have different owners - /// - [Test] - public void TestLlGiveInventoryO2ODifferentOwners() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - UUID user1Id = TestHelpers.ParseTail(0x1); - UUID user2Id = TestHelpers.ParseTail(0x2); - string inventoryItemName = "item1"; - - SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); - m_scene.AddSceneObject(so1); - LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, null); - - // Create an object embedded inside the first - UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); - - // Create a second object - SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); - m_scene.AddSceneObject(so2); - LSL_Api api2 = new LSL_Api(); - api2.Initialize(m_engine, so2.RootPart, null); - - // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** - api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); - - { - // Item has copy permissions so original should stay intact. - List originalItems = so1.RootPart.Inventory.GetInventoryItems(); - Assert.That(originalItems.Count, Is.EqualTo(1)); - - // Should have not copied - List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); - Assert.That(copiedItems.Count, Is.EqualTo(0)); - } - - // *** Secondly, we turn on allow inventory drop in the target and retest. *** - api2.llAllowInventoryDrop(1); - api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); - - { - // Item has copy permissions so original should stay intact. - List originalItems = so1.RootPart.Inventory.GetInventoryItems(); - Assert.That(originalItems.Count, Is.EqualTo(1)); - - // Should now have copied. - List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); - Assert.That(copiedItems.Count, Is.EqualTo(1)); - Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); - } - } - - /// - /// Test giving inventory from an object to an avatar that is not the object's owner. - /// - [Test] - public void TestLlGiveInventoryO2DifferentAvatar() - { - TestHelpers.InMethod(); - // TestHelpers.EnableLogging(); - - UUID user1Id = TestHelpers.ParseTail(0x1); - UUID user2Id = TestHelpers.ParseTail(0x2); - string inventoryItemName = "item1"; - - SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); - m_scene.AddSceneObject(so1); - LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, null); - - // Create an object embedded inside the first - UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); - - UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); - - api.llGiveInventory(user2Id.ToString(), inventoryItemName); - - InventoryItemBase receivedItem - = UserInventoryHelpers.GetInventoryItem( - m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); - - Assert.IsNotNull(receivedItem); - } - - /// - /// Test giving inventory from an object to an avatar that is not the object's owner and where the next - /// permissions do not include mod. - /// - [Test] - public void TestLlGiveInventoryO2DifferentAvatarNoMod() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID user1Id = TestHelpers.ParseTail(0x1); - UUID user2Id = TestHelpers.ParseTail(0x2); - string inventoryItemName = "item1"; - - SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); - m_scene.AddSceneObject(so1); - LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, so1.RootPart, null); - - // Create an object embedded inside the first - UUID itemId = TestHelpers.ParseTail(0x20); - TaskInventoryItem tii - = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); - tii.NextPermissions &= ~((uint)PermissionMask.Modify); - - UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); - - api.llGiveInventory(user2Id.ToString(), inventoryItemName); - - InventoryItemBase receivedItem - = UserInventoryHelpers.GetInventoryItem( - m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); - - Assert.IsNotNull(receivedItem); - Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify); - } - - [Test] - public void TestLlRemoteLoadScriptPin() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID user1Id = TestHelpers.ParseTail(0x1); - UUID user2Id = TestHelpers.ParseTail(0x2); - - SceneObjectGroup sourceSo = SceneHelpers.AddSceneObject(m_scene, "sourceSo", user1Id); - m_scene.AddSceneObject(sourceSo); - LSL_Api api = new LSL_Api(); - api.Initialize(m_engine, sourceSo.RootPart, null); - TaskInventoryHelpers.AddScript(m_scene.AssetService, sourceSo.RootPart, "script", "Hello World"); - - SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene, "targetSo", user1Id); - SceneObjectGroup otherOwnedTargetSo = SceneHelpers.AddSceneObject(m_scene, "otherOwnedTargetSo", user2Id); - - // Test that we cannot load a script when the target pin has never been set (i.e. it is zero) - api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 0, 0, 0); - Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); - - // Test that we cannot load a script when the given pin does not match the target - targetSo.RootPart.ScriptAccessPin = 5; - api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); - Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); - - // Test that we cannot load into a prim with a different owner - otherOwnedTargetSo.RootPart.ScriptAccessPin = 3; - api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); - Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); - - // Test that we can load a script when given pin and dest pin match. - targetSo.RootPart.ScriptAccessPin = 3; - api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); - TaskInventoryItem insertedItem = targetSo.RootPart.Inventory.GetInventoryItem("script"); - Assert.IsNotNull(insertedItem); - - // Test that we can no longer load if access pin is unset - targetSo.RootPart.Inventory.RemoveInventoryItem(insertedItem.ItemID); - Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); - - targetSo.RootPart.ScriptAccessPin = 0; - api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); - Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs deleted file mode 100644 index d9ceb830cb1..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for linking functions in LSL - /// - /// - /// This relates to LSL. Actual linking functionality should be tested in the main - /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. - /// - [TestFixture] - public class LSL_ApiLinkingTests : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - [Test] - public void TestllCreateLink() - { - TestHelpers.InMethod(); - - UUID ownerId = TestHelpers.ParseTail(0x1); - - SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); - grp1.AbsolutePosition = new Vector3(10, 10, 10); - m_scene.AddSceneObject(grp1); - - // FIXME: This should really be a script item (with accompanying script) - TaskInventoryItem grp1Item - = TaskInventoryHelpers.AddNotecard( - m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); - grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - grp1Item.PermsGranter = ownerId; - - SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); - grp2.AbsolutePosition = new Vector3(20, 20, 20); - - // <180,0,0> - grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); - - m_scene.AddSceneObject(grp2); - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); - - apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); - - Assert.That(grp1.Parts.Length, Is.EqualTo(4)); - Assert.That(grp2.IsDeleted, Is.True); - } - - [Test] - public void TestllBreakLink() - { - TestHelpers.InMethod(); - - UUID ownerId = TestHelpers.ParseTail(0x1); - - SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); - grp1.AbsolutePosition = new Vector3(10, 10, 10); - m_scene.AddSceneObject(grp1); - - // FIXME: This should really be a script item (with accompanying script) - TaskInventoryItem grp1Item - = TaskInventoryHelpers.AddNotecard( - m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); - - grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); - - apiGrp1.llBreakLink(2); - - Assert.That(grp1.Parts.Length, Is.EqualTo(1)); - - SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); - Assert.That(grp2, Is.Not.Null); - } - - [Test] - public void TestllBreakAllLinks() - { - TestHelpers.InMethod(); - - UUID ownerId = TestHelpers.ParseTail(0x1); - - SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(3, ownerId, "grp1-", 0x10); - grp1.AbsolutePosition = new Vector3(10, 10, 10); - m_scene.AddSceneObject(grp1); - - // FIXME: This should really be a script item (with accompanying script) - TaskInventoryItem grp1Item - = TaskInventoryHelpers.AddNotecard( - m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); - - grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item); - - apiGrp1.llBreakAllLinks(); - - { - SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part1"); - Assert.That(nowGrp, Is.Not.Null); - Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); - } - - { - SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part2"); - Assert.That(nowGrp, Is.Not.Null); - Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); - } - - { - SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part3"); - Assert.That(nowGrp, Is.Not.Null); - Assert.That(nowGrp.Parts.Length, Is.EqualTo(1)); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs deleted file mode 100644 index 90bbecaebc3..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.Framework.Scenes; -using Nini.Config; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenMetaverse; - -using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; -using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; -using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_ApiListTests : OpenSimTestCase - { - private LSL_Api m_lslApi; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - Scene scene = new SceneHelpers().SetupScene(); - SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; - - XEngine.XEngine engine = new XEngine.XEngine(); - engine.Initialise(initConfigSource); - engine.AddRegion(scene); - - m_lslApi = new LSL_Api(); - m_lslApi.Initialize(engine, part, null); - } - - [Test] - public void TestllListFindList() - { - TestHelpers.InMethod(); - - LSL_List src = new LSL_List(new LSL_Integer(1), new LSL_Integer(2), new LSL_Integer(3)); - - { - // Test for a single item that should be found - int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); - Assert.That(result, Is.EqualTo(-1)); - } - - { - // Test for a single item that should be found - int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2))); - Assert.That(result, Is.EqualTo(1)); - } - - { - // Test for a constant that should be found - int result = m_lslApi.llListFindList(src, new LSL_List(ScriptBaseClass.AGENT)); - Assert.That(result, Is.EqualTo(0)); - } - - { - // Test for a list that should be found - int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3))); - Assert.That(result, Is.EqualTo(1)); - } - - { - // Test for a single item not in the list - int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); - Assert.That(result, Is.EqualTo(-1)); - } - - { - // Test for something that should not be cast - int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_String("4"))); - Assert.That(result, Is.EqualTo(-1)); - } - - { - // Test for a list not in the list - int result - = m_lslApi.llListFindList( - src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3), new LSL_Integer(4))); - Assert.That(result, Is.EqualTo(-1)); - } - - { - LSL_List srcWithConstants - = new LSL_List(new LSL_Integer(3), ScriptBaseClass.AGENT, ScriptBaseClass.OS_NPC_LAND_AT_TARGET); - - // Test for constants that appears in the source list that should be found - int result - = m_lslApi.llListFindList(srcWithConstants, new LSL_List(new LSL_Integer(1), new LSL_Integer(2))); - - Assert.That(result, Is.EqualTo(1)); - } - } - } - } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs deleted file mode 100644 index dd60a87c786..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.CoreModules.Scripting.LSLHttp; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for notecard related functions in LSL - /// - [TestFixture] - public class LSL_ApiNotecardTests : OpenSimTestCase - { - private Scene m_scene; - private MockScriptEngine m_engine; - - private SceneObjectGroup m_so; - private TaskInventoryItem m_scriptItem; - private LSL_Api m_lslApi; - - [OneTimeSetUp] - public void TestFixtureSetUp() - { - // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. - Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; - } - - [OneTimeTearDown] - public void TestFixureTearDown() - { - // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple - // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression - // tests really shouldn't). - Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; - } - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - m_engine = new MockScriptEngine(); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine); - - m_so = SceneHelpers.AddSceneObject(m_scene); - m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart); - - // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. - // Possibly this could be done and we could obtain it directly from the MockScriptEngine. - m_lslApi = new LSL_Api(); - m_lslApi.Initialize(m_engine, m_so.RootPart, m_scriptItem); - } - - [Test] - public void TestLlGetNotecardLine() - { - TestHelpers.InMethod(); - - string[] ncLines = { "One", "Twoè", "Three" }; - - TaskInventoryItem ncItem - = TaskInventoryHelpers.AddNotecard(m_scene.AssetService, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines)); - - AssertValidNotecardLine(ncItem.Name, 0, ncLines[0]); - AssertValidNotecardLine(ncItem.Name, 2, ncLines[2]); - AssertValidNotecardLine(ncItem.Name, 3, ScriptBaseClass.EOF); - AssertValidNotecardLine(ncItem.Name, 4, ScriptBaseClass.EOF); - - // XXX: Is this correct or do we really expect no dataserver event to fire at all? - AssertValidNotecardLine(ncItem.Name, -1, ""); - AssertValidNotecardLine(ncItem.Name, -2, ""); - } - - [Test] - public void TestLlGetNotecardLine_NoNotecard() - { - TestHelpers.InMethod(); - - AssertInValidNotecardLine("nc", 0); - } - - [Test] - public void TestLlGetNotecardLine_NotANotecard() - { - TestHelpers.InMethod(); - - TaskInventoryItem ncItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart, "nc1", "Not important"); - - AssertInValidNotecardLine(ncItem.Name, 0); - } - - private void AssertValidNotecardLine(string ncName, int lineNumber, string assertLine) - { - string key = m_lslApi.llGetNotecardLine(ncName, lineNumber); - Assert.That(key, Is.Not.EqualTo(UUID.Zero.ToString())); - - Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(1)); - Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); - - List events = m_engine.PostedEvents[m_scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - - Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); - Assert.That(eventParams.Params[0].ToString(), Is.EqualTo(key)); - Assert.That(eventParams.Params[1].ToString(), Is.EqualTo(assertLine)); - - m_engine.ClearPostedEvents(); - } - - private void AssertInValidNotecardLine(string ncName, int lineNumber) - { - string key = m_lslApi.llGetNotecardLine(ncName, lineNumber); - Assert.That(key, Is.EqualTo(UUID.Zero.ToString())); - - Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(0)); - } - -// [Test] -// public void TestLlReleaseUrl() -// { -// TestHelpers.InMethod(); -// -// m_lslApi.llRequestURL(); -// string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString(); -// -// { -// // Check that the initial number of URLs is correct -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); -// } -// -// { -// // Check releasing a non-url -// m_lslApi.llReleaseURL("GARBAGE"); -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); -// } -// -// { -// // Check releasing a non-existing url -// m_lslApi.llReleaseURL("http://example.com"); -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); -// } -// -// { -// // Check URL release -// m_lslApi.llReleaseURL(returnedUri); -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); -// -// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); -// -// bool gotExpectedException = false; -// -// try -// { -// using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) -// {} -// } -// catch (WebException e) -// { -// using (HttpWebResponse response = (HttpWebResponse)e.Response) -// gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; -// } -// -// Assert.That(gotExpectedException, Is.True); -// } -// -// { -// // Check releasing the same URL again -// m_lslApi.llReleaseURL(returnedUri); -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); -// } -// } -// -// [Test] -// public void TestLlRequestUrl() -// { -// TestHelpers.InMethod(); -// -// string requestId = m_lslApi.llRequestURL(); -// Assert.That(requestId, Is.Not.EqualTo(UUID.Zero.ToString())); -// string returnedUri; -// -// { -// // Check that URL is correctly set up -// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); -// -// Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); -// -// List events = m_engine.PostedEvents[m_scriptItem.ItemID]; -// Assert.That(events.Count, Is.EqualTo(1)); -// EventParams eventParams = events[0]; -// Assert.That(eventParams.EventName, Is.EqualTo("http_request")); -// -// UUID returnKey; -// string rawReturnKey = eventParams.Params[0].ToString(); -// string method = eventParams.Params[1].ToString(); -// returnedUri = eventParams.Params[2].ToString(); -// -// Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); -// Assert.That(method, Is.EqualTo(ScriptBaseClass.URL_REQUEST_GRANTED)); -// Assert.That(Uri.IsWellFormedUriString(returnedUri, UriKind.Absolute), Is.True); -// } -// -// { -// // Check that request to URL works. -// string testResponse = "Hello World"; -// -// m_engine.ClearPostedEvents(); -// m_engine.PostEventHook -// += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse); -// -//// Console.WriteLine("Trying {0}", returnedUri); -// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); -// -// AssertHttpResponse(returnedUri, testResponse); -// -// Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); -// -// List events = m_engine.PostedEvents[m_scriptItem.ItemID]; -// Assert.That(events.Count, Is.EqualTo(1)); -// EventParams eventParams = events[0]; -// Assert.That(eventParams.EventName, Is.EqualTo("http_request")); -// -// UUID returnKey; -// string rawReturnKey = eventParams.Params[0].ToString(); -// string method = eventParams.Params[1].ToString(); -// string body = eventParams.Params[2].ToString(); -// -// Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); -// Assert.That(method, Is.EqualTo("GET")); -// Assert.That(body, Is.EqualTo("")); -// } -// } -// -// private void AssertHttpResponse(string uri, string expectedResponse) -// { -// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); -// -// using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) -// { -// using (Stream stream = webResponse.GetResponseStream()) -// { -// using (StreamReader reader = new StreamReader(stream)) -// { -// Assert.That(reader.ReadToEnd(), Is.EqualTo(expectedResponse)); -// } -// } -// } -// } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs deleted file mode 100644 index b994901b73f..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; -using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_ApiObjectTests : OpenSimTestCase - { - private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; - private const float FLOAT_ACCURACY = 0.00005f; - - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - [Test] - public void TestllGetLinkPrimitiveParams() - { - TestHelpers.InMethod(); - TestHelpers.EnableLogging(); - - UUID ownerId = TestHelpers.ParseTail(0x1); - - SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); - grp1.AbsolutePosition = new Vector3(10, 11, 12); - m_scene.AddSceneObject(grp1); - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, grp1.RootPart, null); - - // Check simple 1 prim case - { - LSL_List resList - = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); - - Assert.That(resList.Length, Is.EqualTo(1)); - } - - // Check 2 prim case - { - LSL_List resList - = apiGrp1.llGetLinkPrimitiveParams( - 1, - new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), - new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), - new LSL_Integer(2), - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); - - Assert.That(resList.Length, Is.EqualTo(2)); - } - - // Check invalid parameters are ignored - { - LSL_List resList - = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); - - Assert.That(resList.Length, Is.EqualTo(0)); - } - - // Check all parameters are ignored if an initial bad link is given - { - LSL_List resList - = apiGrp1.llGetLinkPrimitiveParams( - 3, - new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), - new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), - new LSL_Integer(1), - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); - - Assert.That(resList.Length, Is.EqualTo(0)); - } - - // Check only subsequent parameters are ignored when we hit the first bad link number - { - LSL_List resList - = apiGrp1.llGetLinkPrimitiveParams( - 1, - new LSL_List( - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), - new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), - new LSL_Integer(3), - new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); - - Assert.That(resList.Length, Is.EqualTo(1)); - } - } - - [Test] - // llSetPrimitiveParams and llGetPrimitiveParams test. - public void TestllSetPrimitiveParams() - { - TestHelpers.InMethod(); - - // Create Prim1. - Scene scene = new SceneHelpers().SetupScene(); - string obj1Name = "Prim1"; - UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); - SceneObjectPart part1 = - new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, - Vector3.Zero, Quaternion.Identity, - Vector3.Zero) { Name = obj1Name, UUID = objUuid }; - Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, part1, null); - - // Note that prim hollow check is passed with the other prim params in order to allow the - // specification of a different check value from the prim param. A cylinder, prism, sphere, - // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below - // specifies a value of 95% and checks to see if 70% was properly returned. - - // Test a sphere. - CheckllSetPrimitiveParams( - apiGrp1, - "test 1", // Prim test identification string - new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size - ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type - ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type - new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut - 0.80f, // Prim hollow - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple - 0.80f); // Prim hollow check - - // Test a prism. - CheckllSetPrimitiveParams( - apiGrp1, - "test 2", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type - ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.90f, // Prim hollow - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.90f); // Prim hollow check - - // Test a box. - CheckllSetPrimitiveParams( - apiGrp1, - "test 3", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_BOX, // Prim type - ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.99f, // Prim hollow - new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.99f); // Prim hollow check - - // Test a tube. - CheckllSetPrimitiveParams( - apiGrp1, - "test 4", // Prim test identification string - new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size - ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type - ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.00f, // Prim hollow - new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size - // Expression for y selected to test precision problems during byte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut - // Expression for y selected to test precision problems during sbyte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper - 1.11f, // Prim revolutions - 0.88f, // Prim radius - 0.95f, // Prim skew - 0.00f); // Prim hollow check - - // Test a prism. - CheckllSetPrimitiveParams( - apiGrp1, - "test 5", // Prim test identification string - new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size - ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type - ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type - new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.99f, // Prim hollow - // Expression for x selected to test precision problems during sbyte - // cast in SetPrimitiveShapeBlockParams. - new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist - // Expression for y selected to test precision problems during sbyte - // cast in SetPrimitiveShapeParams. - new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear - 0.70f); // Prim hollow check - - // Test a sculpted prim. - CheckllSetPrimitiveParams( - apiGrp1, - "test 6", // Prim test identification string - new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size - ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type - "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map - ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type - } - - // Set prim params for a box, cylinder or prism and check results. - public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, - float primHollowCheck) - { - // Set the prim params. - api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primTaper, primShear)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, api.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper"); - CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); - } - - // Set prim params for a sphere and check results. - public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) - { - // Set the prim params. - api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primDimple)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, api.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple"); - } - - // Set prim params for a torus, tube or ring and check results. - public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, - LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, - LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, - float primRev, float primRadius, float primSkew, float primHollowCheck) - { - // Set the prim params. - api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primHoleType, - primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, - primTaper, primRev, primRadius, primSkew)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Valdate settings. - CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, api.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); - CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); - CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); - CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size"); - CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); - CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut"); - CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper"); - Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); - Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim radius fail"); - Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY, - "TestllSetPrimitiveParams " + primTest + " prim skew fail"); - } - - // Set prim params for a sculpted prim and check results. - public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, - LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) - { - // Set the prim params. - api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, - ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); - - // Get params for prim to validate settings. - LSL_Types.list primParams = - api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); - - // Validate settings. - CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); - Assert.AreEqual(primType, api.llList2Integer(primParams, 1), - "TestllSetPrimitiveParams " + primTest + " prim type check fail"); - Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2), - "TestllSetPrimitiveParams " + primTest + " prim map check fail"); - Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3), - "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); - } - - public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) - { - // Check each vector component against expected result. - Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); - Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); - Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, - "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); - } - - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs deleted file mode 100644 index 98800d0b99c..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.Framework.Scenes; -using Nini.Config; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenMetaverse; -using System; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for LSL_Api - /// - [TestFixture, LongRunning] - public class LSL_ApiTest - { - private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; - private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; - private LSL_Api m_lslApi; - - [SetUp] - public void SetUp() - { - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - Scene scene = new SceneHelpers().SetupScene(); - SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; - - XEngine.XEngine engine = new XEngine.XEngine(); - engine.Initialise(initConfigSource); - engine.AddRegion(scene); - - m_lslApi = new LSL_Api(); - m_lslApi.Initialize(engine, part, null); - } - - [Test] - public void TestllAngleBetween() - { - TestHelpers.InMethod(); - - CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1, 1); - CheckllAngleBetween(new Vector3(1, 0, 0), 90, 1, 1); - CheckllAngleBetween(new Vector3(1, 0, 0), 180, 1, 1); - - CheckllAngleBetween(new Vector3(0, 1, 0), 0, 1, 1); - CheckllAngleBetween(new Vector3(0, 1, 0), 90, 1, 1); - CheckllAngleBetween(new Vector3(0, 1, 0), 180, 1, 1); - - CheckllAngleBetween(new Vector3(0, 0, 1), 0, 1, 1); - CheckllAngleBetween(new Vector3(0, 0, 1), 90, 1, 1); - CheckllAngleBetween(new Vector3(0, 0, 1), 180, 1, 1); - - CheckllAngleBetween(new Vector3(1, 1, 1), 0, 1, 1); - CheckllAngleBetween(new Vector3(1, 1, 1), 90, 1, 1); - CheckllAngleBetween(new Vector3(1, 1, 1), 180, 1, 1); - - CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1.6f, 1.8f); - CheckllAngleBetween(new Vector3(1, 0, 0), 90, 0.3f, 3.9f); - CheckllAngleBetween(new Vector3(1, 0, 0), 180, 8.8f, 7.4f); - - CheckllAngleBetween(new Vector3(0, 1, 0), 0, 9.8f, -9.4f); - CheckllAngleBetween(new Vector3(0, 1, 0), 90, 8.4f, -8.2f); - CheckllAngleBetween(new Vector3(0, 1, 0), 180, 0.4f, -5.8f); - - CheckllAngleBetween(new Vector3(0, 0, 1), 0, -6.8f, 3.4f); - CheckllAngleBetween(new Vector3(0, 0, 1), 90, -3.6f, 5.6f); - CheckllAngleBetween(new Vector3(0, 0, 1), 180, -3.8f, 1.1f); - - CheckllAngleBetween(new Vector3(1, 1, 1), 0, -7.7f, -2.0f); - CheckllAngleBetween(new Vector3(1, 1, 1), 90, -3.0f, -9.1f); - CheckllAngleBetween(new Vector3(1, 1, 1), 180, -7.9f, -8.0f); - } - - private void CheckllAngleBetween(Vector3 axis,float originalAngle, float denorm1, float denorm2) - { - Quaternion rotation1 = Quaternion.CreateFromAxisAngle(axis, 0); - Quaternion rotation2 = Quaternion.CreateFromAxisAngle(axis, ToRadians(originalAngle)); - rotation1 *= denorm1; - rotation2 *= denorm2; - - double deducedAngle = FromLslFloat(m_lslApi.llAngleBetween(ToLslQuaternion(rotation2), ToLslQuaternion(rotation1))); - - Assert.That(deducedAngle, Is.EqualTo(ToRadians(originalAngle)).Within(ANGLE_ACCURACY_IN_RADIANS), "TestllAngleBetween check fail"); - } - - #region Conversions to and from LSL_Types - - private float ToRadians(double degrees) - { - return (float)(Math.PI * degrees / 180); - } - - // private double FromRadians(float radians) - // { - // return radians * 180 / Math.PI; - // } - - private double FromLslFloat(LSL_Types.LSLFloat lslFloat) - { - return lslFloat.value; - } - - // private LSL_Types.LSLFloat ToLslFloat(double value) - // { - // return new LSL_Types.LSLFloat(value); - // } - - // private Quaternion FromLslQuaternion(LSL_Types.Quaternion lslQuaternion) - // { - // return new Quaternion((float)lslQuaternion.x, (float)lslQuaternion.y, (float)lslQuaternion.z, (float)lslQuaternion.s); - // } - - private LSL_Types.Quaternion ToLslQuaternion(Quaternion quaternion) - { - return new LSL_Types.Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); - } - - #endregion - - [Test] - // llRot2Euler test. - public void TestllRot2Euler() - { - TestHelpers.InMethod(); - - // 180, 90 and zero degree rotations. - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, 0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 1.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, -0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, 0.0f, 0.0f, 0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.5f, -0.5f, 0.5f, 0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.707107f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, -0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 0.0f, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, -0.707107f, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -1.0f, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, -0.707107f, 0.0f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.707107f, 0.0f, 0.0f, -0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.5f, -0.5f, -0.5f, -0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, -0.707107f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, -0.5f, 0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.0f, 0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, 0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, 0.707107f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, 0.5f, 0.5f, -0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, -0.707107f, 0.0f, -0.707107f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, -0.5f, -0.5f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, -0.707107f, 0.0f)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, 0.5f, -0.5f, 0.5f)); - - // A couple of messy rotations. - CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 5.651f, -3.1f, 67.023f)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.719188f, -0.408934f, -0.363998f, -0.427841f)); - - // Some deliberately malicious rotations (intended on provoking singularity errors) - // The "f" suffexes are deliberately omitted. - CheckllRot2Euler(new LSL_Types.Quaternion(0.50001f, 0.50001f, 0.50001f, 0.50001f)); - // More malice. The "f" suffixes are deliberately omitted. - CheckllRot2Euler(new LSL_Types.Quaternion(-0.701055, 0.092296, 0.701055, -0.092296)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.183005, -0.683010, 0.183005, 0.683010)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.430460, -0.560982, 0.430460, 0.560982)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.701066, 0.092301, -0.701066, 0.092301)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.183013, -0.683010, 0.183013, 0.683010)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.183005, -0.683014, -0.183005, -0.683014)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.353556, 0.612375, 0.353556, -0.612375)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.353554, -0.612385, -0.353554, 0.612385)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.560989, 0.430450, 0.560989, -0.430450)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.183013, 0.683009, -0.183013, 0.683009)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.430457, -0.560985, -0.430457, 0.560985)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.353552, 0.612360, -0.353552, -0.612360)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.499991, 0.500003, 0.499991, -0.500003)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.353555, -0.612385, -0.353555, -0.612385)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.701066, -0.092301, -0.701066, 0.092301)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.499991, 0.500007, 0.499991, -0.500007)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.683002, 0.183016, -0.683002, 0.183016)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.430458, 0.560982, 0.430458, 0.560982)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.499991, -0.500003, -0.499991, 0.500003)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.183009, 0.683011, -0.183009, 0.683011)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.560975, -0.430457, 0.560975, -0.430457)); - CheckllRot2Euler(new LSL_Types.Quaternion(0.701055, 0.092300, 0.701055, 0.092300)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.560990, 0.430459, -0.560990, 0.430459)); - CheckllRot2Euler(new LSL_Types.Quaternion(-0.092302, -0.701059, -0.092302, -0.701059)); - } - - /// - /// Check an llRot2Euler conversion. - /// - /// - /// Testing Rot2Euler this way instead of comparing against expected angles because - /// 1. There are several ways to get to the original Quaternion. For example a rotation - /// of PI and -PI will give the same result. But PI and -PI aren't equal. - /// 2. This method checks to see if the calculated angles from a quaternion can be used - /// to create a new quaternion to produce the same rotation. - /// However, can't compare the newly calculated quaternion against the original because - /// once again, there are multiple quaternions that give the same result. For instance - /// == <-X, -Y, -Z, -S>. Additionally, the magnitude of S can be changed - /// and will still result in the same rotation if the values for X, Y, Z are also changed - /// to compensate. - /// However, if two quaternions represent the same rotation, then multiplying the first - /// quaternion by the conjugate of the second, will give a third quaternion representing - /// a zero rotation. This can be tested for by looking at the X, Y, Z values which should - /// be zero. - /// - /// - private void CheckllRot2Euler(LSL_Types.Quaternion rot) - { - // Call LSL function to convert quaternion rotaion to euler radians. - LSL_Types.Vector3 eulerCalc = m_lslApi.llRot2Euler(rot); - // Now use the euler radians to recalculate a new quaternion rotation - LSL_Types.Quaternion newRot = m_lslApi.llEuler2Rot(eulerCalc); - // Multiple original quaternion by conjugate of quaternion calculated with angles. - LSL_Types.Quaternion check = rot * new LSL_Types.Quaternion(-newRot.x, -newRot.y, -newRot.z, newRot.s); - - Assert.AreEqual(0.0, check.x, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler X bounds check fail"); - Assert.AreEqual(0.0, check.y, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Y bounds check fail"); - Assert.AreEqual(0.0, check.z, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Z bounds check fail"); - } - - [Test] - public void TestllVecNorm() - { - TestHelpers.InMethod(); - - // Check special case for normalizing zero vector. - CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); - // Check various vectors. - CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d)); - CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d)); - CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d)); - CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d)); - } - - public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck) - { - // Call LSL function to normalize the vector. - LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec); - // Check each vector component against expected result. - Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component"); - Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component"); - Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component"); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs deleted file mode 100644 index 70a3a9e3daf..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_ApiUserTests : OpenSimTestCase - { - private Scene m_scene; - private MockScriptEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - m_engine = new MockScriptEngine(); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, m_engine); - } - - [Test] - public void TestLlRequestAgentDataOnline() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID userId = TestHelpers.ParseTail(0x1); - - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId); - - SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part); - - LSL_Api apiGrp1 = new LSL_Api(); - apiGrp1.Initialize(m_engine, part, scriptItem); - - // Initially long timeout to test cache - apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20000; - - // Offline test - { - apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); - - Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); - - List events = m_engine.PostedEvents[scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); - - string data = eventParams.Params[1].ToString(); - Assert.AreEqual(0, int.Parse(data)); - - m_engine.PostedEvents.Clear(); - } - - // Online test. Should get the 'wrong' result because of caching. - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); - - { - apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); - - Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); - - List events = m_engine.PostedEvents[scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); - - string data = eventParams.Params[1].ToString(); - Assert.AreEqual(0, int.Parse(data)); - - m_engine.PostedEvents.Clear(); - } - - apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20; - - // Make absolutely sure that we should trigger cache timeout. - Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 50); - - { - apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); - - Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); - - List events = m_engine.PostedEvents[scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); - - string data = eventParams.Params[1].ToString(); - Assert.AreEqual(1, int.Parse(data)); - - m_engine.PostedEvents.Clear(); - } - - m_scene.CloseAgent(userId, false); - - Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 50); - - { - apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); - - Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); - - List events = m_engine.PostedEvents[scriptItem.ItemID]; - Assert.That(events.Count, Is.EqualTo(1)); - EventParams eventParams = events[0]; - Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); - - string data = eventParams.Params[1].ToString(); - Assert.AreEqual(0, int.Parse(data)); - - m_engine.PostedEvents.Clear(); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs deleted file mode 100644 index f81e0af04d8..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs +++ /dev/null @@ -1,661 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_TypesTestLSLFloat : OpenSimTestCase - { - // Used for testing equality of two floats. - private double _lowPrecisionTolerance = 0.000001; - - private Dictionary m_intDoubleSet; - private Dictionary m_doubleDoubleSet; - private Dictionary m_doubleIntSet; - private Dictionary m_doubleUintSet; - private Dictionary m_stringDoubleSet; - private Dictionary m_doubleStringSet; - private List m_intList; - private List m_doubleList; - - /// - /// Sets up dictionaries and arrays used in the tests. - /// - [OneTimeSetUp] - public void SetUpDataSets() - { - m_intDoubleSet = new Dictionary(); - m_intDoubleSet.Add(2, 2.0); - m_intDoubleSet.Add(-2, -2.0); - m_intDoubleSet.Add(0, 0.0); - m_intDoubleSet.Add(1, 1.0); - m_intDoubleSet.Add(-1, -1.0); - m_intDoubleSet.Add(999999999, 999999999.0); - m_intDoubleSet.Add(-99999999, -99999999.0); - - m_doubleDoubleSet = new Dictionary(); - m_doubleDoubleSet.Add(2.0, 2.0); - m_doubleDoubleSet.Add(-2.0, -2.0); - m_doubleDoubleSet.Add(0.0, 0.0); - m_doubleDoubleSet.Add(1.0, 1.0); - m_doubleDoubleSet.Add(-1.0, -1.0); - m_doubleDoubleSet.Add(999999999.0, 999999999.0); - m_doubleDoubleSet.Add(-99999999.0, -99999999.0); - m_doubleDoubleSet.Add(0.5, 0.5); - m_doubleDoubleSet.Add(0.0005, 0.0005); - m_doubleDoubleSet.Add(0.6805, 0.6805); - m_doubleDoubleSet.Add(-0.5, -0.5); - m_doubleDoubleSet.Add(-0.0005, -0.0005); - m_doubleDoubleSet.Add(-0.6805, -0.6805); - m_doubleDoubleSet.Add(548.5, 548.5); - m_doubleDoubleSet.Add(2.0005, 2.0005); - m_doubleDoubleSet.Add(349485435.6805, 349485435.6805); - m_doubleDoubleSet.Add(-548.5, -548.5); - m_doubleDoubleSet.Add(-2.0005, -2.0005); - m_doubleDoubleSet.Add(-349485435.6805, -349485435.6805); - - m_doubleIntSet = new Dictionary(); - m_doubleIntSet.Add(2.0, 2); - m_doubleIntSet.Add(-2.0, -2); - m_doubleIntSet.Add(0.0, 0); - m_doubleIntSet.Add(1.0, 1); - m_doubleIntSet.Add(-1.0, -1); - m_doubleIntSet.Add(999999999.0, 999999999); - m_doubleIntSet.Add(-99999999.0, -99999999); - m_doubleIntSet.Add(0.5, 0); - m_doubleIntSet.Add(0.0005, 0); - m_doubleIntSet.Add(0.6805, 0); - m_doubleIntSet.Add(-0.5, 0); - m_doubleIntSet.Add(-0.0005, 0); - m_doubleIntSet.Add(-0.6805, 0); - m_doubleIntSet.Add(548.5, 548); - m_doubleIntSet.Add(2.0005, 2); - m_doubleIntSet.Add(349485435.6805, 349485435); - m_doubleIntSet.Add(-548.5, -548); - m_doubleIntSet.Add(-2.0005, -2); - m_doubleIntSet.Add(-349485435.6805, -349485435); - - m_doubleUintSet = new Dictionary(); - m_doubleUintSet.Add(2.0, 2); - m_doubleUintSet.Add(-2.0, 2); - m_doubleUintSet.Add(0.0, 0); - m_doubleUintSet.Add(1.0, 1); - m_doubleUintSet.Add(-1.0, 1); - m_doubleUintSet.Add(999999999.0, 999999999); - m_doubleUintSet.Add(-99999999.0, 99999999); - m_doubleUintSet.Add(0.5, 0); - m_doubleUintSet.Add(0.0005, 0); - m_doubleUintSet.Add(0.6805, 0); - m_doubleUintSet.Add(-0.5, 0); - m_doubleUintSet.Add(-0.0005, 0); - m_doubleUintSet.Add(-0.6805, 0); - m_doubleUintSet.Add(548.5, 548); - m_doubleUintSet.Add(2.0005, 2); - m_doubleUintSet.Add(349485435.6805, 349485435); - m_doubleUintSet.Add(-548.5, 548); - m_doubleUintSet.Add(-2.0005, 2); - m_doubleUintSet.Add(-349485435.6805, 349485435); - - m_stringDoubleSet = new Dictionary(); - m_stringDoubleSet.Add("2", 2.0); - m_stringDoubleSet.Add("-2", -2.0); - m_stringDoubleSet.Add("1", 1.0); - m_stringDoubleSet.Add("-1", -1.0); - m_stringDoubleSet.Add("0", 0.0); - m_stringDoubleSet.Add("999999999.0", 999999999.0); - m_stringDoubleSet.Add("-99999999.0", -99999999.0); - m_stringDoubleSet.Add("0.5", 0.5); - m_stringDoubleSet.Add("0.0005", 0.0005); - m_stringDoubleSet.Add("0.6805", 0.6805); - m_stringDoubleSet.Add("-0.5", -0.5); - m_stringDoubleSet.Add("-0.0005", -0.0005); - m_stringDoubleSet.Add("-0.6805", -0.6805); - m_stringDoubleSet.Add("548.5", 548.5); - m_stringDoubleSet.Add("2.0005", 2.0005); - m_stringDoubleSet.Add("349485435.6805", 349485435.6805); - m_stringDoubleSet.Add("-548.5", -548.5); - m_stringDoubleSet.Add("-2.0005", -2.0005); - m_stringDoubleSet.Add("-349485435.6805", -349485435.6805); - // some oddball combinations and exponents - m_stringDoubleSet.Add("", 0.0); - m_stringDoubleSet.Add("1.0E+5", 100000.0); - m_stringDoubleSet.Add("-1.0E+5", -100000.0); - m_stringDoubleSet.Add("-1E+5", -100000.0); - m_stringDoubleSet.Add("-1.E+5", -100000.0); - m_stringDoubleSet.Add("-1.E+5.0", -100000.0); - m_stringDoubleSet.Add("1ef", 1.0); - m_stringDoubleSet.Add("e10", 0.0); - m_stringDoubleSet.Add("1.e0.0", 1.0); - - m_doubleStringSet = new Dictionary(); - m_doubleStringSet.Add(2.0, "2.000000"); - m_doubleStringSet.Add(-2.0, "-2.000000"); - m_doubleStringSet.Add(1.0, "1.000000"); - m_doubleStringSet.Add(-1.0, "-1.000000"); - m_doubleStringSet.Add(0.0, "0.000000"); - m_doubleStringSet.Add(999999999.0, "999999999.000000"); - m_doubleStringSet.Add(-99999999.0, "-99999999.000000"); - m_doubleStringSet.Add(0.5, "0.500000"); - m_doubleStringSet.Add(0.0005, "0.000500"); - m_doubleStringSet.Add(0.6805, "0.680500"); - m_doubleStringSet.Add(-0.5, "-0.500000"); - m_doubleStringSet.Add(-0.0005, "-0.000500"); - m_doubleStringSet.Add(-0.6805, "-0.680500"); - m_doubleStringSet.Add(548.5, "548.500000"); - m_doubleStringSet.Add(2.0005, "2.000500"); - m_doubleStringSet.Add(349485435.6805, "349485435.680500"); - m_doubleStringSet.Add(-548.5, "-548.500000"); - m_doubleStringSet.Add(-2.0005, "-2.000500"); - m_doubleStringSet.Add(-349485435.6805, "-349485435.680500"); - - m_doubleList = new List(); - m_doubleList.Add(2.0); - m_doubleList.Add(-2.0); - m_doubleList.Add(1.0); - m_doubleList.Add(-1.0); - m_doubleList.Add(999999999.0); - m_doubleList.Add(-99999999.0); - m_doubleList.Add(0.5); - m_doubleList.Add(0.0005); - m_doubleList.Add(0.6805); - m_doubleList.Add(-0.5); - m_doubleList.Add(-0.0005); - m_doubleList.Add(-0.6805); - m_doubleList.Add(548.5); - m_doubleList.Add(2.0005); - m_doubleList.Add(349485435.6805); - m_doubleList.Add(-548.5); - m_doubleList.Add(-2.0005); - m_doubleList.Add(-349485435.6805); - - m_intList = new List(); - m_intList.Add(2); - m_intList.Add(-2); - m_intList.Add(0); - m_intList.Add(1); - m_intList.Add(-1); - m_intList.Add(999999999); - m_intList.Add(-99999999); - } - - /// - /// Tests constructing a LSLFloat from an integer. - /// - [Test] - public void TestConstructFromInt() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (KeyValuePair number in m_intDoubleSet) - { - testFloat = new LSL_Types.LSLFloat(number.Key); - Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests constructing a LSLFloat from a double. - /// - [Test] - public void TestConstructFromDouble() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (KeyValuePair number in m_doubleDoubleSet) - { - testFloat = new LSL_Types.LSLFloat(number.Key); - Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLFloat is correctly cast explicitly to integer. - /// - [Test] - public void TestExplicitCastLSLFloatToInt() - { - TestHelpers.InMethod(); - - int testNumber; - - foreach (KeyValuePair number in m_doubleIntSet) - { - testNumber = (int) new LSL_Types.LSLFloat(number.Key); - Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); - } - } - - /// - /// Tests LSLFloat is correctly cast explicitly to unsigned integer. - /// - [Test] - public void TestExplicitCastLSLFloatToUint() - { - TestHelpers.InMethod(); - - uint testNumber; - - foreach (KeyValuePair number in m_doubleUintSet) - { - testNumber = (uint) new LSL_Types.LSLFloat(number.Key); - Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); - } - } - - /// - /// Tests LSLFloat is correctly cast implicitly to Boolean if non-zero. - /// - [Test] - public void TestImplicitCastLSLFloatToBooleanTrue() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - bool testBool; - - foreach (double number in m_doubleList) - { - testFloat = new LSL_Types.LSLFloat(number); - testBool = testFloat; - - Assert.IsTrue(testBool); - } - } - - /// - /// Tests LSLFloat is correctly cast implicitly to Boolean if zero. - /// - [Test] - public void TestImplicitCastLSLFloatToBooleanFalse() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); - bool testBool = testFloat; - - Assert.IsFalse(testBool); - } - - /// - /// Tests integer is correctly cast implicitly to LSLFloat. - /// - [Test] - public void TestImplicitCastIntToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (int number in m_intList) - { - testFloat = number; - Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLInteger is correctly cast implicitly to LSLFloat. - /// - [Test] - public void TestImplicitCastLSLIntegerToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (int number in m_intList) - { - testFloat = new LSL_Types.LSLInteger(number); - Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLInteger is correctly cast explicitly to LSLFloat. - /// - [Test] - public void TestExplicitCastLSLIntegerToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (int number in m_intList) - { - testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLInteger(number); - Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - } - } - - /// - /// Tests string is correctly cast explicitly to LSLFloat. - /// - [Test] - public void TestExplicitCastStringToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (KeyValuePair number in m_stringDoubleSet) - { - testFloat = (LSL_Types.LSLFloat) number.Key; - Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLString is correctly cast implicitly to LSLFloat. - /// - [Test] - public void TestExplicitCastLSLStringToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (KeyValuePair number in m_stringDoubleSet) - { - testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLString(number.Key); - Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests double is correctly cast implicitly to LSLFloat. - /// - [Test] - public void TestImplicitCastDoubleToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (double number in m_doubleList) - { - testFloat = number; - Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLFloat is correctly cast implicitly to double. - /// - [Test] - public void TestImplicitCastLSLFloatToDouble() - { - TestHelpers.InMethod(); - - double testNumber; - LSL_Types.LSLFloat testFloat; - - foreach (double number in m_doubleList) - { - testFloat = new LSL_Types.LSLFloat(number); - testNumber = testFloat; - - Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLFloat is correctly cast explicitly to float - /// - [Test] - public void TestExplicitCastLSLFloatToFloat() - { - TestHelpers.InMethod(); - - float testFloat; - float numberAsFloat; - LSL_Types.LSLFloat testLSLFloat; - - foreach (double number in m_doubleList) - { - testLSLFloat = new LSL_Types.LSLFloat(number); - numberAsFloat = (float)number; - testFloat = (float)testLSLFloat; - - Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance)); - } - } - - /// - /// Tests the equality (==) operator. - /// - [Test] - public void TestEqualsOperator() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloatA, testFloatB; - - foreach (double number in m_doubleList) - { - testFloatA = new LSL_Types.LSLFloat(number); - testFloatB = new LSL_Types.LSLFloat(number); - Assert.IsTrue(testFloatA == testFloatB); - - testFloatB = new LSL_Types.LSLFloat(number + 1.0); - Assert.IsFalse(testFloatA == testFloatB); - } - } - - /// - /// Tests the inequality (!=) operator. - /// - [Test] - public void TestNotEqualOperator() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloatA, testFloatB; - - foreach (double number in m_doubleList) - { - testFloatA = new LSL_Types.LSLFloat(number); - testFloatB = new LSL_Types.LSLFloat(number + 1.0); - Assert.IsTrue(testFloatA != testFloatB); - - testFloatB = new LSL_Types.LSLFloat(number); - Assert.IsFalse(testFloatA != testFloatB); - } - } - - /// - /// Tests the increment operator. - /// - [Test] - public void TestIncrementOperator() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - double testNumber; - - foreach (double number in m_doubleList) - { - testFloat = new LSL_Types.LSLFloat(number); - - testNumber = testFloat++; - Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - - testNumber = testFloat; - Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance)); - - testNumber = ++testFloat; - Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance)); - } - } - - /// - /// Tests the decrement operator. - /// - [Test] - public void TestDecrementOperator() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - double testNumber; - - foreach (double number in m_doubleList) - { - testFloat = new LSL_Types.LSLFloat(number); - - testNumber = testFloat--; - Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); - - testNumber = testFloat; - Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance)); - - testNumber = --testFloat; - Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance)); - } - } - - /// - /// Tests LSLFloat.ToString(). - /// - [Test] - public void TestToString() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - foreach (KeyValuePair number in m_doubleStringSet) - { - testFloat = new LSL_Types.LSLFloat(number.Key); - Assert.AreEqual(number.Value, testFloat.ToString()); - } - } - - /// - /// Tests addition of two LSLFloats. - /// - [Test] - public void TestAddTwoLSLFloats() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testResult; - - foreach (KeyValuePair number in m_doubleDoubleSet) - { - testResult = new LSL_Types.LSLFloat(number.Key) + new LSL_Types.LSLFloat(number.Value); - Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key + number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests subtraction of two LSLFloats. - /// - [Test] - public void TestSubtractTwoLSLFloats() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testResult; - - foreach (KeyValuePair number in m_doubleDoubleSet) - { - testResult = new LSL_Types.LSLFloat(number.Key) - new LSL_Types.LSLFloat(number.Value); - Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key - number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests multiplication of two LSLFloats. - /// - [Test] - public void TestMultiplyTwoLSLFloats() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testResult; - - foreach (KeyValuePair number in m_doubleDoubleSet) - { - testResult = new LSL_Types.LSLFloat(number.Key) * new LSL_Types.LSLFloat(number.Value); - Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key * number.Value, _lowPrecisionTolerance)); - } - } - - /// - /// Tests division of two LSLFloats. - /// - [Test] - public void TestDivideTwoLSLFloats() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testResult; - - foreach (KeyValuePair number in m_doubleDoubleSet) - { - if (number.Value != 0.0) // Let's avoid divide by zero. - { - testResult = new LSL_Types.LSLFloat(number.Key) / new LSL_Types.LSLFloat(number.Value); - Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key / number.Value, _lowPrecisionTolerance)); - } - } - } - - /// - /// Tests boolean correctly cast implicitly to LSLFloat. - /// - [Test] - public void TestImplicitCastBooleanToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testFloat; - - testFloat = (1 == 0); - Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance)); - - testFloat = (1 == 1); - Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance)); - - testFloat = false; - Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance)); - - testFloat = true; - Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs deleted file mode 100644 index 41b5bcc0b8f..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_TypesTestLSLInteger : OpenSimTestCase - { - private Dictionary m_doubleIntSet; - private Dictionary m_stringIntSet; - - /// - /// Sets up dictionaries and arrays used in the tests. - /// - [OneTimeSetUp] - public void SetUpDataSets() - { - m_doubleIntSet = new Dictionary(); - m_doubleIntSet.Add(2.0, 2); - m_doubleIntSet.Add(-2.0, -2); - m_doubleIntSet.Add(0.0, 0); - m_doubleIntSet.Add(1.0, 1); - m_doubleIntSet.Add(-1.0, -1); - m_doubleIntSet.Add(999999999.0, 999999999); - m_doubleIntSet.Add(-99999999.0, -99999999); - - m_stringIntSet = new Dictionary(); - m_stringIntSet.Add("2", 2); - m_stringIntSet.Add("-2", -2); - m_stringIntSet.Add("0", 0); - m_stringIntSet.Add("1", 1); - m_stringIntSet.Add("-1", -1); - m_stringIntSet.Add("123.9", 123); - m_stringIntSet.Add("999999999", 999999999); - m_stringIntSet.Add("-99999999", -99999999); - m_stringIntSet.Add("", 0); - m_stringIntSet.Add("aa", 0); - m_stringIntSet.Add("56foo", 56); - m_stringIntSet.Add("42", 42); - m_stringIntSet.Add("42 is the answer", 42); - m_stringIntSet.Add(" 42", 42); - m_stringIntSet.Add("42,123,456", 42); - m_stringIntSet.Add("0xff", 255); - m_stringIntSet.Add("12345678900000", -1); - } - - /// - /// Tests LSLFloat is correctly cast explicitly to LSLInteger. - /// - [Test] - public void TestExplicitCastLSLFloatToLSLInteger() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testInteger; - - foreach (KeyValuePair number in m_doubleIntSet) - { - testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLFloat(number.Key); - Assert.AreEqual(testInteger.value, number.Value); - } - } - - /// - /// Tests string is correctly cast explicitly to LSLInteger. - /// - [Test] - public void TestExplicitCastStringToLSLInteger() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testInteger; - - foreach (KeyValuePair number in m_stringIntSet) - { - testInteger = (LSL_Types.LSLInteger) number.Key; - Assert.AreEqual(testInteger.value, number.Value); - } - } - - /// - /// Tests LSLString is correctly cast explicitly to LSLInteger. - /// - [Test] - public void TestExplicitCastLSLStringToLSLInteger() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testInteger; - - foreach (KeyValuePair number in m_stringIntSet) - { - testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLString(number.Key); - Assert.AreEqual(testInteger.value, number.Value); - } - } - - /// - /// Tests boolean correctly cast implicitly to LSLInteger. - /// - [Test] - public void TestImplicitCastBooleanToLSLInteger() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testInteger; - - testInteger = (1 == 0); - Assert.AreEqual(0, testInteger.value); - - testInteger = (1 == 1); - Assert.AreEqual(1, testInteger.value); - - testInteger = false; - Assert.AreEqual(0, testInteger.value); - - testInteger = true; - Assert.AreEqual(1, testInteger.value); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs deleted file mode 100644 index 70c1a381c06..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - [TestFixture] - public class LSL_TypesTestLSLString : OpenSimTestCase - { - private Dictionary m_doubleStringSet; - - /// - /// Sets up dictionaries and arrays used in the tests. - /// - [OneTimeSetUp] - public void SetUpDataSets() - { - m_doubleStringSet = new Dictionary(); - m_doubleStringSet.Add(2, "2.000000"); - m_doubleStringSet.Add(-2, "-2.000000"); - m_doubleStringSet.Add(0, "0.000000"); - m_doubleStringSet.Add(1, "1.000000"); - m_doubleStringSet.Add(-1, "-1.000000"); - m_doubleStringSet.Add(999999999, "999999999.000000"); - m_doubleStringSet.Add(-99999999, "-99999999.000000"); - m_doubleStringSet.Add(0.5, "0.500000"); - m_doubleStringSet.Add(0.0005, "0.000500"); - m_doubleStringSet.Add(0.6805, "0.680500"); - m_doubleStringSet.Add(-0.5, "-0.500000"); - m_doubleStringSet.Add(-0.0005, "-0.000500"); - m_doubleStringSet.Add(-0.6805, "-0.680500"); - m_doubleStringSet.Add(548.5, "548.500000"); - m_doubleStringSet.Add(2.0005, "2.000500"); - m_doubleStringSet.Add(349485435.6805, "349485435.680500"); - m_doubleStringSet.Add(-548.5, "-548.500000"); - m_doubleStringSet.Add(-2.0005, "-2.000500"); - m_doubleStringSet.Add(-349485435.6805, "-349485435.680500"); - } - - /// - /// Tests constructing a LSLString from an LSLFloat. - /// - [Test] - public void TestConstructFromLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLString testString; - - foreach (KeyValuePair number in m_doubleStringSet) - { - testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key)); - Assert.AreEqual(number.Value, testString.m_string); - } - } - - /// - /// Tests constructing a LSLString from an LSLFloat. - /// - [Test] - public void TestExplicitCastLSLFloatToLSLString() - { - TestHelpers.InMethod(); - - LSL_Types.LSLString testString; - - foreach (KeyValuePair number in m_doubleStringSet) - { - testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key); - Assert.AreEqual(number.Value, testString.m_string); - } - } - - /// - /// Test constructing a Quaternion from a string. - /// - [Test] - public void TestExplicitCastLSLStringToQuaternion() - { - TestHelpers.InMethod(); - - string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>"; - LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString); - - LSL_Types.Quaternion expectedQuaternion = new LSL_Types.Quaternion(0.0, 0.70711, 0.0, 0.70711); - LSL_Types.Quaternion stringQuaternion = (LSL_Types.Quaternion) quaternionString; - LSL_Types.Quaternion LSLStringQuaternion = (LSL_Types.Quaternion) quaternionLSLString; - - Assert.AreEqual(expectedQuaternion, stringQuaternion); - Assert.AreEqual(expectedQuaternion, LSLStringQuaternion); - } - - /// - /// Tests boolean correctly cast explicitly to LSLString. - /// - [Test] - public void TestImplicitCastBooleanToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLString testString; - - testString = (LSL_Types.LSLString) (1 == 0); - Assert.AreEqual("0", testString.m_string); - - testString = (LSL_Types.LSLString) (1 == 1); - Assert.AreEqual("1", testString.m_string); - - testString = (LSL_Types.LSLString) false; - Assert.AreEqual("0", testString.m_string); - - testString = (LSL_Types.LSLString) true; - Assert.AreEqual("1", testString.m_string); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs deleted file mode 100644 index fe2113bd561..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests the LSL_Types.list class. - /// - [TestFixture] - public class LSL_TypesTestList : OpenSimTestCase - { - /// - /// Tests concatenating a string to a list. - /// - [Test] - public void TestConcatenateString() - { - TestHelpers.InMethod(); - - LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); - testList += new LSL_Types.LSLString("addition"); - - Assert.AreEqual(4, testList.Length); - Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]); - Assert.AreEqual(typeof(LSL_Types.LSLString), testList.Data[3].GetType()); - - LSL_Types.list secondTestList = testList + new LSL_Types.LSLString("more"); - - Assert.AreEqual(5, secondTestList.Length); - Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]); - Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType()); - } - - /// - /// Tests concatenating an integer to a list. - /// - [Test] - public void TestConcatenateInteger() - { - TestHelpers.InMethod(); - - LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); - testList += new LSL_Types.LSLInteger(20); - - Assert.AreEqual(4, testList.Length); - Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]); - Assert.AreEqual(typeof(LSL_Types.LSLInteger), testList.Data[3].GetType()); - - LSL_Types.list secondTestList = testList + new LSL_Types.LSLInteger(2); - - Assert.AreEqual(5, secondTestList.Length); - Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]); - Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType()); - } - - /// - /// Tests concatenating a float to a list. - /// - [Test] - public void TestConcatenateDouble() - { - TestHelpers.InMethod(); - - LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); - testList += new LSL_Types.LSLFloat(2.0f); - - Assert.AreEqual(4, testList.Length); - Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]); - Assert.AreEqual(typeof(LSL_Types.LSLFloat), testList.Data[3].GetType()); - - LSL_Types.list secondTestList = testList + new LSL_Types.LSLFloat(0.04f); - - Assert.AreEqual(5, secondTestList.Length); - Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]); - Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType()); - } - - /// - /// Tests casting LSLInteger item to LSLInteger. - /// - [Test] - public void TestCastLSLIntegerItemToLSLInteger() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, (LSL_Types.LSLInteger)testList.Data[0]); - } - - /// - /// Tests casting LSLFloat item to LSLFloat. - /// - [Test] - public void TestCastLSLFloatItemToLSLFloat() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, (LSL_Types.LSLFloat)testList.Data[0]); - } - - /// - /// Tests casting LSLString item to LSLString. - /// - [Test] - public void TestCastLSLStringItemToLSLString() - { - TestHelpers.InMethod(); - - LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there"); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, (LSL_Types.LSLString)testList.Data[0]); - } - - /// - /// Tests casting Vector3 item to Vector3. - /// - [Test] - public void TestCastVector3ItemToVector3() - { - TestHelpers.InMethod(); - - LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, (LSL_Types.Vector3)testList.Data[0]); - } - /// - /// Tests casting Quaternion item to Quaternion. - /// - [Test] - public void TestCastQuaternionItemToQuaternion() - { - TestHelpers.InMethod(); - - LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]); - } - -//==================================================================================== - - /// - /// Tests GetLSLIntegerItem for LSLInteger item. - /// - [Test] - public void TestGetLSLIntegerItemForLSLIntegerItem() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetLSLIntegerItem(0)); - } - - /// - /// Tests GetLSLFloatItem for LSLFloat item. - /// - [Test] - public void TestGetLSLFloatItemForLSLFloatItem() - { - TestHelpers.InMethod(); - - LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetLSLFloatItem(0)); - } - - /// - /// Tests GetLSLFloatItem for LSLInteger item. - /// - [Test] - public void TestGetLSLFloatItemForLSLIntegerItem() - { - TestHelpers.InMethod(); - - LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); - LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); - } - - /// - /// Tests GetLSLStringItem for LSLString item. - /// - [Test] - public void TestGetLSLStringItemForLSLStringItem() - { - TestHelpers.InMethod(); - - LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all"); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetLSLStringItem(0)); - } - - /// - /// Tests GetLSLStringItem for key item. - /// - [Test] - public void TestGetLSLStringItemForKeyItem() - { - TestHelpers.InMethod(); - - LSL_Types.key testValue - = new LSL_Types.key("98000000-0000-2222-3333-100000001000"); - LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testStringValue, testList.GetLSLStringItem(0)); - } - - /// - /// Tests GetVector3Item for Vector3 item. - /// - [Test] - public void TestGetVector3ItemForVector3Item() - { - TestHelpers.InMethod(); - - LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetVector3Item(0)); - } - /// - /// Tests GetQuaternionItem for Quaternion item. - /// - [Test] - public void TestGetQuaternionItemForQuaternionItem() - { - TestHelpers.InMethod(); - - LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); - // make that nonsense a quaternion - testValue.Normalize(); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetQuaternionItem(0)); - } - - /// - /// Tests GetKeyItem for key item. - /// - [Test] - public void TestGetKeyItemForKeyItem() - { - TestHelpers.InMethod(); - - LSL_Types.key testValue - = new LSL_Types.key("00000000-0000-2222-3333-100000001012"); - LSL_Types.list testList = new LSL_Types.list(testValue); - - Assert.AreEqual(testValue, testList.GetKeyItem(0)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs deleted file mode 100644 index 0c838afa3c7..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using NUnit.Framework; -using OpenSim.Tests.Common; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for Vector3 - /// - [TestFixture] - public class LSL_TypesTestVector3 : OpenSimTestCase - { - [Test] - public void TestDotProduct() - { - TestHelpers.InMethod(); - - // The numbers we test for. - Dictionary expectsSet = new Dictionary(); - expectsSet.Add("<1, 2, 3> * <2, 3, 4>", 20.0); - expectsSet.Add("<1, 2, 3> * <0, 0, 0>", 0.0); - - double result; - string[] parts; - string[] delim = { "*" }; - - foreach (KeyValuePair ex in expectsSet) - { - parts = ex.Key.Split(delim, System.StringSplitOptions.None); - result = new LSL_Types.Vector3(parts[0]) * new LSL_Types.Vector3(parts[1]); - Assert.AreEqual(ex.Value, result); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs deleted file mode 100644 index 7d042c69115..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for OSSL_Api - /// - [TestFixture] - public class OSSL_ApiAppearanceTest : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("NPC"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - [Test] - public void TestOsOwnerSaveAppearance() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - UUID userId = TestHelpers.ParseTail(0x1); - float newHeight = 1.9f; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = newHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - string notecardName = "appearanceNc"; - - osslApi.osOwnerSaveAppearance(notecardName); - - IList items = part.Inventory.GetInventoryItems(notecardName); - Assert.That(items.Count, Is.EqualTo(1)); - - TaskInventoryItem ncItem = items[0]; - Assert.That(ncItem.Name, Is.EqualTo(notecardName)); - - AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); - Assert.That(ncAsset, Is.Not.Null); - - AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); - anc.Decode(); - OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); - AvatarAppearance savedAppearance = new AvatarAppearance(); - savedAppearance.Unpack(appearanceOsd); - - Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); - } - - [Test] - public void TestOsAgentSaveAppearance() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - UUID ownerId = TestHelpers.ParseTail(0x1); - UUID nonOwnerId = TestHelpers.ParseTail(0x2); - float newHeight = 1.9f; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId); - sp.Appearance.AvatarHeight = newHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - string notecardName = "appearanceNc"; - - osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName); - - IList items = part.Inventory.GetInventoryItems(notecardName); - Assert.That(items.Count, Is.EqualTo(1)); - - TaskInventoryItem ncItem = items[0]; - Assert.That(ncItem.Name, Is.EqualTo(notecardName)); - - AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); - Assert.That(ncAsset, Is.Not.Null); - - AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); - anc.Decode(); - OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); - AvatarAppearance savedAppearance = new AvatarAppearance(); - savedAppearance.Unpack(appearanceOsd); - - Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs deleted file mode 100644 index c7fdefc2e52..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.Attachments; -using OpenSim.Region.CoreModules.Framework.InventoryAccess; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for OSSL attachment functions - /// - /// - /// TODO: Add tests for all functions - /// - [TestFixture] - public class OSSL_ApiAttachmentTests : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - - IConfig xengineConfig = initConfigSource.AddConfig("XEngine"); - xengineConfig.Set("Enabled", "true"); - - IConfig oconfig = initConfigSource.AddConfig("OSSL"); - oconfig.Set("DebuggerSafe", false); - oconfig.Set("AllowOSFunctions", "true"); - oconfig.Set("OSFunctionThreatLevel", "Severe"); - - IConfig modulesConfig = initConfigSource.AddConfig("Modules"); - modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules( - m_scene, initConfigSource, new AttachmentsModule(), new BasicInventoryAccessModule()); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - [Test] - public void TestOsForceAttachToAvatarFromInventory() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string taskInvObjItemName = "sphere"; - UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - AttachmentPoint attachPoint = AttachmentPoint.Chin; - - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); - SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); - - new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); - -// SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); - - // Create an object embedded inside the first - TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); - - osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); - - // Check scene presence status - Assert.That(sp.HasAttachments(), Is.True); - List attachments = sp.GetAttachments(); - Assert.That(attachments.Count, Is.EqualTo(1)); - SceneObjectGroup attSo = attachments[0]; - Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); - Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); - Assert.That(attSo.IsAttachment); - Assert.That(attSo.UsesPhysics, Is.False); - Assert.That(attSo.IsTemporary, Is.False); - - // Check appearance status - List attachmentsInAppearance = sp.Appearance.GetAttachments(); - Assert.That(attachmentsInAppearance.Count, Is.EqualTo(1)); - Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint)); - } - - /// - /// Make sure we can't force attach anything other than objects. - /// - [Test] - public void TestOsForceAttachToAvatarFromInventoryNotObject() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string taskInvObjItemName = "sphere"; - UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - AttachmentPoint attachPoint = AttachmentPoint.Chin; - - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); - SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); - - new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); - - // Create an object embedded inside the first - TaskInventoryHelpers.AddNotecard( - m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!"); - - bool exceptionCaught = false; - - try - { - osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); - } - catch (Exception) - { - exceptionCaught = true; - } - - Assert.That(exceptionCaught, Is.True); - - // Check scene presence status - Assert.That(sp.HasAttachments(), Is.False); - List attachments = sp.GetAttachments(); - Assert.That(attachments.Count, Is.EqualTo(0)); - - // Check appearance status - List attachmentsInAppearance = sp.Appearance.GetAttachments(); - Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); - } - - [Test] - public void TestOsForceAttachToOtherAvatarFromInventory() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string taskInvObjItemName = "sphere"; - UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - AttachmentPoint attachPoint = AttachmentPoint.Chin; - - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass"); - UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass"); - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); - SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); - TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart); - - new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); - - // Create an object embedded inside the first - TaskInventoryHelpers.AddSceneObject( - m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); - - ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); - - osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint); - - // Check scene presence status - Assert.That(sp.HasAttachments(), Is.False); - List attachments = sp.GetAttachments(); - Assert.That(attachments.Count, Is.EqualTo(0)); - - Assert.That(sp2.HasAttachments(), Is.True); - List attachments2 = sp2.GetAttachments(); - Assert.That(attachments2.Count, Is.EqualTo(1)); - SceneObjectGroup attSo = attachments2[0]; - Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); - Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID)); - Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); - Assert.That(attSo.IsAttachment); - Assert.That(attSo.UsesPhysics, Is.False); - Assert.That(attSo.IsTemporary, Is.False); - - // Check appearance status - List attachmentsInAppearance = sp.Appearance.GetAttachments(); - Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); - - List attachmentsInAppearance2 = sp2.Appearance.GetAttachments(); - Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1)); - Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint)); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs deleted file mode 100644 index b44cc1641c9..00000000000 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.Attachments; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Shared.Tests -{ - /// - /// Tests for OSSL NPC API - /// - [TestFixture] - public class OSSL_NpcApiAppearanceTest : OpenSimTestCase - { - protected Scene m_scene; - protected XEngine.XEngine m_engine; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - - IConfigSource initConfigSource = new IniConfigSource(); - IConfig config = initConfigSource.AddConfig("XEngine"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("NPC"); - config.Set("Enabled", "true"); - - config = initConfigSource.AddConfig("OSSL"); - config.Set("DebuggerSafe", false); - config.Set("AllowOSFunctions", "true"); - config.Set("OSFunctionThreatLevel", "Severe"); - - m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules( - m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule()); - - m_engine = new XEngine.XEngine(); - m_engine.Initialise(initConfigSource); - m_engine.AddRegion(m_scene); - } - - /// - /// Test creation of an NPC where the appearance data comes from a notecard - /// - [Test] - public void TestOsNpcCreateUsingAppearanceFromNotecard() - { - TestHelpers.InMethod(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - float newHeight = 1.9f; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = newHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - string notecardName = "appearanceNc"; - osslApi.osOwnerSaveAppearance(notecardName); - - // Try creating a bot using the appearance in the notecard. - string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName); - Assert.That(npcRaw, Is.Not.Null); - - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Not.Null); - Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); - } - - [Test] - public void TestOsNpcCreateNotExistingNotecard() - { - TestHelpers.InMethod(); - - UUID userId = TestHelpers.ParseTail(0x1); - - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, so.RootPart, null); - - bool gotExpectedException = false; - try - { - osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name"); - } - catch (ScriptException) - { - gotExpectedException = true; - } - - Assert.That(gotExpectedException, Is.True); - } - - /// - /// Test creation of an NPC where the appearance data comes from an avatar already in the region. - /// - [Test] - public void TestOsNpcCreateUsingAppearanceFromAvatar() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - float newHeight = 1.9f; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = newHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - string notecardName = "appearanceNc"; - osslApi.osOwnerSaveAppearance(notecardName); - - // Try creating a bot using the existing avatar's appearance - string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString()); - Assert.That(npcRaw, Is.Not.Null); - - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Not.Null); - Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); - } - - [Test] - public void TestOsNpcLoadAppearance() - { - TestHelpers.InMethod(); - //TestHelpers.EnableLogging(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - float firstHeight = 1.9f; - float secondHeight = 2.1f; - string firstAppearanceNcName = "appearanceNc1"; - string secondAppearanceNcName = "appearanceNc2"; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = firstHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - osslApi.osOwnerSaveAppearance(firstAppearanceNcName); - - string npcRaw - = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); - - // Create a second appearance notecard with a different height - sp.Appearance.AvatarHeight = secondHeight; - osslApi.osOwnerSaveAppearance(secondAppearanceNcName); - - osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); - - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Not.Null); - Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight)); - } - - [Test] - public void TestOsNpcLoadAppearanceNotExistingNotecard() - { - TestHelpers.InMethod(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - float firstHeight = 1.9f; -// float secondHeight = 2.1f; - string firstAppearanceNcName = "appearanceNc1"; - string secondAppearanceNcName = "appearanceNc2"; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = firstHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - osslApi.osOwnerSaveAppearance(firstAppearanceNcName); - - string npcRaw - = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); - - bool gotExpectedException = false; - try - { - osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); - } - catch (ScriptException) - { - gotExpectedException = true; - } - - Assert.That(gotExpectedException, Is.True); - - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Not.Null); - Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight)); - } - - /// - /// Test removal of an owned NPC. - /// - [Test] - public void TestOsNpcRemoveOwned() - { - TestHelpers.InMethod(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - UUID otherUserId = TestHelpers.ParseTail(0x2); - float newHeight = 1.9f; - - SceneHelpers.AddScenePresence(m_scene, otherUserId); - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = newHeight; - - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId, 0x20); - SceneObjectPart otherPart = otherSo.RootPart; - m_scene.AddSceneObject(otherSo); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - OSSL_Api otherOsslApi = new OSSL_Api(); - otherOsslApi.Initialize(m_engine, otherPart, null); - - string notecardName = "appearanceNc"; - osslApi.osOwnerSaveAppearance(notecardName); - - string npcRaw - = osslApi.osNpcCreate( - "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_CREATOR_OWNED); - - otherOsslApi.osNpcRemove(npcRaw); - - // Should still be around - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Not.Null); - - osslApi.osNpcRemove(npcRaw); - - npc = m_scene.GetScenePresence(npcId); - - // Now the owner deleted it and it's gone - Assert.That(npc, Is.Null); - } - - /// - /// Test removal of an unowned NPC. - /// - [Test] - public void TestOsNpcRemoveUnowned() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - // Store an avatar with a different height from default in a notecard. - UUID userId = TestHelpers.ParseTail(0x1); - float newHeight = 1.9f; - - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - sp.Appearance.AvatarHeight = newHeight; - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); - SceneObjectPart part = so.RootPart; - m_scene.AddSceneObject(so); - - OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(m_engine, part, null); - - string notecardName = "appearanceNc"; - osslApi.osOwnerSaveAppearance(notecardName); - - string npcRaw - = osslApi.osNpcCreate( - "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); - - osslApi.osNpcRemove(npcRaw); - - UUID npcId = new UUID(npcRaw); - ScenePresence npc = m_scene.GetScenePresence(npcId); - Assert.That(npc, Is.Null); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/OpenSim.Region.ScriptEngine.XEngine.Api.Runtime.csproj b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/OpenSim.Region.ScriptEngine.XEngine.Api.Runtime.csproj deleted file mode 100644 index d560fd24f68..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/OpenSim.Region.ScriptEngine.XEngine.Api.Runtime.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - net48 - OpenSim.Region.ScriptEngine.XEngine.Api.Runtime - http://opensimulator.org - OpenSim - OpenSimulator developers - - - - - - - ..\..\..\..\..\..\bin\Nini.dll - False - - - ..\..\..\..\..\..\bin\OpenMetaverseTypes.dll - False - - - False - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs deleted file mode 100644 index 80d9e2a7616..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Runtime.Remoting; -using System.Runtime.Remoting.Lifetime; -using System.Security.Permissions; -using System.Threading; -using System.Reflection; -using System.Collections; -using System.Collections.Generic; -using OpenSim.Region.ScriptEngine.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; - -namespace OpenSim.Region.ScriptEngine.XEngine.ScriptBase -{ - public class XEngineScriptBase : ScriptBaseClass - { - /// - /// Used for script sleeps when we are using co-operative script termination. - /// - /// null if co-operative script termination is not active - WaitHandle m_coopSleepHandle; - - public XEngineScriptBase(WaitHandle coopSleepHandle) : base() - { - m_coopSleepHandle = coopSleepHandle; - } - - public void opensim_reserved_CheckForCoopTermination() - { - if (m_coopSleepHandle != null && m_coopSleepHandle.WaitOne(0)) - throw new ScriptCoopStopException(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs deleted file mode 100644 index 907c8464c8d..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Interfaces; -using log4net; - -namespace OpenSim.Region.ScriptEngine.XEngine -{ - /// - /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it. - /// - public class EventManager - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private XEngine myScriptEngine; - - public EventManager(XEngine _ScriptEngine) - { - myScriptEngine = _ScriptEngine; - -// m_log.Info("[XEngine] Hooking up to server events"); - myScriptEngine.World.EventManager.OnAttach += attach; - myScriptEngine.World.EventManager.OnObjectGrab += touch_start; - myScriptEngine.World.EventManager.OnObjectGrabbing += touch; - myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; - myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; - myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; - myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; - myScriptEngine.World.EventManager.OnScriptAtRotTargetEvent += at_rot_target; - myScriptEngine.World.EventManager.OnScriptNotAtRotTargetEvent += not_at_rot_target; - myScriptEngine.World.EventManager.OnScriptMovingStartEvent += moving_start; - myScriptEngine.World.EventManager.OnScriptMovingEndEvent += moving_end; - myScriptEngine.World.EventManager.OnScriptControlEvent += control; - myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start; - myScriptEngine.World.EventManager.OnScriptColliding += collision; - myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end; - myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start; - myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision; - myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end; - myScriptEngine.World.EventManager.OnScriptListenEvent += script_listen; - IMoneyModule money = myScriptEngine.World.RequestModuleInterface(); - if (money != null) - { - money.OnObjectPaid+=HandleObjectPaid; - } - } - - /// - /// When an object gets paid by an avatar and generates the paid event, - /// this will pipe it to the script engine - /// - /// Object ID that got paid - /// Agent Id that did the paying - /// Amount paid - private void HandleObjectPaid(UUID objectID, UUID agentID, - int amount) - { - // Since this is an event from a shared module, all scenes will - // get it. But only one has the object in question. The others - // just ignore it. - // - SceneObjectPart part = - myScriptEngine.World.GetSceneObjectPart(objectID); - - if (part == null) - return; - - if ((part.ScriptEvents & scriptEvents.money) == 0) - part = part.ParentGroup.RootPart; - - m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); - -// part = part.ParentGroup.RootPart; - money(part.LocalId, agentID, amount); - } - - /// - /// Handles piping the proper stuff to The script engine for touching - /// Including DetectedParams - /// - /// - /// - /// - /// - /// - public void touch_start(uint localID, uint originalID, Vector3 offsetPos, - IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) - { - // Add to queue for all scripts in ObjectID object - DetectParams[] det = new DetectParams[1]; - det[0] = new DetectParams(); - det[0].Key = remoteClient.AgentId; - det[0].Populate(myScriptEngine.World); - - if (originalID == 0) - { - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); - if (part == null) - return; - - det[0].LinkNum = part.LinkNum; - } - else - { - SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); - det[0].LinkNum = originalPart.LinkNum; - } - - if (surfaceArgs != null) - { - det[0].SurfaceTouchArgs = surfaceArgs; - } - - myScriptEngine.PostObjectEvent(localID, new EventParams( - "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, - det)); - } - - public void touch(uint localID, uint originalID, Vector3 offsetPos, - IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) - { - // Add to queue for all scripts in ObjectID object - DetectParams[] det = new DetectParams[1]; - det[0] = new DetectParams(); - det[0].Key = remoteClient.AgentId; - det[0].Populate(myScriptEngine.World); - det[0].OffsetPos = offsetPos; - - if (originalID == 0) - { - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); - if (part == null) - return; - - det[0].LinkNum = part.LinkNum; - } - else - { - SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); - det[0].LinkNum = originalPart.LinkNum; - } - if (surfaceArgs != null) - { - det[0].SurfaceTouchArgs = surfaceArgs; - } - - myScriptEngine.PostObjectEvent(localID, new EventParams( - "touch", new Object[] { new LSL_Types.LSLInteger(1) }, - det)); - } - - public void touch_end(uint localID, uint originalID, IClientAPI remoteClient, - SurfaceTouchEventArgs surfaceArgs) - { - // Add to queue for all scripts in ObjectID object - DetectParams[] det = new DetectParams[1]; - det[0] = new DetectParams(); - det[0].Key = remoteClient.AgentId; - det[0].Populate(myScriptEngine.World); - - if (originalID == 0) - { - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); - if (part == null) - return; - - det[0].LinkNum = part.LinkNum; - } - else - { - SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); - det[0].LinkNum = originalPart.LinkNum; - } - - if (surfaceArgs != null) - { - det[0].SurfaceTouchArgs = surfaceArgs; - } - - myScriptEngine.PostObjectEvent(localID, new EventParams( - "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, - det)); - } - - public void changed(uint localID, uint change, object parameter) - { - // Add to queue for all scripts in localID, Object pass change. - if(parameter == null) - { - myScriptEngine.PostObjectEvent(localID, new EventParams( - "changed", new object[] { new LSL_Types.LSLInteger(change) }, - new DetectParams[0])); - return; - } - if (parameter is UUID) - { - DetectParams det = new DetectParams(); - det.Key = (UUID)parameter; - myScriptEngine.PostObjectEvent(localID, new EventParams( - "changed", new object[] { new LSL_Types.LSLInteger(change) }, - new DetectParams[] { det })); - return; - } - } - - public void script_listen(UUID scriptID, int channel, string name, UUID id, string message) - { - object[] resobj = new object[] - { - new LSL_Types.LSLInteger(channel), - new LSL_Types.LSLString(name), - new LSL_Types.LSLString(id.ToString()), - new LSL_Types.LSLString(message) - }; - myScriptEngine.PostScriptEvent(scriptID, new EventParams("listen", resobj, new DetectParams[0])); - } - - // state_entry: not processed here - // state_exit: not processed here - - public void money(uint localID, UUID agentID, int amount) - { - myScriptEngine.PostObjectEvent(localID, new EventParams( - "money", new object[] { - new LSL_Types.LSLString(agentID.ToString()), - new LSL_Types.LSLInteger(amount) }, - new DetectParams[0])); - } - - public void collision_start(uint localID, ColliderArgs col) - { - // Add to queue for all scripts in ObjectID object - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Key =detobj.keyUUID; - d.Populate(myScriptEngine.World, detobj); - det.Add(d); - } - - if (det.Count > 0) - myScriptEngine.PostObjectEvent(localID, new EventParams( - "collision_start", - new Object[] { new LSL_Types.LSLInteger(det.Count) }, - det.ToArray())); - } - - public void collision(uint localID, ColliderArgs col) - { - // Add to queue for all scripts in ObjectID object - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Populate(myScriptEngine.World, detobj); - det.Add(d); - } - - if (det.Count > 0) - myScriptEngine.PostObjectEvent(localID, new EventParams( - "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) }, - det.ToArray())); - } - - public void collision_end(uint localID, ColliderArgs col) - { - // Add to queue for all scripts in ObjectID object - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Populate(myScriptEngine.World, detobj); - det.Add(d); - } - - if (det.Count > 0) - myScriptEngine.PostObjectEvent(localID, new EventParams( - "collision_end", - new Object[] { new LSL_Types.LSLInteger(det.Count) }, - det.ToArray())); - } - - public void land_collision_start(uint localID, ColliderArgs col) - { - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Populate(myScriptEngine.World, detobj); - det.Add(d); - myScriptEngine.PostObjectEvent(localID, new EventParams( - "land_collision_start", - new Object[] { new LSL_Types.Vector3(d.Position) }, - det.ToArray())); - } - - } - - public void land_collision(uint localID, ColliderArgs col) - { - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Populate(myScriptEngine.World,detobj); - det.Add(d); - myScriptEngine.PostObjectEvent(localID, new EventParams( - "land_collision", - new Object[] { new LSL_Types.Vector3(d.Position) }, - det.ToArray())); - } - } - - public void land_collision_end(uint localID, ColliderArgs col) - { - List det = new List(); - - foreach (DetectedObject detobj in col.Colliders) - { - DetectParams d = new DetectParams(); - d.Populate(myScriptEngine.World,detobj); - det.Add(d); - myScriptEngine.PostObjectEvent(localID, new EventParams( - "land_collision_end", - new Object[] { new LSL_Types.Vector3(d.Position) }, - det.ToArray())); - } - } - - // timer: not handled here - // listen: not handled here - - public void control(UUID itemID, UUID agentID, uint held, uint change) - { - myScriptEngine.PostScriptEvent(itemID, new EventParams( - "control",new object[] { - new LSL_Types.LSLString(agentID.ToString()), - new LSL_Types.LSLInteger(held), - new LSL_Types.LSLInteger(change)}, - new DetectParams[0])); - } - - public void email(uint localID, UUID itemID, string timeSent, - string address, string subject, string message, int numLeft) - { - myScriptEngine.PostObjectEvent(localID, new EventParams( - "email",new object[] { - new LSL_Types.LSLString(timeSent), - new LSL_Types.LSLString(address), - new LSL_Types.LSLString(subject), - new LSL_Types.LSLString(message), - new LSL_Types.LSLInteger(numLeft)}, - new DetectParams[0])); - } - - public void at_target(UUID itemID, uint handle, Vector3 targetpos, - Vector3 atpos) - { - myScriptEngine.PostScriptEvent(itemID, new EventParams( - "at_target", new object[] { - new LSL_Types.LSLInteger(handle), - new LSL_Types.Vector3(targetpos), - new LSL_Types.Vector3(atpos) }, - new DetectParams[0])); - } - - public void not_at_target(UUID itemID) - { - myScriptEngine.PostScriptEvent(itemID, new EventParams( - "not_at_target",new object[0], - new DetectParams[0])); - } - - public void at_rot_target(UUID itemID, uint handle, Quaternion targetrot, - Quaternion atrot) - { - myScriptEngine.PostScriptEvent(itemID, new EventParams( - "at_rot_target", new object[] { - new LSL_Types.LSLInteger(handle), - new LSL_Types.Quaternion(targetrot), - new LSL_Types.Quaternion(atrot) }, - new DetectParams[0])); - } - - public void not_at_rot_target(UUID itemID) - { - myScriptEngine.PostScriptEvent(itemID, new EventParams( - "not_at_rot_target",new object[0], - new DetectParams[0])); - } - - // run_time_permissions: not handled here - - public void attach(uint localID, UUID itemID, UUID avatar) - { - SceneObjectGroup grp = myScriptEngine.World.GetSceneObjectGroup(localID); - if(grp == null) - return; - - foreach(SceneObjectPart part in grp.Parts) - { - myScriptEngine.PostObjectEvent(part.LocalId, new EventParams( - "attach",new object[] { - new LSL_Types.LSLString(avatar.ToString()) }, - new DetectParams[0])); - } - } - - // dataserver: not handled here - // link_message: not handled here - - public void moving_start(uint localID) - { - myScriptEngine.PostObjectEvent(localID, new EventParams( - "moving_start",new object[0], - new DetectParams[0])); - } - - public void moving_end(uint localID) - { - myScriptEngine.PostObjectEvent(localID, new EventParams( - "moving_end",new object[0], - new DetectParams[0])); - } - - // object_rez: not handled here - // remote_data: not handled here - // http_response: not handled here - } -} diff --git a/OpenSim/Region/ScriptEngine/XEngine/OpenSim.Region.ScriptEngine.XEngine.csproj b/OpenSim/Region/ScriptEngine/XEngine/OpenSim.Region.ScriptEngine.XEngine.csproj deleted file mode 100644 index 28b0c222837..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/OpenSim.Region.ScriptEngine.XEngine.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - net48 - OpenSim.Region.ScriptEngine.XEngine - http://opensimulator.org - OpenSim - OpenSimulator developers - - - - ..\..\..\..\bin\Nini.dll - False - - - ..\..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\..\bin\OpenMetaverseTypes.dll - False - - - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs deleted file mode 100644 index b3fedcb79c0..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Mono.Addins; - -// 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("OpenSim.Region.ScriptEngine.XEngine")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://opensimulator.org")] -[assembly: AssemblyProduct("OpenSim")] -[assembly: AssemblyCopyright("OpenSimulator developers")] -[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("1feed7de-3d45-4d3d-80e2-b57566284df5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] - -[assembly: Addin("OpenSim.Region.ScriptEngine.XEngine", OpenSim.VersionInfo.VersionNumber)] -[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] diff --git a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs deleted file mode 100755 index 564bf37baf9..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Region.ScriptEngine.Interfaces; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; - -namespace OpenSim.Region.ScriptEngine.XEngine -{ - public class ScriptEngineConsoleCommands - { - IScriptEngine m_engine; - - public ScriptEngineConsoleCommands(IScriptEngine engine) - { - m_engine = engine; - } - - public void RegisterCommands() - { - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "show script sensors", "show script sensors", "Show script sensors information", - HandleShowSensors); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "show script timers", "show script timers", "Show script sensors information", - HandleShowTimers); - } - - private bool IsSceneSelected() - { - return MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World; - } - - private void HandleShowSensors(string module, string[] cmdparams) - { - if (!IsSceneSelected()) - return; - - SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(m_engine); - - if (sr == null) - { - MainConsole.Instance.Output("Plugin not yet initialized"); - return; - } - - List sensorInfo = sr.GetSensorInfo(); - - ConsoleDisplayTable cdt = new ConsoleDisplayTable(); - cdt.AddColumn("Part name", 40); - cdt.AddColumn("Script item ID", 36); - cdt.AddColumn("Type", 4); - cdt.AddColumn("Interval", 8); - cdt.AddColumn("Range", 8); - cdt.AddColumn("Arc", 8); - - foreach (SensorRepeat.SensorInfo s in sensorInfo) - { - cdt.AddRow(s.host.Name, s.itemID, s.type, s.interval, s.range, s.arc); - } - - MainConsole.Instance.Output(cdt.ToString()); - MainConsole.Instance.Output("Total: {0}", sensorInfo.Count); - } - - private void HandleShowTimers(string module, string[] cmdparams) - { - if (!IsSceneSelected()) - return; - - ScriptTimer timerPlugin = AsyncCommandManager.GetTimerPlugin(m_engine); - - if (timerPlugin == null) - { - MainConsole.Instance.Output("Plugin not yet initialized"); - return; - } - - List timersInfo = timerPlugin.GetTimersInfo(); - - ConsoleDisplayTable cdt = new ConsoleDisplayTable(); - cdt.AddColumn("Part local ID", 13); - cdt.AddColumn("Script item ID", 36); - cdt.AddColumn("Interval", 10); - cdt.AddColumn("Next", 8); - - foreach (ScriptTimer.TimerInfo t in timersInfo) - { - // Convert from 100 ns ticks back to seconds - cdt.AddRow(t.localID, t.itemID, (double)t.interval / 10000000, t.next); - } - - MainConsole.Instance.Output(cdt.ToString()); - MainConsole.Instance.Output("Total: {0}", timersInfo.Count); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs deleted file mode 100644 index 6ec44d6be4a..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Scripting.WorldComm; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.XEngine.Tests -{ - /// - /// Basic XEngine tests. - /// - [TestFixture] - public class XEngineBasicTests : OpenSimTestCase - { - private TestScene m_scene; - private XEngine m_xEngine; - private AutoResetEvent m_chatEvent = new AutoResetEvent(false); - private OSChatMessage m_osChatMessageReceived; - - [OneTimeSetUp] - public void Init() - { - //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); -// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); - m_xEngine = new XEngine(); - - IniConfigSource configSource = new IniConfigSource(); - - IConfig startupConfig = configSource.AddConfig("Startup"); - startupConfig.Set("DefaultScriptEngine", "XEngine"); - - IConfig xEngineConfig = configSource.AddConfig("XEngine"); - xEngineConfig.Set("Enabled", "true"); - xEngineConfig.Set("StartDelay", "0"); - - // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call - // to AssemblyResolver.OnAssemblyResolve fails. - xEngineConfig.Set("AppDomainLoading", "false"); - - m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); - SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine); - m_scene.StartScripts(); - } - - /// - /// Test compilation and starting of a script. - /// - /// - /// This is a less than ideal regression test since it involves an asynchronous operation (in this case, - /// compilation of the script). - /// - [Test] - public void TestCompileAndStartScript() - { - TestHelpers.InMethod(); - TestHelpers.EnableLogging(); - - UUID userId = TestHelpers.ParseTail(0x1); -// UUID objectId = TestHelpers.ParseTail(0x100); -// UUID itemId = TestHelpers.ParseTail(0x3); - string itemName = "TestStartScript() Item"; - - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStartScriptPart_", 0x100); - m_scene.AddNewSceneObject(so, true); - - InventoryItemBase itemTemplate = new InventoryItemBase(); -// itemTemplate.ID = itemId; - itemTemplate.Name = itemName; - itemTemplate.Folder = so.UUID; - itemTemplate.InvType = (int)InventoryType.LSL; - - m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; - - SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate, Constants.DefaultScriptText); - - m_chatEvent.WaitOne(60000); - - Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()"); - Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running")); - - bool running; - TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); - Assert.That( - SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True); - Assert.That(running, Is.True); - } - - private void OnChatFromWorld(object sender, OSChatMessage oscm) - { -// Console.WriteLine("Got chat [{0}]", oscm.Message); - - m_osChatMessageReceived = oscm; - m_chatEvent.Set(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs deleted file mode 100644 index 14c3772f4e0..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Framework.EntityTransfer; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.XEngine.Tests -{ - /// - /// XEngine tests connected with crossing scripts between regions. - /// - [TestFixture] - public class XEngineCrossingTests : OpenSimTestCase - { - [OneTimeSetUp] - public void FixtureInit() - { - // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. - Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; - } - - [OneTimeTearDown] - public void TearDown() - { - // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple - // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression - // tests really shouldn't). - Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; - } - - /// - /// Test script state preservation when a script crosses between regions on the same simulator. - /// - [Test] - public void TestScriptCrossOnSameSimulator() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID userId = TestHelpers.ParseTail(0x1); - int sceneObjectIdTail = 0x2; - - EntityTransferModule etmA = new EntityTransferModule(); - EntityTransferModule etmB = new EntityTransferModule(); - LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); - XEngine xEngineA = new XEngine(); - XEngine xEngineB = new XEngine(); - xEngineA.DebugLevel = 1; - xEngineB.DebugLevel = 1; - - IConfigSource configSource = new IniConfigSource(); - - IConfig startupConfig = configSource.AddConfig("Startup"); - startupConfig.Set("DefaultScriptEngine", "XEngine"); - startupConfig.Set("TrustBinaries", "true"); - - IConfig xEngineConfig = configSource.AddConfig("XEngine"); - xEngineConfig.Set("Enabled", "true"); - xEngineConfig.Set("StartDelay", "0"); - - // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call - // to AssemblyResolver.OnAssemblyResolve fails. - xEngineConfig.Set("AppDomainLoading", "false"); - - IConfig modulesConfig = configSource.AddConfig("Modules"); - modulesConfig.Set("EntityTransferModule", etmA.Name); - modulesConfig.Set("SimulationServices", lscm.Name); - - SceneHelpers sh = new SceneHelpers(); - TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000, configSource); - TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999, configSource); - - SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, configSource, lscm); - SceneHelpers.SetupSceneModules(sceneA, configSource, etmA, xEngineA); - SceneHelpers.SetupSceneModules(sceneB, configSource, etmB, xEngineB); - sceneA.StartScripts(); - sceneB.StartScripts(); - - SceneObjectGroup soSceneA = SceneHelpers.AddSceneObject(sceneA, 1, userId, "so1-", sceneObjectIdTail); - soSceneA.AbsolutePosition = new Vector3(128, 10, 20); - - string soSceneAName = soSceneA.Name; - string scriptItemSceneAName = "script1"; - - // CREATE SCRIPT TODO - InventoryItemBase scriptItemSceneA = new InventoryItemBase(); - // itemTemplate.ID = itemId; - scriptItemSceneA.Name = scriptItemSceneAName; - scriptItemSceneA.Folder = soSceneA.UUID; - scriptItemSceneA.InvType = (int)InventoryType.LSL; - - AutoResetEvent chatEvent = new AutoResetEvent(false); - OSChatMessage messageReceived = null; - sceneA.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEvent.Set(); }; - - sceneA.RezNewScript(userId, scriptItemSceneA, -@"integer c = 0; - -default -{ - state_entry() - { - llSay(0, ""Script running""); - } - - changed(integer change) - { - llSay(0, ""Changed""); - } - - touch_start(integer n) - { - c = c + 1; - llSay(0, (string)c); - } -}"); - - chatEvent.WaitOne(60000); - - Assert.That(messageReceived, Is.Not.Null, "No chat message received."); - Assert.That(messageReceived.Message, Is.EqualTo("Script running")); - - { - // XXX: Should not be doing this so directly. Should call some variant of EventManager.touch() instead. - DetectParams[] det = new DetectParams[1]; - det[0] = new DetectParams(); - det[0].Key = userId; - det[0].Populate(sceneA); - - EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det); - - messageReceived = null; - chatEvent.Reset(); - xEngineA.PostObjectEvent(soSceneA.LocalId, ep); - chatEvent.WaitOne(60000); - - Assert.That(messageReceived.Message, Is.EqualTo("1")); - } - - AutoResetEvent chatEventB = new AutoResetEvent(false); - sceneB.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEventB.Set(); }; - - messageReceived = null; - chatEventB.Reset(); - // Cross with a negative value - soSceneA.AbsolutePosition = new Vector3(128, -10, 20); - - chatEventB.WaitOne(60000); - Assert.That(messageReceived, Is.Not.Null, "No Changed message received."); - Assert.That(messageReceived.Message, Is.Not.Null, "Changed message without content"); - Assert.That(messageReceived.Message, Is.EqualTo("Changed")); - - // TEST sending event to moved prim and output - { - SceneObjectGroup soSceneB = sceneB.GetSceneObjectGroup(soSceneAName); - TaskInventoryItem scriptItemSceneB = soSceneB.RootPart.Inventory.GetInventoryItem(scriptItemSceneAName); - - // XXX: Should not be doing this so directly. Should call some variant of EventManager.touch() instead. - DetectParams[] det = new DetectParams[1]; - det[0] = new DetectParams(); - det[0].Key = userId; - det[0].Populate(sceneB); - - EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det); - - Thread.Sleep(250); // wait for other change messages to pass - messageReceived = null; - chatEventB.Reset(); - xEngineB.PostObjectEvent(soSceneB.LocalId, ep); - chatEventB.WaitOne(60000); - - Assert.That(messageReceived.Message, Is.EqualTo("2")); - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs deleted file mode 100644 index 07470d6ec97..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Linq; -using System.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.Attachments; -using OpenSim.Region.CoreModules.Framework.InventoryAccess; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.XEngine; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Region.ScriptEngine.Tests -{ - /* - [TestFixture] - public class XEnginePersistenceTests : OpenSimTestCase - { - private AutoResetEvent m_chatEvent = new AutoResetEvent(false); - - private void OnChatFromWorld(object sender, OSChatMessage oscm) - { - // Console.WriteLine("Got chat [{0}]", oscm.Message); - - // m_osChatMessageReceived = oscm; - m_chatEvent.Set(); - } - - private void AddCommonConfig(IConfigSource config, List modules) - { - config.AddConfig("Modules"); - config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - AttachmentsModule attMod = new AttachmentsModule(); - attMod.DebugLevel = 1; - modules.Add(attMod); - modules.Add(new BasicInventoryAccessModule()); - } - - private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List modules) - { - IConfig startupConfig = config.AddConfig("Startup"); - startupConfig.Set("DefaultScriptEngine", "XEngine"); - - IConfig xEngineConfig = config.AddConfig("XEngine"); - xEngineConfig.Set("Enabled", "true"); - xEngineConfig.Set("StartDelay", "0"); - - // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call - // to AssemblyResolver.OnAssemblyResolve fails. - xEngineConfig.Set("AppDomainLoading", "false"); - - modules.Add(xEngine); - } - - private Scene CreateScriptingEnabledTestScene(XEngine.XEngine xEngine) - { - IConfigSource config = new IniConfigSource(); - List modules = new List(); - - AddCommonConfig(config, modules); - AddScriptingConfig(config, xEngine, modules); - - Scene scene - = new SceneHelpers().SetupScene( - "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); - SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); - - scene.StartScripts(); - - return scene; - } - - [Test] - public void TestScriptedAttachmentPersistence() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - XEngine.XEngine xEngine = new XEngine.XEngine(); - Scene scene = CreateScriptingEnabledTestScene(xEngine); - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); - - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); - TaskInventoryHelpers.AddScript( - scene.AssetService, - so.RootPart, - "scriptItem", - "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); - - InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); - - // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. - // In the future, we need to be able to do this programatically more predicably. - scene.EventManager.OnChatFromWorld += OnChatFromWorld; - - SceneObjectGroup rezzedSo - = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); - TaskInventoryItem rezzedScriptItem = rezzedSo.RootPart.Inventory.GetInventoryItem("scriptItem"); - - // Wait for chat to signal rezzed script has been started. - m_chatEvent.WaitOne(60000); - - // Force save - xEngine.DoBackup(new Object[] { 0 }); - -// Console.WriteLine("ItemID {0}", rezzedScriptItem.ItemID); -// -// foreach ( -// string s in Directory.EnumerateFileSystemEntries( -// string.Format("ScriptEngines/{0}", scene.RegionInfo.RegionID))) -// Console.WriteLine(s); - - Assert.IsFalse( - File.Exists( - string.Format("ScriptEngines/{0}/{1}.state", scene.RegionInfo.RegionID, rezzedScriptItem.ItemID))); - - scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo); - } - } - */ -} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs deleted file mode 100755 index 58b1f872524..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ /dev/null @@ -1,2535 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Security; -using System.Security.Policy; -using System.Text; -using System.Threading; -using System.Xml; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using log4net; -using Nini.Config; -using Amib.Threading; -using Mono.Addins; -using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.ScriptEngine.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using OpenSim.Region.ScriptEngine.Shared.Instance; -using OpenSim.Region.ScriptEngine.Shared.Api; -using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; -using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Region.ScriptEngine.XEngine.ScriptBase; -using ScriptTimer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.ScriptTimer; - -using ScriptCompileQueue = OpenSim.Framework.LocklessQueue; - -namespace OpenSim.Region.ScriptEngine.XEngine -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XEngine")] - public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Control the printing of certain debug messages. - /// - /// - /// If DebugLevel >= 1, then we log every time that a script is started. - /// - public int DebugLevel { get; set; } - - /// - /// A parameter to allow us to notify the log if at least one script has a compilation that is not compatible - /// with ScriptStopStrategy. - /// - public bool HaveNotifiedLogOfScriptStopMismatch { get; private set; } - - private SmartThreadPool m_ThreadPool; - private int m_MaxScriptQueue; - private Scene m_Scene; - private IConfig m_ScriptConfig = null; - private IConfigSource m_ConfigSource = null; - private ICompiler m_Compiler; - private int m_MinThreads; - private int m_MaxThreads; - - /// - /// Amount of time to delay before starting. - /// - private int m_StartDelay; - - /// - /// Are we stopping scripts co-operatively by inserting checks in them at C# compile time (true) or aborting - /// their threads (false)? - /// - private bool m_coopTermination; - - private int m_IdleTimeout; - private int m_StackSize; - private int m_SleepTime; - private int m_SaveTime; - private ThreadPriority m_Prio; - private bool m_Enabled = false; - private bool m_InitialStartup = true; - private int m_ScriptFailCount; // Number of script fails since compile queue was last empty - private string m_ScriptErrorMessage; - private bool m_AppDomainLoading; - private bool m_AttachmentsDomainLoading; - private Dictionary m_ScriptErrors = - new Dictionary(); - - // disable warning: need to keep a reference to XEngine.EventManager - // alive to avoid it being garbage collected -#pragma warning disable 414 - private EventManager m_EventManager; -#pragma warning restore 414 - private IXmlRpcRouter m_XmlRpcRouter; - private int m_EventLimit; - private bool m_KillTimedOutScripts; - - /// - /// Number of milliseconds we will wait for a script event to complete on script stop before we forcibly abort - /// its thread. - /// - /// - /// It appears that if a script thread is aborted whilst it is holding ReaderWriterLockSlim (possibly the write - /// lock) then the lock is not properly released. This causes mono 2.6, 2.10 and possibly - /// later to crash, sometimes with symptoms such as a leap to 100% script usage and a vm thead dump showing - /// all threads waiting on release of ReaderWriterLockSlim write thread which none of the threads listed - /// actually hold. - /// - /// Pausing for event completion reduces the risk of this happening. However, it may be that aborting threads - /// is not a mono issue per se but rather a risky activity in itself in an AppDomain that is not immediately - /// shutting down. - /// - private int m_WaitForEventCompletionOnScriptStop = 1000; - - private string m_ScriptEnginesPath = null; - - private ExpiringCache m_runFlags = new ExpiringCache(); - - /// - /// Is the entire simulator in the process of shutting down? - /// - private bool m_SimulatorShuttingDown; - - private static List m_ScriptEngines = - new List(); - - // Maps the local id to the script inventory items in it - - private Dictionary > m_PrimObjects = - new Dictionary >(); - - // Maps the UUID above to the script instance - - private Dictionary m_Scripts = - new Dictionary(); - - // Maps the asset ID to the assembly - - private Dictionary m_Assemblies = - new Dictionary(); - - private Dictionary m_AddingAssemblies = - new Dictionary(); - - // This will list AppDomains by script asset - - private Dictionary m_AppDomains = - new Dictionary(); - - // List the scripts running in each appdomain - - private Dictionary > m_DomainScripts = - new Dictionary >(); - - private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); - IWorkItemResult m_CurrentCompile = null; - private Dictionary m_CompileDict = new Dictionary(); - - private ScriptEngineConsoleCommands m_consoleCommands; - - public string ScriptEngineName - { - get { return "XEngine"; } - } - - public string ScriptClassName { get; private set; } - - public string ScriptBaseClassName { get; private set; } - - public ParameterInfo[] ScriptBaseClassParameters { get; private set; } - - public string[] ScriptReferencedAssemblies { get; private set; } - - public Scene World - { - get { return m_Scene; } - } - - public static List ScriptEngines - { - get { return m_ScriptEngines; } - } - - public IScriptModule ScriptModule - { - get { return this; } - } - - // private struct RezScriptParms - // { - // uint LocalID; - // UUID ItemID; - // string Script; - // } - - public IConfig Config - { - get { return m_ScriptConfig; } - } - - public string ScriptEnginePath - { - get { return m_ScriptEnginesPath; } - } - - public IConfigSource ConfigSource - { - get { return m_ConfigSource; } - } - - private class ScriptCompileInfo - { - public List eventList = new List(); - } - - /// - /// Event fired after the script engine has finished removing a script. - /// - public event ScriptRemoved OnScriptRemoved; - - /// - /// Event fired after the script engine has finished removing a script from an object. - /// - public event ObjectRemoved OnObjectRemoved; - - public void Initialise(IConfigSource configSource) - { - m_ScriptConfig = configSource.Configs["XEngine"]; - if (m_ScriptConfig == null) - return; - - if (!m_ScriptConfig.GetBoolean("Enabled", true)) - return; - - m_Enabled = true; - - m_ConfigSource = configSource; - - string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "co-op"); - - m_log.InfoFormat("[XEngine]: Script stop strategy is {0}", rawScriptStopStrategy); - - if (rawScriptStopStrategy == "co-op") - { - m_coopTermination = true; - ScriptClassName = "XEngineScript"; - ScriptBaseClassName = typeof(XEngineScriptBase).FullName; - ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); - ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) }; - } - else - { - ScriptClassName = "Script"; - ScriptBaseClassName = typeof(ScriptBaseClass).FullName; - } - -// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]); - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - m_ScriptFailCount = 0; - m_ScriptErrorMessage = String.Empty; - - AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; - - m_Scene = scene; - m_log.InfoFormat("[XEngine]: Initializing scripts in region {0}", m_Scene.RegionInfo.RegionName); - - m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2); - m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); - m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); - string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); - m_StartDelay = m_ScriptConfig.GetInt("StartDelay", 15000); - m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); - m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); - m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; - m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", false); - m_AttachmentsDomainLoading = m_ScriptConfig.GetBoolean("AttachmentsDomainLoading", false); - m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); - m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); - m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; - m_WaitForEventCompletionOnScriptStop - = m_ScriptConfig.GetInt("WaitForEventCompletionOnScriptStop", m_WaitForEventCompletionOnScriptStop); - - m_ScriptEnginesPath = m_ScriptConfig.GetString("ScriptEnginesPath", "ScriptEngines"); - - m_Prio = ThreadPriority.BelowNormal; - switch (priority) - { - case "Lowest": - m_Prio = ThreadPriority.Lowest; - break; - case "BelowNormal": - m_Prio = ThreadPriority.BelowNormal; - break; - case "Normal": - m_Prio = ThreadPriority.Normal; - break; - case "AboveNormal": - m_Prio = ThreadPriority.AboveNormal; - break; - case "Highest": - m_Prio = ThreadPriority.Highest; - break; - default: - m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); - break; - } - - lock (m_ScriptEngines) - { - m_ScriptEngines.Add(this); - } - - // Needs to be here so we can queue the scripts that need starting - // - m_Scene.EventManager.OnRezScript += OnRezScript; - - // Complete basic setup of the thread pool - // - SetupEngine(m_MinThreads, m_MaxThreads, m_IdleTimeout, m_Prio, - m_MaxScriptQueue, m_StackSize); - - m_Scene.StackModuleInterface(this); - - m_XmlRpcRouter = m_Scene.RequestModuleInterface(); - if (m_XmlRpcRouter != null) - { - OnScriptRemoved += m_XmlRpcRouter.ScriptRemoved; - OnObjectRemoved += m_XmlRpcRouter.ObjectRemoved; - } - - m_consoleCommands = new ScriptEngineConsoleCommands(this); - m_consoleCommands.RegisterCommands(); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "xengine status", "xengine status", "Show status information", - "Show status information on the script engine.", - HandleShowStatus); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts show", "scripts show [+]", "Show script information", - "Show information on all scripts known to the script engine.\n" - + "If one or more s are given then only information on that script will be shown.", - HandleShowScripts); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "show scripts", "show scripts [+]", "Show script information", - "Synonym for scripts show command", HandleShowScripts); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts suspend", "scripts suspend [+]", "Suspends all running scripts", - "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" - + " script that is currently processing an event.\n" - + "Suspended scripts will continue to accumulate events but won't process them.\n" - + "If one or more s are given then only that script will be suspended. Otherwise, all suitable scripts are suspended.", - (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript)); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts resume", "scripts resume [+]", "Resumes all suspended scripts", - "Resumes all currently suspended scripts.\n" - + "Resumed scripts will process all events accumulated whilst suspended.\n" - + "If one or more s are given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", - (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts stop", "scripts stop [+]", "Stops all running scripts", - "Stops all running scripts.\n" - + "If one or more s are given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", - (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); - - MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts start", "scripts start [+]", "Starts all stopped scripts", - "Starts all stopped scripts.\n" - + "If one or more s are given then only that script will be started. Otherwise, all suitable scripts are started.", - (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); - - MainConsole.Instance.Commands.AddCommand( - "Debug", false, "debug scripts log", "debug scripts log ", "Extra debug logging for a particular script.", - "Activates or deactivates extra debug logging for the given script.\n" - + "Level == 0, deactivate extra debug logging.\n" - + "Level >= 1, log state changes.\n" - + "Level >= 2, log event invocations.\n", - HandleDebugScriptLogCommand); - - MainConsole.Instance.Commands.AddCommand( - "Debug", false, "debug xengine log", "debug xengine log []", - "Turn on detailed xengine debugging.", - "If level <= 0, then no extra logging is done.\n" - + "If level >= 1, then we log every time that a script is started.", - HandleDebugLevelCommand); - } - - private void HandleDebugScriptLogCommand(string module, string[] args) - { - if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) - return; - - if (args.Length != 5) - { - MainConsole.Instance.Output("Usage: debug script log "); - return; - } - - UUID itemId; - - if (!ConsoleUtil.TryParseConsoleUuid(MainConsole.Instance, args[3], out itemId)) - return; - - int newLevel; - - if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out newLevel)) - return; - - IScriptInstance si; - - lock (m_Scripts) - { - // XXX: We can't give the user feedback on a bad item id because this may apply to a different script - // engine - if (!m_Scripts.TryGetValue(itemId, out si)) - return; - } - - si.DebugLevel = newLevel; - MainConsole.Instance.Output("Set debug level of {0} {1} to {2}", si.ScriptName, si.ItemID, newLevel); - } - - /// - /// Change debug level - /// - /// - /// - private void HandleDebugLevelCommand(string module, string[] args) - { - if (args.Length >= 4) - { - int newDebug; - if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, args[3], out newDebug)) - { - DebugLevel = newDebug; - MainConsole.Instance.Output("Debug level set to {0} in XEngine for region {1}", newDebug, m_Scene.Name); - } - } - else if (args.Length == 3) - { - MainConsole.Instance.Output("Current debug level is {0}", DebugLevel); - } - else - { - MainConsole.Instance.Output("Usage: debug xengine log "); - } - } - - /// - /// Parse the raw item id into a script instance from the command params if it's present. - /// - /// - /// - /// Basis on which to sort output. Can be null if no sort needs to take place - private void HandleScriptsAction(string[] cmdparams, Action action) - { - HandleScriptsAction(cmdparams, action, null); - } - - /// - /// Parse the raw item id into a script instance from the command params if it's present. - /// - /// - /// - /// Basis on which to sort output. Can be null if no sort needs to take place - private void HandleScriptsAction( - string[] cmdparams, Action action, System.Func keySelector) - { - if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) - return; - - lock (m_Scripts) - { - string rawItemId; - UUID itemId = UUID.Zero; - - if (cmdparams.Length == 2) - { - IEnumerable scripts = m_Scripts.Values; - - if (keySelector != null) - scripts = scripts.OrderBy(keySelector); - - foreach (IScriptInstance instance in scripts) - action(instance); - - return; - } - - for (int i = 2; i < cmdparams.Length; i++) - { - rawItemId = cmdparams[i]; - - if (!UUID.TryParse(rawItemId, out itemId)) - { - MainConsole.Instance.Output("ERROR: {0} is not a valid UUID", rawItemId); - continue; - } - - if (!itemId.IsZero()) - { - IScriptInstance instance = GetInstance(itemId); - if (instance == null) - { - // Commented out for now since this will cause false reports on simulators with more than - // one scene where the current command line set region is 'root' (which causes commands to - // go to both regions... (sigh) - // MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); - continue; - } - else - { - action(instance); - } - } - } - } - } - - private void HandleShowStatus(string module, string[] cmdparams) - { - if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) - return; - - MainConsole.Instance.Output(GetStatusReport()); - } - - public string GetStatusReport() - { - StringBuilder sb = new StringBuilder(); - sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); - - long scriptsLoaded, eventsQueued = 0, eventsProcessed = 0; - - lock (m_Scripts) - { - scriptsLoaded = m_Scripts.Count; - - foreach (IScriptInstance si in m_Scripts.Values) - { - eventsQueued += si.EventsQueued; - eventsProcessed += si.EventsProcessed; - } - } - - sb.AppendFormat("Scripts loaded : {0}\n", scriptsLoaded); - sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); - sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads); - sb.AppendFormat("Min threads : {0}\n", m_ThreadPool.MinThreads); - sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); - sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); - sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); -// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); - sb.AppendFormat("Events queued : {0}\n", eventsQueued); - sb.AppendFormat("Events processed : {0}\n", eventsProcessed); - - SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); - sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0); - - Dataserver ds = AsyncCommandManager.GetDataserverPlugin(this); - sb.AppendFormat("Dataserver requests : {0}\n", ds != null ? ds.DataserverRequestsCount : 0); - - ScriptTimer t = AsyncCommandManager.GetTimerPlugin(this); - sb.AppendFormat("Timers : {0}\n", t != null ? t.TimersCount : 0); - - Listener l = AsyncCommandManager.GetListenerPlugin(this); - sb.AppendFormat("Listeners : {0}\n", l != null ? l.ListenerCount : 0); - - return sb.ToString(); - } - - public void HandleShowScripts(string module, string[] cmdparams) - { - if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) - return; - - if (cmdparams.Length == 2) - { - lock (m_Scripts) - { - MainConsole.Instance.Output( - "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); - } - } - - HandleScriptsAction(cmdparams, HandleShowScript, si => si.EventsProcessed); - } - - private void HandleShowScript(IScriptInstance instance) - { - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - string status; - - if (instance.ShuttingDown) - { - status = "shutting down"; - } - else if (instance.Suspended) - { - status = "suspended"; - } - else if (!instance.Running) - { - status = "stopped"; - } - else - { - status = "running"; - } - - StringBuilder sb = new StringBuilder(); - - sb.AppendFormat("Script name : {0}\n", instance.ScriptName); - sb.AppendFormat("Status : {0}\n", status); - sb.AppendFormat("Queued events : {0}\n", instance.EventsQueued); - sb.AppendFormat("Processed events : {0}\n", instance.EventsProcessed); - sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); - sb.AppendFormat("Asset UUID : {0}\n", instance.AssetID); - sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); - sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); - sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition); - - MainConsole.Instance.Output(sb.ToString()); - } - - private void HandleSuspendScript(IScriptInstance instance) - { - if (!instance.Suspended) - { - instance.Suspend(); - - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - MainConsole.Instance.Output( - "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); - } - } - - private void HandleResumeScript(IScriptInstance instance) - { - if (instance.Suspended) - { - instance.Resume(); - - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - MainConsole.Instance.Output( - "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); - } - } - - private void HandleStartScript(IScriptInstance instance) - { - if (!instance.Running) - { - instance.Start(); - - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - MainConsole.Instance.Output( - "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); - } - } - - private void HandleStopScript(IScriptInstance instance) - { - if (instance.Running) - { - instance.StayStopped = true; // the script was stopped explicitly - - instance.Stop(0); - - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - MainConsole.Instance.Output( - "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); - } - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - - lock (m_Scripts) - { - m_log.InfoFormat( - "[XEngine]: Shutting down {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); - - foreach (IScriptInstance instance in m_Scripts.Values) - { - // Force a final state save - // - try - { - if (instance.StatePersistedHere) - instance.SaveState(); - } - catch (Exception e) - { - m_log.Error( - string.Format( - "[XEngine]: Failed final state save for script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) - , e); - } - - // Clear the event queue and abort the instance thread - // - instance.Stop(0, true); - - // Release events, timer, etc - // - instance.DestroyScriptInstance(); - - // Unload scripts and app domains. - // Must be done explicitly because they have infinite - // lifetime. - // However, don't bother to do this if the simulator is shutting - // down since it takes a long time with many scripts. - if (!m_SimulatorShuttingDown) - { - m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); - if (m_DomainScripts[instance.AppDomain].Count == 0) - { - m_DomainScripts.Remove(instance.AppDomain); - UnloadAppDomain(instance.AppDomain); - } - } - } - - m_Scripts.Clear(); - m_PrimObjects.Clear(); - m_Assemblies.Clear(); - m_DomainScripts.Clear(); - } - lock (m_ScriptEngines) - { - m_ScriptEngines.Remove(this); - } - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - m_EventManager = new EventManager(this); - - m_Compiler = new Compiler(this); - - m_Scene.EventManager.OnRemoveScript += OnRemoveScript; - m_Scene.EventManager.OnScriptReset += OnScriptReset; - m_Scene.EventManager.OnStartScript += OnStartScript; - m_Scene.EventManager.OnStopScript += OnStopScript; - m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning; - m_Scene.EventManager.OnShutdown += OnShutdown; - - // If region ready has been triggered, then the region had no scripts to compile and completed its other - // work. - m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; }; - - if (m_SleepTime > 0) - { - m_ThreadPool.QueueWorkItem(DoMaintenance, new object[]{ m_SleepTime }); - } - - if (m_SaveTime > 0) - { - m_ThreadPool.QueueWorkItem(DoBackup, new object[] { m_SaveTime }); - } - } - - public void StartProcessing() - { - m_ThreadPool.Start(); - } - - public void Close() - { - if (!m_Enabled) - return; - - lock (m_ScriptEngines) - { - if (m_ScriptEngines.Contains(this)) - m_ScriptEngines.Remove(this); - } - - lock(m_Scripts) - m_ThreadPool.Shutdown(); - } - - public object DoBackup(object o) - { - Object[] p = (Object[])o; - int saveTime = (int)p[0]; - - if (saveTime > 0) - System.Threading.Thread.Sleep(saveTime); - -// m_log.Debug("[XEngine] Backing up script states"); - - List instances = new List(); - - lock (m_Scripts) - { - foreach (IScriptInstance instance in m_Scripts.Values) - { - if (instance.StatePersistedHere) - { -// m_log.DebugFormat( -// "[XEngine]: Adding script {0}.{1}, item UUID {2}, prim UUID {3} in {4} for state persistence", -// instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name); - - instances.Add(instance); - } - } - } - - foreach (IScriptInstance i in instances) - { - try - { - i.SaveState(); - } - catch (Exception e) - { - m_log.Error( - string.Format( - "[XEngine]: Failed to save state of script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", - i.PrimName, i.ScriptName, i.ItemID, i.ObjectID, World.Name) - , e); - } - } - - if (saveTime > 0) - m_ThreadPool.QueueWorkItem(DoBackup, new object[] { saveTime }); - - return 0; - } - - public void SaveAllState() - { - DoBackup(new object[] { 0 }); - } - - public object DoMaintenance(object p) - { - object[] parms = (object[])p; - int sleepTime = (int)parms[0]; - - foreach (IScriptInstance inst in m_Scripts.Values) - { - if (inst.EventTime() > m_EventLimit) - { - inst.Stop(100); - if (!m_KillTimedOutScripts) - inst.Start(); - } - } - - System.Threading.Thread.Sleep(sleepTime); - - m_ThreadPool.QueueWorkItem(DoMaintenance, new object[]{ sleepTime }); - - return 0; - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "XEngine"; } - } - - public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) - { -// m_log.DebugFormat( -// "[XEngine]: OnRezScript event triggered for script {0}, startParam {1}, postOnRez {2}, engine {3}, stateSource {4}, script\n{5}", -// itemID, startParam, postOnRez, engine, stateSource, script); - - if (script.StartsWith("//MRM:")) - return; - - List engines = new List(m_Scene.RequestModuleInterfaces()); - - List names = new List(); - foreach (IScriptModule m in engines) - names.Add(m.ScriptEngineName); - - int lineEnd = script.IndexOf('\n'); - - if (lineEnd > 1) - { - string firstline = script.Substring(0, lineEnd).Trim(); - - int colon = firstline.IndexOf(':'); - if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) - { - string engineName = firstline.Substring(2, colon - 2); - - if (names.Contains(engineName)) - { - engine = engineName; - script = "//" + script.Substring(colon + 1); - } - else - { - if (engine == ScriptEngineName) - { - // If we are falling back on XEngine as the default engine, then only complain to the user - // if a script language has been explicitly set and it's one that we recognize or there are - // no non-whitespace characters after the colon. - // - // If the script is - // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message. - // - // If the colon ends the line then we'll risk the false positive as this is more likely - // to signal a real scriptengine line where the user wants to use the default compile language. - // - // This avoids the overwhelming number of false positives where we're in this code because - // there's a colon in a comment in the first line of a script for entirely - // unrelated reasons (e.g. vim settings). - // - // TODO: A better fix would be to deprecate simple : detection and look for some less likely - // string to begin the comment (like #! in unix shell scripts). - bool warnRunningInXEngine = false; - string restOfFirstLine = firstline.Substring(colon + 1); - - // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs - if (restOfFirstLine.StartsWith("c#") - || restOfFirstLine.StartsWith("vb") - || restOfFirstLine.StartsWith("lsl") - || restOfFirstLine.Length == 0) - warnRunningInXEngine = true; - - if (warnRunningInXEngine) - { - SceneObjectPart part = - m_Scene.GetSceneObjectPart( - localID); - - TaskInventoryItem item = - part.Inventory.GetInventoryItem(itemID); - - ScenePresence presence = - m_Scene.GetScenePresence( - item.OwnerID); - - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage( - "Selected engine unavailable. "+ - "Running script on "+ - ScriptEngineName, - false); - } - } - } - } - } - } - - if (engine != ScriptEngineName) - return; - - Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; - - if (stateSource == (int)StateSource.ScriptedRez) - { - lock (m_CompileDict) - { -// m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID); - m_CompileDict[itemID] = new ScriptCompileInfo(); - } - - DoOnRezScript(parms); - } - else - { - lock (m_CompileDict) - m_CompileDict[itemID] = new ScriptCompileInfo(); -// m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID); - - // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check - // in DoOnRezScript() before m_CompileDict has been updated. - m_CompileQueue.Enqueue(parms); - -// m_log.DebugFormat("[XEngine]: Added script {0} to compile queue", itemID); - - // NOTE: Although we use a lockless queue, the lock here - // is required. It ensures that there are never two - // compile threads running, which, due to a race - // conndition, might otherwise happen - // - lock (m_CompileQueue) - { - if (m_CurrentCompile == null) - m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); - } - } - } - - public Object DoOnRezScriptQueue(Object dummy) - { - try - { - if (m_InitialStartup) - { - // This delay exists to stop mono problems where script compilation and startup would stop the sim - // working properly for the session. - System.Threading.Thread.Sleep(m_StartDelay); - - m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name); - } - - object[] o; - - int scriptsStarted = 0; - - while (m_CompileQueue.Dequeue(out o)) - { - try - { - if (DoOnRezScript(o)) - { - scriptsStarted++; - - if (m_InitialStartup) - if (scriptsStarted % 50 == 0) - m_log.InfoFormat( - "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name); - } - } - catch (System.Threading.ThreadAbortException) { } - catch (Exception e) - { - m_log.Error( - string.Format( - "[XEngine]: Failure in DoOnRezScriptQueue() for item {0} in {1}. Continuing. Exception ", - o[1], m_Scene.Name), - e); - } - } - - if (m_InitialStartup) - m_log.InfoFormat( - "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name); - - } - catch (Exception e) - { - m_log.Error( - string.Format("[XEngine]: Failure in DoOnRezScriptQueue() in {0}. Exception ", m_Scene.Name), e); - } - finally - { - // FIXME: On failure we must trigger this even if the compile queue is not actually empty so that the - // RegionReadyModule is not forever waiting. This event really needs a different name. - m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, - m_ScriptErrorMessage); - - m_ScriptFailCount = 0; - m_InitialStartup = false; - - // NOTE: Despite having a lockless queue, this lock is required - // to make sure there is never no compile thread while there - // are still scripts to compile. This could otherwise happen - // due to a race condition - // - lock (m_CompileQueue) - { - m_CurrentCompile = null; - - // This is to avoid a situation where the m_CompileQueue while loop above could complete but - // OnRezScript() place a new script on the queue and check m_CurrentCompile = null before we hit - // this section. - if (m_CompileQueue.Count > 0) - m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); - } - } - - return null; - } - - private bool DoOnRezScript(object[] parms) - { - Object[] p = parms; - uint localID = (uint)p[0]; - UUID itemID = (UUID)p[1]; - string script =(string)p[2]; - int startParam = (int)p[3]; - bool postOnRez = (bool)p[4]; - StateSource stateSource = (StateSource)p[5]; - - //m_log.DebugFormat("[XEngine]: DoOnRezScript called for script {0}", itemID); - - lock (m_CompileDict) - { - if (!m_CompileDict.ContainsKey(itemID)) - return false; - } - - // Get the asset ID of the script, so we can check if we - // already have it. - - // We must look for the part outside the m_Scripts lock because GetSceneObjectPart later triggers the - // m_parts lock on SOG. At the same time, a scene object that is being deleted will take the m_parts lock - // and then later on try to take the m_scripts lock in this class when it calls OnRemoveScript() - SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); - if (part == null) - { - m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID); - m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n"; - m_ScriptFailCount++; - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - - TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); - if (item == null) - { - m_ScriptErrorMessage += "Can't find script inventory item.\n"; - m_ScriptFailCount++; - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - - if (DebugLevel > 0) - m_log.DebugFormat( - "[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", - part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, - part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); - - UUID assetID = item.AssetID; - - ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); - - string assemblyPath = ""; - - Culture.SetCurrentCulture(); - - Dictionary, KeyValuePair> linemap; - - lock (m_ScriptErrors) - { - try - { - lock (m_AddingAssemblies) - { - m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assemblyPath, out linemap); - -// m_log.DebugFormat( -// "[XENGINE]: Found assembly path {0} onrez {1} in {2}", -// assemblyPath, item.ItemID, World.Name); - - if (!m_AddingAssemblies.ContainsKey(assemblyPath)) { - m_AddingAssemblies[assemblyPath] = 1; - } else { - m_AddingAssemblies[assemblyPath]++; - } - } - - string[] warnings = m_Compiler.GetWarnings(); - - if (warnings != null && warnings.Length != 0) - { - foreach (string warning in warnings) - { - if (!m_ScriptErrors.ContainsKey(itemID)) - m_ScriptErrors[itemID] = new ArrayList(); - - m_ScriptErrors[itemID].Add(warning); - //try - //{ - // DISPLAY WARNING INWORLD - // string text = "Warning:\n" + warning; - // if (text.Length > 1000) - // text = text.Substring(0, 1000); - // if (!ShowScriptSaveResponse(item.OwnerID,assetID, text, true)) - // { - // if (presence != null && (!postOnRez)) - // presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); - // - // World.SimChat(Utils.StringToBytes(text), - // ChatTypeEnum.DebugChannel, 2147483647, - // part.AbsolutePosition, - // part.Name, part.UUID, false); - // } - //} - //catch (Exception e2) // LEGIT: User Scripting - //{ - // m_log.Error("[XEngine]: " + "Error displaying warning in-world: " + e2.ToString()); - // m_log.Error("[XEngine]: " + "Warning:\r\n" + warning); - //} - } - } - } - catch (Exception e) - { - //m_log.ErrorFormat( - // "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}", - // itemID, e.Message, e.StackTrace); - - //try - //{ - if (!m_ScriptErrors.ContainsKey(itemID)) - m_ScriptErrors[itemID] = new ArrayList(); - // DISPLAY ERROR INWORLD - //m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); - - m_ScriptFailCount++; - m_ScriptErrors[itemID].Add(e.Message.ToString()); - //string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); - //if (text.Length > 1000) - // text = text.Substring(0, 1000); - //if (!ShowScriptSaveResponse(item.OwnerID,assetID, text, false)) - //{ - // if (presence != null && (!postOnRez)) - // presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); - // World.SimChat(Utils.StringToBytes(text), - // ChatTypeEnum.DebugChannel, 2147483647, - // part.AbsolutePosition, - // part.Name, part.UUID, false); - // } - //} - //catch (Exception e2) // LEGIT: User Scripting - //{ - // m_log.Error("[XEngine]: "+ "Error displaying error in-world: " + e2.ToString()); - // m_log.Error("[XEngine]: " + "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); - //} - - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - } - - ScriptInstance instance = null; - lock (m_Scripts) - { - // Create the object record - if ((!m_Scripts.ContainsKey(itemID)) || (m_Scripts[itemID].AssetID != assetID)) - { - bool attachDomains = m_AttachmentsDomainLoading && part.ParentGroup.IsAttachmentCheckFull(); - UUID appDomain = part.ParentGroup.RootPart.UUID; - - if (!m_AppDomains.ContainsKey(appDomain)) - { - try - { - AppDomain sandbox; - if (m_AppDomainLoading || attachDomains) - { - AppDomainSetup appSetup = new AppDomainSetup(); - appSetup.PrivateBinPath = Path.Combine( - m_ScriptEnginesPath, - m_Scene.RegionInfo.RegionID.ToString()); - - Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; - Evidence evidence = new Evidence(baseEvidence); - - sandbox = AppDomain.CreateDomain( - m_Scene.RegionInfo.RegionID.ToString(), - evidence, appSetup); - sandbox.AssemblyResolve += - new ResolveEventHandler( - AssemblyResolver.OnAssemblyResolve); - } - else - { - sandbox = AppDomain.CurrentDomain; - } - - //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); - //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); - //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); - //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); - //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); - //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; - //sandbox.SetAppDomainPolicy(sandboxPolicy); - - m_AppDomains[appDomain] = sandbox; - m_DomainScripts[appDomain] = new List(); - } - catch (Exception e) - { - m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); - m_ScriptErrorMessage += "Exception creating app domain:\n"; - m_ScriptFailCount++; - lock (m_AddingAssemblies) - { - m_AddingAssemblies[assemblyPath]--; - } - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - } - - m_DomainScripts[appDomain].Add(itemID); - - IScript scriptObj = null; - EventWaitHandle coopSleepHandle; - bool coopTerminationForThisScript; - - // Set up assembly name to point to the appropriate scriptEngines directory - AssemblyName assemblyName = new AssemblyName(Path.GetFileNameWithoutExtension(assemblyPath)); - assemblyName.CodeBase = Path.GetDirectoryName(assemblyPath); - - if (m_coopTermination) - { - try - { - coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); - - scriptObj - = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( - assemblyName.FullName, - "SecondLife.XEngineScript", - false, - BindingFlags.Default, - null, - new object[] { coopSleepHandle }, - null, - null); - - coopTerminationForThisScript = true; - } - catch (TypeLoadException) - { - coopSleepHandle = null; - - try - { - scriptObj - = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( - assemblyName.FullName, - "SecondLife.Script", - false, - BindingFlags.Default, - null, - null, - null, - null); - } - catch (Exception e2) - { - m_log.Error( - string.Format( - "[XENGINE]: Could not load previous SecondLife.Script from assembly {0} in {1}. Not starting. Exception ", - assemblyName.FullName, World.Name), - e2); - - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - - coopTerminationForThisScript = false; - } - } - else - { - try - { - scriptObj - = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( - assemblyName.FullName, - "SecondLife.Script", - false, - BindingFlags.Default, - null, - null, - null, - null); - - coopSleepHandle = null; - coopTerminationForThisScript = false; - } - catch (TypeLoadException) - { - coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); - - try - { - scriptObj - = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( - assemblyName.FullName, - "SecondLife.XEngineScript", - false, - BindingFlags.Default, - null, - new object[] { coopSleepHandle }, - null, - null); - } - catch (Exception e2) - { - m_log.Error( - string.Format( - "[XENGINE]: Could not load previous SecondLife.XEngineScript from assembly {0} in {1}. Not starting. Exception ", - assemblyName.FullName, World.Name), - e2); - - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - - coopTerminationForThisScript = true; - } - } - - if (m_coopTermination != coopTerminationForThisScript && !HaveNotifiedLogOfScriptStopMismatch) - { - // Notify the log that there is at least one script compile that doesn't match the - // ScriptStopStrategy. Operator has to manually delete old DLLs - we can't do this on Windows - // once the assembly has been loaded evne if the instantiation of a class was unsuccessful. - m_log.WarnFormat( - "[XEngine]: At least one existing compiled script DLL in {0} has {1} as ScriptStopStrategy whereas config setting is {2}." - + "\nContinuing with script compiled strategy but to remove this message please set [XEngine] DeleteScriptsOnStartup = true for one simulator session to remove old script DLLs (script state will not be lost).", - World.Name, coopTerminationForThisScript ? "co-op" : "abort", m_coopTermination ? "co-op" : "abort"); - - HaveNotifiedLogOfScriptStopMismatch = true; - } - - instance = new ScriptInstance(this, part, - item, - startParam, postOnRez, - m_MaxScriptQueue); - - if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath, - Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) - { - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - return false; - } - -// if (DebugLevel >= 1) -// m_log.DebugFormat( -// "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", -// part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, -// part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); - - if (presence != null) - { - ShowScriptSaveResponse(item.OwnerID, - assetID, "Compile successful", true); - } - - instance.AppDomain = appDomain; - instance.LineMap = linemap; - - m_Scripts[itemID] = instance; - } - } - - lock (m_PrimObjects) - { - if (!m_PrimObjects.ContainsKey(localID)) - m_PrimObjects[localID] = new List(); - - if (!m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Add(itemID); - } - - - lock (m_AddingAssemblies) - { - if (!m_Assemblies.ContainsKey(assetID)) - m_Assemblies[assetID] = assemblyPath; - - m_AddingAssemblies[assemblyPath]--; - } - - if (instance != null) - { - instance.Init(); - lock (m_CompileDict) - { - foreach (EventParams pp in m_CompileDict[itemID].eventList) - instance.PostEvent(pp); - } - } - lock (m_CompileDict) - m_CompileDict.Remove(itemID); - - bool runIt = instance.ScriptTask.ScriptRunning; - if (m_runFlags.TryGetValue(itemID, out bool flagrunIt)) - { - runIt &= flagrunIt; - m_runFlags.Remove(itemID); - } - - if (!runIt) - StopScript(itemID); - - return true; - } - - public void OnRemoveScript(uint localID, UUID itemID) - { - // If it's not yet been compiled, make sure we don't try - lock (m_CompileDict) - { - if (m_CompileDict.ContainsKey(itemID)) - m_CompileDict.Remove(itemID); - } - - IScriptInstance instance = null; - lock (m_Scripts) - { - // Do we even have it? - if (!m_Scripts.TryGetValue(itemID, out instance)) - return; - m_Scripts.Remove(itemID); - } - - instance.Stop(m_WaitForEventCompletionOnScriptStop, true); - - lock (m_PrimObjects) - { - // Remove the script from it's prim - if (m_PrimObjects.ContainsKey(localID)) - { - // Remove inventory item record - if (m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Remove(itemID); - - // If there are no more scripts, remove prim - if (m_PrimObjects[localID].Count == 0) - m_PrimObjects.Remove(localID); - } - } - - if (instance.StatePersistedHere) - instance.RemoveState(); - - instance.DestroyScriptInstance(); - - m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); - if (m_DomainScripts[instance.AppDomain].Count == 0) - { - m_DomainScripts.Remove(instance.AppDomain); - UnloadAppDomain(instance.AppDomain); - } - - OnObjectRemoved?.Invoke(instance.ObjectID); - OnScriptRemoved?.Invoke(itemID); - } - - public void OnScriptReset(uint localID, UUID itemID) - { - ResetScript(itemID); - } - - public void OnStartScript(uint localID, UUID itemID) - { - StartScript(itemID); - } - - public void OnStopScript(uint localID, UUID itemID) - { - StopScript(itemID); - } - - private void CleanAssemblies() - { - List assetIDList = new List(m_Assemblies.Keys); - - foreach (IScriptInstance i in m_Scripts.Values) - { - if (assetIDList.Contains(i.AssetID)) - assetIDList.Remove(i.AssetID); - } - - lock (m_AddingAssemblies) - { - foreach (UUID assetID in assetIDList) - { - // Do not remove assembly files if another instance of the script - // is currently initialising - if (!m_AddingAssemblies.ContainsKey(m_Assemblies[assetID]) - || m_AddingAssemblies[m_Assemblies[assetID]] == 0) - { -// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); - try - { - if (File.Exists(m_Assemblies[assetID])) - File.Delete(m_Assemblies[assetID]); - - if (File.Exists(m_Assemblies[assetID]+".text")) - File.Delete(m_Assemblies[assetID]+".text"); - - if (File.Exists(m_Assemblies[assetID]+".mdb")) - File.Delete(m_Assemblies[assetID]+".mdb"); - - if (File.Exists(m_Assemblies[assetID]+".map")) - File.Delete(m_Assemblies[assetID]+".map"); - } - catch (Exception) - { - } - m_Assemblies.Remove(assetID); - } - } - } - } - - private void UnloadAppDomain(UUID id) - { - if (m_AppDomains.ContainsKey(id)) - { - AppDomain domain = m_AppDomains[id]; - m_AppDomains.Remove(id); - - if (domain != AppDomain.CurrentDomain) - AppDomain.Unload(domain); - domain = null; - // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); - } - } - - // - // Start processing - // - private void SetupEngine(int minThreads, int maxThreads, - int idleTimeout, ThreadPriority threadPriority, - int maxScriptQueue, int stackSize) - { - m_MaxScriptQueue = maxScriptQueue; - - STPStartInfo startInfo = new STPStartInfo() - { - ThreadPoolName = "XEngine", - IdleTimeout = idleTimeout * 1000, // convert to seconds as stated in .ini - MaxWorkerThreads = maxThreads, - MinWorkerThreads = minThreads, - ThreadPriority = threadPriority, - MaxStackSize = stackSize, - SuppressFlow = true, - StartSuspended = true - }; - m_ThreadPool = new SmartThreadPool(startInfo); - } - - // - // Used by script instances to queue event handler jobs - // - public IScriptWorkItem QueueEventHandler(object parms) - { - return new XWorkItem(m_ThreadPool.QueueWorkItem((WaitCallback)ProcessEventHandler,parms)); - } - - /// - /// Process a previously posted script event. - /// - /// - /// - private void ProcessEventHandler(object parms) - { - Culture.SetCurrentCulture(); - - IScriptInstance instance = (ScriptInstance) parms; - -// m_log.DebugFormat("[XEngine]: Processing event for {0}", instance); - - instance.EventProcessor(); - } - - /// - /// Post event to an entire prim - /// - /// - /// - /// - public bool PostObjectEvent(uint localID, EventParams p) - { - bool result = false; - List uuids = null; - - lock (m_PrimObjects) - { - if (!m_PrimObjects.TryGetValue(localID, out uuids)) - return false; - - foreach (UUID itemID in uuids) - { - IScriptInstance instance = null; - try - { - m_Scripts.TryGetValue(itemID, out instance); - } - catch { /* ignore race conditions */ } - - if (instance != null) - { - instance.PostEvent(p); - result = true; - } - else - { - lock (m_CompileDict) - { - if (m_CompileDict.ContainsKey(itemID)) - { - m_CompileDict[itemID].eventList.Add(p); - result = true; - } - } - } - } - } - - return result; - } - - public void CancelScriptEvent(UUID itemID, string eventName) - { - } - - /// - /// Post an event to a single script - /// - /// - /// - /// - public bool PostScriptEvent(UUID itemID, EventParams p) - { - if (m_Scripts.TryGetValue(itemID, out IScriptInstance instance)) - { - instance?.PostEvent(p); - return true; - } - lock (m_CompileDict) - { - if (m_CompileDict.ContainsKey(itemID)) - { - m_CompileDict[itemID].eventList.Add(p); - return true; - } - } - return false; - } - - public bool PostScriptEvent(UUID itemID, string name, Object[] p) - { - Object[] lsl_p = new Object[p.Length]; - for (int i = 0; i < p.Length ; i++) - { - if (p[i] is int) - lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]); - else if (p[i] is string) - lsl_p[i] = new LSL_Types.LSLString((string)p[i]); - else if (p[i] is Vector3) - lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); - else if (p[i] is Quaternion) - lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); - else if (p[i] is float) - lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); - else - lsl_p[i] = p[i]; - } - - return PostScriptEvent(itemID, new EventParams(name, lsl_p, new DetectParams[0])); - } - - public bool PostObjectEvent(UUID itemID, string name, Object[] p) - { - SceneObjectPart part = m_Scene.GetSceneObjectPart(itemID); - if (part == null) - return false; - - Object[] lsl_p = new Object[p.Length]; - for (int i = 0; i < p.Length ; i++) - { - if (p[i] is int) - lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]); - else if (p[i] is string) - lsl_p[i] = new LSL_Types.LSLString((string)p[i]); - else if (p[i] is Vector3) - lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); - else if (p[i] is Quaternion) - lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); - else if (p[i] is float) - lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); - else - lsl_p[i] = p[i]; - } - - return PostObjectEvent(part.LocalId, new EventParams(name, lsl_p, new DetectParams[0])); - } - - public Assembly OnAssemblyResolve(object sender, - ResolveEventArgs args) - { - if (!(sender is System.AppDomain)) - return null; - - string[] pathList = new string[] {"bin", m_ScriptEnginesPath, - Path.Combine(m_ScriptEnginesPath, - m_Scene.RegionInfo.RegionID.ToString())}; - - string assemblyName = args.Name; - if (assemblyName.IndexOf(",") != -1) - assemblyName = args.Name.Substring(0, args.Name.IndexOf(",")); - - foreach (string s in pathList) - { - string path = Path.Combine(Directory.GetCurrentDirectory(), - Path.Combine(s, assemblyName))+".dll"; - - //Console.WriteLine("[XEngine]: Trying to resolve {0}", path); - - if (File.Exists(path)) - return Assembly.LoadFrom(path); - } - - return null; - } - - private IScriptInstance GetInstance(UUID itemID) - { - lock (m_Scripts) - { - if (m_Scripts.TryGetValue(itemID, out IScriptInstance instance)) - return instance; - } - return null; - } - - public void SetScriptState(UUID itemID, bool running, bool self) - { - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - { - if (instance.ScriptTask != null) - instance.ScriptTask.ScriptRunning = running; - - if (running) - { - instance.Start(); - } - else - { - if(self) - { - instance.Running = false; - throw new EventAbortException(); - } - else - instance.Stop(100); - } - } - } - - public bool GetScriptState(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - return instance != null && instance.Running; - } - - public void ApiResetScript(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - instance.ApiResetScript(); - - // Send the new number of threads that are in use by the thread - // pool, I believe that by adding them to the locations where the - // script is changing states that I will catch all changes to the - // thread pool - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - } - - public void ResetScript(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - instance.ResetScript(m_WaitForEventCompletionOnScriptStop); - - // Send the new number of threads that are in use by the thread - // pool, I believe that by adding them to the locations where the - // script is changing states that I will catch all changes to the - // thread pool - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - } - - public void StartScript(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - { - instance.Start(); - if (instance.ScriptTask != null) - instance.ScriptTask.ScriptRunning = true; - } - else - m_runFlags.AddOrUpdate(itemID, true, 240); - - // Send the new number of threads that are in use by the thread - // pool, I believe that by adding them to the locations where the - // script is changing states that I will catch all changes to the - // thread pool - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - } - - public void StopScript(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - - if (instance != null) - { - lock (instance.EventQueue) - instance.StayStopped = true; // the script was stopped explicitly - - instance.Stop(m_WaitForEventCompletionOnScriptStop); - if (instance.ScriptTask != null) - instance.ScriptTask.ScriptRunning = false; - } - else - { - //m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name); - m_runFlags.AddOrUpdate(itemID, false, 240); - } - - // Send the new number of threads that are in use by the thread - // pool, I believe that by adding them to the locations where the - // script is changing states that I will catch all changes to the - // thread pool - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - } - - public DetectParams GetDetectParams(UUID itemID, int idx) - { - IScriptInstance instance = GetInstance(itemID); - return instance != null ? instance.GetDetectParams(idx) : null; - } - - public void SetMinEventDelay(UUID itemID, double delay) - { - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - instance.MinEventDelay = delay; - } - - public UUID GetDetectID(UUID itemID, int idx) - { - IScriptInstance instance = GetInstance(itemID); - return instance != null ? instance.GetDetectID(idx) : UUID.Zero; - } - - public void SetState(UUID itemID, string newState) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return; - instance.SetState(newState); - } - - public int GetStartParameter(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - return instance == null ? 0 : instance.StartParam; - } - - public void OnShutdown() - { - m_SimulatorShuttingDown = true; - - List instances = new List(); - - lock (m_Scripts) - { - foreach (IScriptInstance instance in m_Scripts.Values) - instances.Add(instance); - } - - foreach (IScriptInstance i in instances) - { - // Stop the script, even forcibly if needed. Then flag - // it as shutting down and restore the previous run state - // for serialization, so the scripts don't come back - // dead after region restart - // - bool prevRunning = i.Running; - i.Stop(50); - i.ShuttingDown = true; - i.Running = prevRunning; - } - - DoBackup(new Object[] {0}); - } - - public IScriptApi GetApi(UUID itemID, string name) - { - IScriptInstance instance = GetInstance(itemID); - return instance == null ? null : instance.GetApi(name); - } - - public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return; - IEventQueue eq = World.RequestModuleInterface(); - if (eq == null) - { - controllingClient.SendScriptRunningReply(objectID, itemID, - GetScriptState(itemID)); - } - else - { - eq.ScriptRunningEvent(objectID, itemID, GetScriptState(itemID), controllingClient.AgentId); - } - } - - public string GetXMLState(UUID itemID) - { -// m_log.DebugFormat("[XEngine]: Getting XML state for script instance {0}", itemID); - - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - { -// m_log.DebugFormat("[XEngine]: Found no script instance for {0}, returning empty string", itemID); - return ""; - } - - string xml = instance.GetXMLState(); - - XmlDocument sdoc = new XmlDocument(); - - bool loadedState = true; - try - { - sdoc.LoadXml(xml); - } - catch (System.Xml.XmlException) - { - loadedState = false; - } - - XmlNodeList rootL = null; - XmlNode rootNode = null; - if (loadedState) - { - rootL = sdoc.GetElementsByTagName("ScriptState"); - rootNode = rootL[0]; - } - - // Create - XmlDocument doc = new XmlDocument(); - XmlElement stateData = doc.CreateElement("", "State", ""); - XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); - stateID.Value = itemID.ToString(); - stateData.Attributes.Append(stateID); - XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); - assetID.Value = instance.AssetID.ToString(); - stateData.Attributes.Append(assetID); - XmlAttribute engineName = doc.CreateAttribute("", "Engine", ""); - engineName.Value = ScriptEngineName; - stateData.Attributes.Append(engineName); - doc.AppendChild(stateData); - - XmlNode xmlstate = null; - - // Add ... - if (loadedState) - { - xmlstate = doc.ImportNode(rootNode, true); - } - else - { - xmlstate = doc.CreateElement("", "ScriptState", ""); - } - - stateData.AppendChild(xmlstate); - - string assemName = instance.GetAssemblyName(); - - string fn = Path.GetFileName(assemName); - - string assem = String.Empty; - string assemNameText = assemName + ".text"; - - if (File.Exists(assemNameText)) - { - FileInfo tfi = new FileInfo(assemNameText); - - if (tfi != null) - { - Byte[] tdata = new Byte[tfi.Length]; - - try - { - using (FileStream tfs = File.Open(assemNameText, - FileMode.Open, FileAccess.Read)) - { - tfs.Read(tdata, 0, tdata.Length); - } - - assem = Encoding.ASCII.GetString(tdata); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[XEngine]: Unable to open script textfile {0}{1}, reason: {2}", - assemName, ".text", e.Message); - } - } - } - else - { - FileInfo fi = new FileInfo(assemName); - - if (fi != null) - { - Byte[] data = new Byte[fi.Length]; - - try - { - using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) - { - fs.Read(data, 0, data.Length); - } - - assem = System.Convert.ToBase64String(data); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); - } - } - } - - string map = String.Empty; - - if (File.Exists(fn + ".map")) - { - using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read)) - { - using (StreamReader msr = new StreamReader(mfs)) - { - map = msr.ReadToEnd(); - } - } - } - - XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); - - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = assem; - - stateData.AppendChild(assemblyData); - - XmlElement mapData = doc.CreateElement("", "LineMap", ""); - XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); - - mapName.Value = fn + ".map"; - mapData.Attributes.Append(mapName); - - mapData.InnerText = map; - - stateData.AppendChild(mapData); - - // m_log.DebugFormat("[XEngine]: Got XML state for {0}", itemID); - - return doc.InnerXml; - } - - private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) - { - return false; - } - - public bool SetXMLState(UUID itemID, string xml) - { -// m_log.DebugFormat("[XEngine]: Writing state for script item with ID {0}", itemID); - - if (xml.Length == 0) - return false; - - XmlDocument doc = new XmlDocument(); - - try - { - doc.LoadXml(xml); - } - catch (Exception) - { - m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); - return false; - } - - XmlNodeList rootL = doc.GetElementsByTagName("State"); - if (rootL.Count < 1) - return false; - - XmlElement rootE = (XmlElement)rootL[0]; - - if (rootE.GetAttribute("Engine") != ScriptEngineName) - return false; - -// On rez from inventory, that ID will have changed. It was only -// advisory anyway. So we don't check it anymore. -// -// if (rootE.GetAttribute("UUID") != itemID.ToString()) -// return; - - XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); - - if (stateL.Count != 1) - return false; - - XmlElement stateE = (XmlElement)stateL[0]; - - if (World.m_trustBinaries) - { - XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); - if (assemL.Count > 0) - { - XmlElement assemE = (XmlElement)assemL[0]; - - string fn = assemE.GetAttribute("Filename"); - string base64 = assemE.InnerText; - - string path = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - Byte[] filedata = Convert.FromBase64String(base64); - - try - { - using (FileStream fs = File.Create(path)) - { - // m_log.DebugFormat("[XEngine]: Writing assembly file {0}", path); - - fs.Write(filedata, 0, filedata.Length); - } - } - catch (IOException ex) - { - // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: Error whilst writing assembly file {0}, {1}", path, ex.Message); - } - - string textpath = path + ".text"; - try - { - using (FileStream fs = File.Create(textpath)) - { - using (StreamWriter sw = new StreamWriter(fs)) - { - // m_log.DebugFormat("[XEngine]: Writing .text file {0}", textpath); - - sw.Write(base64); - } - } - } - catch (IOException ex) - { - // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: Error whilst writing .text file {0}, {1}", textpath, ex.Message); - } - } - - XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); - if (mapL.Count > 0) - { - XmlElement mapE = (XmlElement)mapL[0]; - - string mappath = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); - mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); - - try - { - using (FileStream mfs = File.Create(mappath)) - { - using (StreamWriter msw = new StreamWriter(mfs)) - { - // m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath); - - msw.Write(mapE.InnerText); - } - } - } - catch (IOException ex) - { - // if there already exists a file at that location, it may be locked. - m_log.Error( - string.Format("[XEngine]: Linemap file {0} could not be written. Exception ", mappath), ex); - } - } - } - } - - string statepath = Path.Combine(m_ScriptEnginesPath, World.RegionInfo.RegionID.ToString()); - statepath = Path.Combine(statepath, itemID.ToString() + ".state"); - - try - { - using (FileStream sfs = File.Create(statepath)) - { - using (StreamWriter ssw = new StreamWriter(sfs)) - { -// m_log.DebugFormat("[XEngine]: Writing state file {0}", statepath); - - ssw.Write(stateE.OuterXml); - } - } - } - catch (IOException ex) - { - // if there already exists a file at that location, it may be locked. - m_log.ErrorFormat("[XEngine]: Error whilst writing state file {0}, {1}", statepath, ex.Message); - } - -// m_log.DebugFormat( -// "[XEngine]: Wrote state for script item with ID {0} at {1} in {2}", itemID, statepath, m_Scene.Name); - - return true; - } - - public ArrayList GetScriptErrors(UUID itemID) - { - System.Threading.Thread.Sleep(1000); - - lock (m_ScriptErrors) - { - if (m_ScriptErrors.ContainsKey(itemID)) - { - ArrayList ret = m_ScriptErrors[itemID]; - m_ScriptErrors.Remove(itemID); - return ret; - } - return new ArrayList(); - } - } - - public Dictionary GetObjectScriptsExecutionTimes() - { - Dictionary topScripts = new Dictionary(); - - lock (m_Scripts) - { - foreach (IScriptInstance si in m_Scripts.Values) - { - if (!topScripts.ContainsKey(si.RootLocalID)) - topScripts[si.RootLocalID] = 0; - - topScripts[si.RootLocalID] += GetExectionTime(si); - } - } - - return topScripts; - } - - public float GetScriptExecutionTime(List itemIDs) - { - if (itemIDs == null|| itemIDs.Count == 0) - { - return 0.0f; - } - float time = 0.0f; - IScriptInstance si; - // Calculate the time for all scripts that this engine is executing - // Ignore any others - foreach (UUID id in itemIDs) - { - si = GetInstance(id); - if (si != null && si.Running) - { - time += GetExectionTime(si); - } - } - return time; - } - - public int GetScriptsMemory(List itemIDs) - { - return 0; - } - - private float GetExectionTime(IScriptInstance si) - { - return (float)si.ExecutionTime.GetSumTime().TotalMilliseconds; - } - - public bool SuspendScript(UUID itemID) - { - // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return false; - - instance.Suspend(); - return true; - } - - public bool ResumeScript(UUID itemID) - { - // m_log.DebugFormat("[XEngine]: Received request to resume script with ID {0}", itemID); - - m_Scene.setThreadCount(m_ThreadPool.InUseThreads); - - IScriptInstance instance = GetInstance(itemID); - if (instance != null) - { - instance.Resume(); - return true; - } - return false; - } - - public bool HasScript(UUID itemID, out bool running) - { - running = true; - - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return false; - - running = instance.Running; - return true; - } - - public void SleepScript(UUID itemID, int delay) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return; - - instance.ExecutionTimer.Stop(); - try - { - if (instance.CoopWaitHandle != null) - { - if (instance.CoopWaitHandle.WaitOne(delay)) - throw new ScriptCoopStopException(); - } - else - { - Thread.Sleep(delay); - } - } - finally - { - instance.ExecutionTimer.Start(); - } - } - - public ICollection GetTopObjectStats(float mintime, int minmemory, out float totaltime, out float totalmemory) - { - Dictionary topScripts = new Dictionary(); - totalmemory = 0; - totaltime = 0; - lock (m_Scripts) - { - foreach (IScriptInstance si in m_Scripts.Values) - { - float time = GetExectionTime(si); - totaltime += time; - if(time > mintime) - { - ScriptTopStatsData sd; - if (topScripts.TryGetValue(si.RootLocalID, out sd)) - sd.time += time; - else - { - sd = new ScriptTopStatsData(); - sd.localID = si.RootLocalID; - sd.time = time; - topScripts[si.RootLocalID] = sd; - } - } - } - } - return topScripts.Values; - } - - } -} diff --git a/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs b/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs deleted file mode 100644 index ede8ef30617..00000000000 --- a/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using System.Threading; -using Amib.Threading; -using OpenSim.Region.ScriptEngine.Interfaces; - -namespace OpenSim.Region.ScriptEngine.XEngine -{ - public class XWorkItem : IScriptWorkItem - { - private IWorkItemResult wr; - - public IWorkItemResult WorkItem - { - get { return wr; } - } - - public XWorkItem(IWorkItemResult w) - { - wr = w; - } - - public bool Cancel() - { - return wr.Cancel(); - } - - public bool Abort() - { - return wr.Cancel(true); - } - - public bool Wait(int t) - { - // We use the integer version of WaitAll because the current version of SmartThreadPool has a bug with the - // TimeSpan version. The number of milliseconds in TimeSpan is an int64 so when STP casts it down to an - // int (32-bit) we can end up with bad values. This occurs on Windows though curiously not on Mono 2.10.8 - // (or very likely other versions of Mono at least up until 3.0.3). - return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false); - } - } -} diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs index 0a49ffe8358..bdbd259513f 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs @@ -38,8 +38,8 @@ public class DelegateCommon private string sig; // rettype(arg1type,arg2type,...), eg, "void(list,string,integer)" private Type type; // resultant delegate type - private static Dictionary delegateCommons = new Dictionary(); - private static Dictionary delegateCommonsBySysType = new Dictionary(); + private readonly static Dictionary delegateCommons = new(); + private readonly static Dictionary delegateCommonsBySysType = new(); private static ModuleBuilder delegateModuleBuilder = null; public static Type[] constructorArgTypes = new Type[] { typeof(object), typeof(IntPtr) }; @@ -54,9 +54,11 @@ public static Type GetType(System.Type ret, System.Type[] args, string sig) { if(!delegateCommons.TryGetValue(sig, out dc)) { - dc = new DelegateCommon(); - dc.sig = sig; - dc.type = CreateDelegateType(sig, ret, args); + dc = new DelegateCommon + { + sig = sig, + type = CreateDelegateType(sig, ret, args) + }; delegateCommons.Add(sig, dc); delegateCommonsBySysType.Add(dc.type, dc); } @@ -72,7 +74,7 @@ public static Type TryGetType(string sig) if(!delegateCommons.TryGetValue(sig, out dc)) dc = null; } - return (dc == null) ? null : dc.type; + return dc?.type; } public static string TryGetName(Type t) @@ -83,7 +85,7 @@ public static string TryGetName(Type t) if(!delegateCommonsBySysType.TryGetValue(t, out dc)) dc = null; } - return (dc == null) ? null : dc.sig; + return dc?.sig; } // http://blog.bittercoder.com/PermaLink,guid,a770377a-b1ad-4590-9145-36381757a52b.aspx @@ -91,9 +93,11 @@ private static Type CreateDelegateType(string name, Type retType, Type[] argType { if(delegateModuleBuilder == null) { - AssemblyName assembly = new AssemblyName(); - assembly.Name = "CustomDelegateAssembly"; - AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.Run); + AssemblyName assembly = new() + { + Name = "CustomDelegateAssembly" + }; + AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.RunAndCollect); delegateModuleBuilder = assemblyBuilder.DefineDynamicModule("CustomDelegateModule"); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs index ca7c372d6d1..65d428cd945 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs @@ -68,12 +68,14 @@ public InternalFuncDict(Type iface, bool inclSig) TokenName name = new TokenName(null, param.Name); argDecl.AddArg(type, name); } - TokenDeclVar declFunc = new TokenDeclVar(null, null, null); - declFunc.name = new TokenName(null, key); - declFunc.retType = TokenType.FromSysType(null, ifaceMethod.ReturnType); - declFunc.argDecl = argDecl; + TokenDeclVar declFunc = new TokenDeclVar(null, null, null) + { + name = new TokenName(null, key), + retType = TokenType.FromSysType(null, ifaceMethod.ReturnType), + argDecl = argDecl + }; - // Add the TokenDeclVar struct to the dictionary. + // Add the TokenDeclVar struct to the dictionary. this.AddEntry(declFunc); } catch(Exception except) @@ -82,7 +84,7 @@ public InternalFuncDict(Type iface, bool inclSig) string msg = except.ToString(); int i = msg.IndexOf("\n"); if(i > 0) - msg = msg.Substring(0, i); + msg = msg[..i]; Console.WriteLine("InternalFuncDict*: {0}: {1}", key, msg); ///??? IGNORE ANY THAT FAIL - LIKE UNRECOGNIZED TYPE ???/// diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs index d4659e89297..f12494b0bfd 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs @@ -34,7 +34,6 @@ using System.Reflection.Emit; using System.Runtime.Serialization; using System.Text; -using System.Threading; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; @@ -75,82 +74,81 @@ public class ScriptCodeGen: IScriptCodeGen // - must inherit from XMRInstAbstract // Static tables that there only needs to be one copy of for all. - private static VarDict legalEventHandlers = CreateLegalEventHandlers(); - private static CompValu[] zeroCompValus = new CompValu[0]; - private static TokenType[] zeroArgs = new TokenType[0]; - private static TokenTypeBool tokenTypeBool = new TokenTypeBool(null); - private static TokenTypeExc tokenTypeExc = new TokenTypeExc(null); - private static TokenTypeFloat tokenTypeFlt = new TokenTypeFloat(null); - private static TokenTypeInt tokenTypeInt = new TokenTypeInt(null); - private static TokenTypeObject tokenTypeObj = new TokenTypeObject(null); - private static TokenTypeRot tokenTypeRot = new TokenTypeRot(null); - private static TokenTypeStr tokenTypeStr = new TokenTypeStr(null); - private static TokenTypeVec tokenTypeVec = new TokenTypeVec(null); - private static Type[] instanceTypeArg = new Type[] { typeof(XMRInstAbstract) }; - private static string[] instanceNameArg = new string[] { "$xmrthis" }; - - private static ConstructorInfo lslFloatConstructorInfo = typeof(LSL_Float).GetConstructor(new Type[] { typeof(double) }); - private static ConstructorInfo lslIntegerConstructorInfo = typeof(LSL_Integer).GetConstructor(new Type[] { typeof(int) }); - private static ConstructorInfo lslListConstructorInfo = typeof(LSL_List).GetConstructor(new Type[] { typeof(object[]) }); - public static ConstructorInfo lslRotationConstructorInfo = typeof(LSL_Rotation).GetConstructor(new Type[] { typeof(double), typeof(double), typeof(double), typeof(double) }); - private static ConstructorInfo lslStringConstructorInfo = typeof(LSL_String).GetConstructor(new Type[] { typeof(string) }); - public static ConstructorInfo lslVectorConstructorInfo = typeof(LSL_Vector).GetConstructor(new Type[] { typeof(double), typeof(double), typeof(double) }); - private static ConstructorInfo scriptBadCallNoExceptionConstructorInfo = typeof(ScriptBadCallNoException).GetConstructor(new Type[] { typeof(int) }); - private static ConstructorInfo scriptChangeStateExceptionConstructorInfo = typeof(ScriptChangeStateException).GetConstructor(new Type[] { typeof(int) }); - private static ConstructorInfo scriptRestoreCatchExceptionConstructorInfo = typeof(ScriptRestoreCatchException).GetConstructor(new Type[] { typeof(Exception) }); - private static ConstructorInfo scriptUndefinedStateExceptionConstructorInfo = typeof(ScriptUndefinedStateException).GetConstructor(new Type[] { typeof(string) }); - private static ConstructorInfo sdtClassConstructorInfo = typeof(XMRSDTypeClObj).GetConstructor(new Type[] { typeof(XMRInstAbstract), typeof(int) }); - private static ConstructorInfo xmrArrayConstructorInfo = typeof(XMR_Array).GetConstructor(new Type[] { typeof(XMRInstAbstract) }); - private static FieldInfo callModeFieldInfo = typeof(XMRInstAbstract).GetField("callMode"); - private static FieldInfo doGblInitFieldInfo = typeof(XMRInstAbstract).GetField("doGblInit"); - private static FieldInfo ehArgsFieldInfo = typeof(XMRInstAbstract).GetField("ehArgs"); - private static FieldInfo rotationXFieldInfo = typeof(LSL_Rotation).GetField("x"); - private static FieldInfo rotationYFieldInfo = typeof(LSL_Rotation).GetField("y"); - private static FieldInfo rotationZFieldInfo = typeof(LSL_Rotation).GetField("z"); - private static FieldInfo rotationSFieldInfo = typeof(LSL_Rotation).GetField("s"); - private static FieldInfo sdtXMRInstFieldInfo = typeof(XMRSDTypeClObj).GetField("xmrInst"); - private static FieldInfo stackLeftFieldInfo = typeof(XMRInstAbstract).GetField("m_StackLeft"); - private static FieldInfo heapUsedFieldInfo = typeof(XMRInstAbstract).GetField("m_localsHeapUsed"); - private static FieldInfo vectorXFieldInfo = typeof(LSL_Vector).GetField("x"); - private static FieldInfo vectorYFieldInfo = typeof(LSL_Vector).GetField("y"); - private static FieldInfo vectorZFieldInfo = typeof(LSL_Vector).GetField("z"); - - private static MethodInfo arrayClearMethodInfo = typeof(XMR_Array).GetMethod("__pub_clear", new Type[] { }); - private static MethodInfo arrayCountMethodInfo = typeof(XMR_Array).GetMethod("__pub_count", new Type[] { }); - private static MethodInfo arrayIndexMethodInfo = typeof(XMR_Array).GetMethod("__pub_index", new Type[] { typeof(int) }); - private static MethodInfo arrayValueMethodInfo = typeof(XMR_Array).GetMethod("__pub_value", new Type[] { typeof(int) }); - private static MethodInfo checkRunStackMethInfo = typeof(XMRInstAbstract).GetMethod("CheckRunStack", new Type[] { }); - private static MethodInfo checkRunQuickMethInfo = typeof(XMRInstAbstract).GetMethod("CheckRunQuick", new Type[] { }); - private static MethodInfo ehArgUnwrapFloat = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapFloat", new Type[] { typeof(object) }); - private static MethodInfo ehArgUnwrapInteger = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapInteger", new Type[] { typeof(object) }); - private static MethodInfo ehArgUnwrapRotation = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapRotation", new Type[] { typeof(object) }); - private static MethodInfo ehArgUnwrapString = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapString", new Type[] { typeof(object) }); - private static MethodInfo ehArgUnwrapVector = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapVector", new Type[] { typeof(object) }); - private static MethodInfo xmrArrPubIndexMethod = typeof(XMR_Array).GetMethod("__pub_index", new Type[] { typeof(int) }); - private static MethodInfo xmrArrPubValueMethod = typeof(XMR_Array).GetMethod("__pub_value", new Type[] { typeof(int) }); - private static MethodInfo captureStackFrameMethodInfo = typeof(XMRInstAbstract).GetMethod("CaptureStackFrame", new Type[] { typeof(string), typeof(int), typeof(int) }); - private static MethodInfo restoreStackFrameMethodInfo = typeof(XMRInstAbstract).GetMethod("RestoreStackFrame", new Type[] { typeof(string), typeof(int).MakeByRefType() }); - private static MethodInfo stringCompareMethodInfo = GetStaticMethod(typeof(String), "Compare", new Type[] { typeof(string), typeof(string), typeof(StringComparison) }); - private static MethodInfo stringConcat2MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string) }); - private static MethodInfo stringConcat3MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string), typeof(string) }); - private static MethodInfo stringConcat4MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string), typeof(string), typeof(string) }); - private static MethodInfo lslRotationNegateMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "LSLRotationNegate", new Type[] { typeof(LSL_Rotation) }); - private static MethodInfo lslVectorNegateMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "LSLVectorNegate", new Type[] { typeof(LSL_Vector) }); - private static MethodInfo scriptRestoreCatchExceptionUnwrap = GetStaticMethod(typeof(ScriptRestoreCatchException), "Unwrap", new Type[] { typeof(Exception) }); - private static MethodInfo thrownExceptionWrapMethodInfo = GetStaticMethod(typeof(ScriptThrownException), "Wrap", new Type[] { typeof(object) }); - private static MethodInfo catchExcToStrMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "CatchExcToStr", new Type[] { typeof(Exception) }); - private static MethodInfo consoleWriteMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "ConsoleWrite", new Type[] { typeof(object) }); + private static readonly VarDict legalEventHandlers = CreateLegalEventHandlers(); + private static readonly CompValu[] zeroCompValus = Array.Empty(); + private static readonly TokenType[] zeroArgs = Array.Empty(); + private static readonly TokenTypeBool tokenTypeBool = new(null); + private static readonly TokenTypeExc tokenTypeExc = new(null); + private static readonly TokenTypeFloat tokenTypeFlt = new(null); + private static readonly TokenTypeInt tokenTypeInt = new(null); + private static readonly TokenTypeObject tokenTypeObj = new(null); + private static readonly TokenTypeRot tokenTypeRot = new(null); + private static readonly TokenTypeStr tokenTypeStr = new(null); + private static readonly TokenTypeVec tokenTypeVec = new(null); + private static readonly Type[] instanceTypeArg = new Type[] { typeof(XMRInstAbstract) }; + private static readonly string[] instanceNameArg = new string[] { "$xmrthis" }; + + private static readonly ConstructorInfo lslFloatConstructorInfo = typeof(LSL_Float).GetConstructor(new Type[] { typeof(double) }); + private static readonly ConstructorInfo lslIntegerConstructorInfo = typeof(LSL_Integer).GetConstructor(new Type[] { typeof(int) }); + private static readonly ConstructorInfo lslListConstructorInfo = typeof(LSL_List).GetConstructor(new Type[] { typeof(object[]) }); + public static readonly ConstructorInfo lslRotationConstructorInfo = typeof(LSL_Rotation).GetConstructor(new Type[] { typeof(double), typeof(double), typeof(double), typeof(double) }); + private static readonly ConstructorInfo lslStringConstructorInfo = typeof(LSL_String).GetConstructor(new Type[] { typeof(string) }); + public static readonly ConstructorInfo lslVectorConstructorInfo = typeof(LSL_Vector).GetConstructor(new Type[] { typeof(double), typeof(double), typeof(double) }); + private static readonly ConstructorInfo scriptBadCallNoExceptionConstructorInfo = typeof(ScriptBadCallNoException).GetConstructor(new Type[] { typeof(int) }); + private static readonly ConstructorInfo scriptChangeStateExceptionConstructorInfo = typeof(ScriptChangeStateException).GetConstructor(new Type[] { typeof(int) }); + private static readonly ConstructorInfo scriptRestoreCatchExceptionConstructorInfo = typeof(ScriptRestoreCatchException).GetConstructor(new Type[] { typeof(Exception) }); + private static readonly ConstructorInfo scriptUndefinedStateExceptionConstructorInfo = typeof(ScriptUndefinedStateException).GetConstructor(new Type[] { typeof(string) }); + private static readonly ConstructorInfo sdtClassConstructorInfo = typeof(XMRSDTypeClObj).GetConstructor(new Type[] { typeof(XMRInstAbstract), typeof(int) }); + private static readonly ConstructorInfo xmrArrayConstructorInfo = typeof(XMR_Array).GetConstructor(new Type[] { typeof(XMRInstAbstract) }); + private static readonly FieldInfo callModeFieldInfo = typeof(XMRInstAbstract).GetField("callMode"); + private static readonly FieldInfo doGblInitFieldInfo = typeof(XMRInstAbstract).GetField("doGblInit"); + private static readonly FieldInfo ehArgsFieldInfo = typeof(XMRInstAbstract).GetField("ehArgs"); + private static readonly FieldInfo rotationXFieldInfo = typeof(LSL_Rotation).GetField("x"); + private static readonly FieldInfo rotationYFieldInfo = typeof(LSL_Rotation).GetField("y"); + private static readonly FieldInfo rotationZFieldInfo = typeof(LSL_Rotation).GetField("z"); + private static readonly FieldInfo rotationSFieldInfo = typeof(LSL_Rotation).GetField("s"); + private static readonly FieldInfo sdtXMRInstFieldInfo = typeof(XMRSDTypeClObj).GetField("xmrInst"); + private static readonly FieldInfo stackLeftFieldInfo = typeof(XMRInstAbstract).GetField("m_StackLeft"); + private static readonly FieldInfo heapUsedFieldInfo = typeof(XMRInstAbstract).GetField("m_localsHeapUsed"); + private static readonly FieldInfo vectorXFieldInfo = typeof(LSL_Vector).GetField("x"); + private static readonly FieldInfo vectorYFieldInfo = typeof(LSL_Vector).GetField("y"); + private static readonly FieldInfo vectorZFieldInfo = typeof(LSL_Vector).GetField("z"); + + private static readonly MethodInfo arrayClearMethodInfo = typeof(XMR_Array).GetMethod("__pub_clear", Array.Empty()); + private static readonly MethodInfo arrayCountMethodInfo = typeof(XMR_Array).GetMethod("__pub_count", Array.Empty()); + private static readonly MethodInfo arrayIndexMethodInfo = typeof(XMR_Array).GetMethod("__pub_index", new Type[] { typeof(int) }); + private static readonly MethodInfo arrayValueMethodInfo = typeof(XMR_Array).GetMethod("__pub_value", new Type[] { typeof(int) }); + private static readonly MethodInfo checkRunStackMethInfo = typeof(XMRInstAbstract).GetMethod("CheckRunStack", Array.Empty()); + private static readonly MethodInfo checkRunQuickMethInfo = typeof(XMRInstAbstract).GetMethod("CheckRunQuick", Array.Empty()); + private static readonly MethodInfo ehArgUnwrapFloat = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapFloat", new Type[] { typeof(object) }); + private static readonly MethodInfo ehArgUnwrapInteger = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapInteger", new Type[] { typeof(object) }); + private static readonly MethodInfo ehArgUnwrapRotation = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapRotation", new Type[] { typeof(object) }); + private static readonly MethodInfo ehArgUnwrapString = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapString", new Type[] { typeof(object) }); + private static readonly MethodInfo ehArgUnwrapVector = GetStaticMethod(typeof(TypeCast), "EHArgUnwrapVector", new Type[] { typeof(object) }); + private static readonly MethodInfo xmrArrPubIndexMethod = typeof(XMR_Array).GetMethod("__pub_index", new Type[] { typeof(int) }); + private static readonly MethodInfo xmrArrPubValueMethod = typeof(XMR_Array).GetMethod("__pub_value", new Type[] { typeof(int) }); + private static readonly MethodInfo captureStackFrameMethodInfo = typeof(XMRInstAbstract).GetMethod("CaptureStackFrame", new Type[] { typeof(string), typeof(int), typeof(int) }); + private static readonly MethodInfo restoreStackFrameMethodInfo = typeof(XMRInstAbstract).GetMethod("RestoreStackFrame", new Type[] { typeof(string), typeof(int).MakeByRefType() }); + private static readonly MethodInfo stringCompareMethodInfo = GetStaticMethod(typeof(String), "Compare", new Type[] { typeof(string), typeof(string), typeof(StringComparison) }); + private static readonly MethodInfo stringConcat2MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string) }); + private static readonly MethodInfo stringConcat3MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string), typeof(string) }); + private static readonly MethodInfo stringConcat4MethodInfo = GetStaticMethod(typeof(String), "Concat", new Type[] { typeof(string), typeof(string), typeof(string), typeof(string) }); + private static readonly MethodInfo lslRotationNegateMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "LSLRotationNegate", new Type[] { typeof(LSL_Rotation) }); + private static readonly MethodInfo lslVectorNegateMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "LSLVectorNegate", new Type[] { typeof(LSL_Vector) }); + private static readonly MethodInfo scriptRestoreCatchExceptionUnwrap = GetStaticMethod(typeof(ScriptRestoreCatchException), "Unwrap", new Type[] { typeof(Exception) }); + private static readonly MethodInfo thrownExceptionWrapMethodInfo = GetStaticMethod(typeof(ScriptThrownException), "Wrap", new Type[] { typeof(object) }); + private static readonly MethodInfo catchExcToStrMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "CatchExcToStr", new Type[] { typeof(Exception) }); + private static readonly MethodInfo consoleWriteMethodInfo = GetStaticMethod(typeof(ScriptCodeGen), "ConsoleWrite", new Type[] { typeof(object) }); public static void ConsoleWrite(object o) { - if(o == null) - o = "<>"; + o ??= "<>"; Console.Write(o.ToString()); } public static bool CodeGen(TokenScript tokenScript, BinaryWriter objFileWriter, string sourceHash) { // Run compiler such that it has a 'this' context for convenience. - ScriptCodeGen scg = new ScriptCodeGen(tokenScript, objFileWriter, sourceHash); + ScriptCodeGen scg = new(tokenScript, objFileWriter, sourceHash); // Return pointer to resultant script object code. return !scg.youveAnError; @@ -163,15 +161,15 @@ public static bool CodeGen(TokenScript tokenScript, BinaryWriter objFileWriter, private BreakContTarg curContTarg = null; private int lastErrorLine = 0; private int nStates = 0; - private string sourceHash; + private readonly string sourceHash; private string lastErrorFile = ""; private string[] stateNames; - private XMRInstArSizes glblSizes = new XMRInstArSizes(); + private readonly XMRInstArSizes glblSizes = new (); private Token errorMessageToken = null; private TokenDeclVar curDeclFunc = null; private TokenStmtBlock curStmtBlock = null; - private BinaryWriter objFileWriter = null; - private TokenScript tokenScript = null; + private readonly BinaryWriter objFileWriter = null; + private readonly TokenScript tokenScript = null; public int tempCompValuNum = 0; private TokenDeclSDTypeClass currentSDTClass = null; @@ -183,8 +181,8 @@ public static bool CodeGen(TokenScript tokenScript, BinaryWriter objFileWriter, private ScriptMyLabel retLabel = null; // where to jump to exit function private ScriptMyLocal retValue = null; private ScriptMyLocal actCallNo = null; // for the active try/catch/finally stack or the big one outside them all - private LinkedList actCallLabels = new LinkedList(); // for the active try/catch/finally stack or the big one outside them all - private LinkedList allCallLabels = new LinkedList(); // this holds each and every one for all stacks in total + private LinkedList actCallLabels = new(); // for the active try/catch/finally stack or the big one outside them all + private LinkedList allCallLabels = new(); // this holds each and every one for all stacks in total public CallLabel openCallLabel = null; // only one call label can be open at a time // - the call label is open from the time of CallPre() until corresponding CallPost() // - so no non-trivial pushes/pops etc allowed between a CallPre() and a CallPost() @@ -217,7 +215,6 @@ private ScriptCodeGen(TokenScript tokenScript, BinaryWriter objFileWriter, strin } finally { - objFileWriter = null; } } @@ -277,9 +274,8 @@ private void PerformCompilation() foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { itIsAGoodDayToDie = false; - if(sdType is TokenDeclSDTypeClass) + if(sdType is TokenDeclSDTypeClass sdtClass) { - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; foreach(TokenDeclVar declFunc in sdtClass.members) { if(declFunc.retType != null) @@ -289,15 +285,14 @@ private void PerformCompilation() { // this is for the "$new()" static method that we create below. // See GenerateStmtNewobj() etc. - new TokenTypeSDTypeDelegate(declFunc, sdtClass.MakeRefToken(declFunc), + _ = new TokenTypeSDTypeDelegate(declFunc, sdtClass.MakeRefToken(declFunc), declFunc.argDecl.types, tokenScript); } } } } - if(sdType is TokenDeclSDTypeInterface) + if(sdType is TokenDeclSDTypeInterface sdtIFace) { - TokenDeclSDTypeInterface sdtIFace = (TokenDeclSDTypeInterface)sdType; foreach(TokenDeclVar declFunc in sdtIFace.methsNProps) { if(declFunc.retType != null) @@ -344,7 +339,7 @@ private void PerformCompilation() // GenerateFromLValSField(). foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass) continue; TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; @@ -375,9 +370,9 @@ private void PerformCompilation() // $get() and $set() methods are in the table and they each get a slot. foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeInterface)) + if(sdType is not TokenDeclSDTypeInterface sdtIFace) continue; - TokenDeclSDTypeInterface sdtIFace = (TokenDeclSDTypeInterface)sdType; + int vti = 0; foreach(TokenDeclVar im in sdtIFace.methsNProps) { @@ -396,9 +391,8 @@ private void PerformCompilation() didOne = false; foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass sdtClass) continue; - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; if(sdtClass.slotsAssigned) continue; @@ -667,19 +661,19 @@ private void PerformCompilation() didOne = false; foreach(TokenDeclVar tdv in tokenScript.variablesStack) { - if(tdv.constant && !(tdv.init is TokenRValConst)) + if(tdv.constant && tdv.init is not TokenRValConst) { tdv.init = tdv.init.TryComputeConstant(LookupInitConstants, ref didOne); } } foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass TokenDeclSDTypeClasssdType) continue; - currentSDTClass = (TokenDeclSDTypeClass)sdType; + currentSDTClass = TokenDeclSDTypeClasssdType; foreach(TokenDeclVar tdv in currentSDTClass.members) { - if(tdv.constant && !(tdv.init is TokenRValConst)) + if(tdv.constant && tdv.init is not TokenRValConst) { tdv.init = tdv.init.TryComputeConstant(LookupInitConstants, ref didOne); } @@ -693,9 +687,8 @@ private void PerformCompilation() { if(tdv.constant) { - if(tdv.init is TokenRValConst) + if (tdv.init is TokenRValConst rvc) { - TokenRValConst rvc = (TokenRValConst)tdv.init; tdv.type = rvc.tokType; tdv.location = rvc.GetCompValu(); } @@ -707,16 +700,15 @@ private void PerformCompilation() } foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass TokenDeclSDTypeClasssdType) continue; - currentSDTClass = (TokenDeclSDTypeClass)sdType; + currentSDTClass = TokenDeclSDTypeClasssdType; foreach(TokenDeclVar tdv in currentSDTClass.members) { if(tdv.constant) { - if(tdv.init is TokenRValConst) + if (tdv.init is TokenRValConst rvc) { - TokenRValConst rvc = (TokenRValConst)tdv.init; tdv.type = rvc.tokType; tdv.location = rvc.GetCompValu(); } @@ -734,9 +726,8 @@ private void PerformCompilation() // class to be instantiated via the new operator. foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass sdtClass) continue; - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; // See if the class as it stands would be able to fill every slot of its vtable. bool[] filled = new bool[sdtClass.numVirtFuncs]; @@ -761,7 +752,7 @@ private void PerformCompilation() // Note that the reducer made sure there is at least a default constructor for every class. if(numFilled >= sdtClass.numVirtFuncs) { - List newobjDeclFuncs = new List(); + List newobjDeclFuncs = new (); foreach(TokenDeclVar ctorDeclFunc in sdtClass.members) { if((ctorDeclFunc.funcNameSig != null) && ctorDeclFunc.funcNameSig.val.StartsWith("$ctor(")) @@ -799,9 +790,8 @@ private void PerformCompilation() } foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(!(sdType is TokenDeclSDTypeClass)) + if(sdType is not TokenDeclSDTypeClass sdtClass) continue; - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; foreach(TokenDeclVar declVar in sdtClass.members) { if((declVar.sdtFlags & ScriptReduce.SDT_STATIC) != 0) @@ -834,12 +824,11 @@ private void PerformCompilation() } foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(sdType is TokenDeclSDTypeClass) + if (sdType is TokenDeclSDTypeClass sdtClass) { - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; - foreach(TokenDeclVar declFunc in sdtClass.members) + foreach (TokenDeclVar declFunc in sdtClass.members) { - if((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) + if ((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) GenerateMethodHeader(declFunc); } } @@ -853,12 +842,11 @@ private void PerformCompilation() } foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - if(sdType is TokenDeclSDTypeClass) + if (sdType is TokenDeclSDTypeClass sdtClass) { - TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; - foreach(TokenDeclVar declFunc in sdtClass.members) + foreach (TokenDeclVar declFunc in sdtClass.members) { - if((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) + if ((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) GenerateMethodBody(declFunc); } } @@ -867,21 +855,22 @@ private void PerformCompilation() // Output default state event handler functions. // Each event handler is a private static method named 'default '. // Splice in a default state_entry() handler if none defined so we can init global vars. - TokenDeclVar defaultStateEntry = null; - for(defaultStateEntry = tokenScript.defaultState.body.eventFuncs; - defaultStateEntry != null; - defaultStateEntry = (TokenDeclVar)defaultStateEntry.nextToken) + TokenDeclVar defaultStateEntry = tokenScript.defaultState.body.eventFuncs; + while(defaultStateEntry != null) { - if(defaultStateEntry.funcNameSig.val == "state_entry()") + if("state_entry()".Equals(defaultStateEntry.funcNameSig.val)) break; + defaultStateEntry = (TokenDeclVar)defaultStateEntry.nextToken; } - if(defaultStateEntry == null) + if (defaultStateEntry == null) { - defaultStateEntry = new TokenDeclVar(tokenScript.defaultState.body, null, tokenScript); - defaultStateEntry.name = new TokenName(tokenScript.defaultState.body, "state_entry"); - defaultStateEntry.retType = new TokenTypeVoid(tokenScript.defaultState.body); - defaultStateEntry.argDecl = new TokenArgDecl(tokenScript.defaultState.body); - defaultStateEntry.body = new TokenStmtBlock(tokenScript.defaultState.body); + defaultStateEntry = new TokenDeclVar(tokenScript.defaultState.body, null, tokenScript) + { + name = new TokenName(tokenScript.defaultState.body, "state_entry"), + retType = new TokenTypeVoid(tokenScript.defaultState.body), + argDecl = new TokenArgDecl(tokenScript.defaultState.body), + body = new TokenStmtBlock(tokenScript.defaultState.body) + }; defaultStateEntry.body.function = defaultStateEntry; defaultStateEntry.nextToken = tokenScript.defaultState.body.eventFuncs; @@ -940,20 +929,15 @@ private void WriteOutGblAssignment(string pfx, TokenDeclVar declVar) */ private void GenerateStateEventHandlers(string statename, TokenStateBody body) { - Dictionary statehandlers = new Dictionary(); + Dictionary statehandlers = new(); for(Token t = body.eventFuncs; t != null; t = t.nextToken) { TokenDeclVar tdv = (TokenDeclVar)t; string eventname = tdv.GetSimpleName(); - if(statehandlers.ContainsKey(eventname)) - { - ErrorMsg(tdv, "event handler " + eventname + " already defined for state " + statename); - } - else - { - statehandlers.Add(eventname, tdv); + if(statehandlers.TryAdd(eventname, tdv)) GenerateEventHandler(statename, tdv); - } + else + ErrorMsg(tdv, "event handler " + eventname + " already defined for state " + statename); } } @@ -991,7 +975,7 @@ private void GenerateEventHandler(string statename, TokenDeclVar declFunc) ilGen.Emit(declFunc, OpCodes.Castclass, xmrInstSuperType); ilGen.Emit(declFunc, OpCodes.Stloc, instancePointer); - if (curDeclFunc.fullName != "$globalvarinit()") + if (!"$globalvarinit()".Equals(curDeclFunc.fullName)) { PushXMRInst(); ilGen.Emit(curDeclFunc, OpCodes.Ldfld, heapUsedFieldInfo); @@ -1001,13 +985,12 @@ private void GenerateEventHandler(string statename, TokenDeclVar declFunc) // Output args as variable definitions and initialize each from __sw.ehArgs[]. // If the script writer goofed, the typecast will complain. - int nArgs = argDecl.vars.Length; - for(int i = 0; i < nArgs; i++) + for(int i = 0; i < argDecl.vars.Length; i++) { // Say that the argument variable is going to be located in a local var. TokenDeclVar argVar = argDecl.vars[i]; TokenType argTokType = argVar.type; - CompValuLocalVar local = new CompValuLocalVar(argTokType, argVar.name.val, this); + CompValuLocalVar local = new (argTokType, argVar.name.val, this); argVar.location = local; // Copy from the ehArgs[i] element to the temp var. @@ -1113,6 +1096,12 @@ private void GenerateMethodHeader(TokenDeclVar declFunc) */ private void GenerateMethodBody(TokenDeclVar declFunc) { + if ("$globalvarinit()".Equals(declFunc.fullName)) + { + if(declFunc.body?.statements == null) + return; + } + // Set up code generator for the function's contents. _ilGen = declFunc.ilGen; StartFunctionBody(declFunc); @@ -1132,7 +1121,7 @@ private void GenerateMethodBody(TokenDeclVar declFunc) ilGen.Emit(declFunc, OpCodes.Stloc, instancePointer); } - if (curDeclFunc.fullName != "$globalvarinit()") + if (!("$globalvarinit()".Equals(declFunc.fullName))) { PushXMRInst(); ilGen.Emit(curDeclFunc, OpCodes.Ldfld, heapUsedFieldInfo); @@ -1144,8 +1133,7 @@ private void GenerateMethodBody(TokenDeclVar declFunc) // The argument indices need to have +1 added to them because XMRInstance or // XMRSDTypeClObj is spliced in at arg 0. TokenArgDecl argDecl = declFunc.argDecl; - int nArgs = argDecl.vars.Length; - for(int i = 0; i < nArgs; i++) + for(int i = 0; i < argDecl.vars.Length; i++) { TokenDeclVar argVar = argDecl.vars[i]; argVar.location = new CompValuArg(argVar.type, i + 1); @@ -1175,65 +1163,78 @@ private void StartFunctionBody(TokenDeclVar declFunc) */ private TokenDeclVar DefineNewobjFunc(TokenDeclVar ctorDeclFunc) { - // Set up 'static classname $new(params-same-as-ctor) { }'. - TokenDeclVar newobjDeclFunc = new TokenDeclVar(ctorDeclFunc, null, tokenScript); + // Set up 'static classname $new(params-same-as-ctor) { }'. + TokenDeclVar newobjDeclFunc = new (ctorDeclFunc, null, tokenScript); newobjDeclFunc.name = new TokenName(newobjDeclFunc, "$new"); newobjDeclFunc.retType = ctorDeclFunc.sdtClass.MakeRefToken(newobjDeclFunc); newobjDeclFunc.argDecl = ctorDeclFunc.argDecl; newobjDeclFunc.sdtClass = ctorDeclFunc.sdtClass; newobjDeclFunc.sdtFlags = ScriptReduce.SDT_STATIC | ctorDeclFunc.sdtFlags; - // Declare local variable named '$objptr' in a frame just under - // what the '$new(...)' function's arguments are declared in. - TokenDeclVar objptrVar = new TokenDeclVar(newobjDeclFunc, newobjDeclFunc, tokenScript); - objptrVar.type = newobjDeclFunc.retType; - objptrVar.name = new TokenName(newobjDeclFunc, "$objptr"); - VarDict newFrame = new VarDict(false); - newFrame.outerVarDict = ctorDeclFunc.argDecl.varDict; + // Declare local variable named '$objptr' in a frame just under + // what the '$new(...)' function's arguments are declared in. + TokenDeclVar objptrVar = new (newobjDeclFunc, newobjDeclFunc, tokenScript) + { + type = newobjDeclFunc.retType, + name = new TokenName(newobjDeclFunc, "$objptr") + }; + VarDict newFrame = new (false) + { + outerVarDict = ctorDeclFunc.argDecl.varDict + }; newFrame.AddEntry(objptrVar); - // Set up '$objptr.$ctor' - TokenLValName objptrLValName = new TokenLValName(objptrVar.name, newFrame); + // Set up '$objptr.$ctor' + TokenLValName objptrLValName = new (objptrVar.name, newFrame); // ref a var by giving its name - TokenLValIField objptrDotCtor = new TokenLValIField(newobjDeclFunc); // an instance member reference - objptrDotCtor.baseRVal = objptrLValName; // '$objptr' - objptrDotCtor.fieldName = ctorDeclFunc.name; // '.' '$ctor' - - // Set up '$objptr.$ctor(arglist)' call for use in the '$new(...)' body. - // Copy the arglist from the constructor declaration so triviality - // processing will pick the correct overloaded constructor. - TokenRValCall callCtorRVal = new TokenRValCall(newobjDeclFunc); // doing a call of some sort - callCtorRVal.meth = objptrDotCtor; // calling $objptr.$ctor() + TokenLValIField objptrDotCtor = new (newobjDeclFunc) + { + baseRVal = objptrLValName, // '$objptr' + fieldName = ctorDeclFunc.name // '.' '$ctor' + }; // an instance member reference + + // Set up '$objptr.$ctor(arglist)' call for use in the '$new(...)' body. + // Copy the arglist from the constructor declaration so triviality + // processing will pick the correct overloaded constructor. + TokenRValCall callCtorRVal = new (newobjDeclFunc) + { + meth = objptrDotCtor // calling $objptr.$ctor() + }; // doing a call of some sort TokenDeclVar[] argList = newobjDeclFunc.argDecl.vars; // get args $new() was declared with callCtorRVal.nArgs = argList.Length; // ...that is nArgs we are passing to $objptr.$ctor() for(int i = argList.Length; --i >= 0;) { TokenDeclVar arg = argList[i]; // find out about one of the args - TokenLValName argLValName = new TokenLValName(arg.name, ctorDeclFunc.argDecl.varDict); - // pass arg of that name to $objptr.$ctor() - argLValName.nextToken = callCtorRVal.args; // link to list of args passed to $objptr.$ctor() + TokenLValName argLValName = new (arg.name, ctorDeclFunc.argDecl.varDict) + { + // pass arg of that name to $objptr.$ctor() + nextToken = callCtorRVal.args // link to list of args passed to $objptr.$ctor() + }; callCtorRVal.args = argLValName; } - // Set up a funky call to the constructor for the code body. - // This will let code generator know there is some craziness. - // See GenerateStmtNewobj(). - // - // This is in essence: - // { - // classname $objptr = newobj (classname); - // $objptr.$ctor (...); - // return $objptr; - // } - TokenStmtNewobj newobjStmtBody = new TokenStmtNewobj(ctorDeclFunc); - newobjStmtBody.objptrVar = objptrVar; - newobjStmtBody.rValCall = callCtorRVal; - TokenStmtBlock newobjBody = new TokenStmtBlock(ctorDeclFunc); - newobjBody.statements = newobjStmtBody; + // Set up a funky call to the constructor for the code body. + // This will let code generator know there is some craziness. + // See GenerateStmtNewobj(). + // + // This is in essence: + // { + // classname $objptr = newobj (classname); + // $objptr.$ctor (...); + // return $objptr; + // } + TokenStmtNewobj newobjStmtBody = new (ctorDeclFunc) + { + objptrVar = objptrVar, + rValCall = callCtorRVal + }; - // Link that code as the body of the function. - newobjDeclFunc.body = newobjBody; + // Link that code as the body of the function. + newobjDeclFunc.body = new TokenStmtBlock(ctorDeclFunc) + { + statements = newobjStmtBody + }; // Say the function calls '$objptr.$ctor(arglist)' so we will inherit ctor's triviality. newobjDeclFunc.unknownTrivialityCalls.AddLast(callCtorRVal); @@ -1281,7 +1282,7 @@ private void GenerateFuncBody() // after putting return value in __retval. retLabel = ilGen.DefineLabel("__retlbl"); retValue = null; - if(!(curDeclFunc.retType is TokenTypeVoid)) + if(curDeclFunc.retType is not TokenTypeVoid) { retValue = ilGen.DeclareLocal(curDeclFunc.retType.ToSysType(), "__retval"); } @@ -1312,8 +1313,8 @@ private void GenerateFuncBody() ilGen.Emit(curDeclFunc, OpCodes.Bne_Un, cmRestore); } - // Splice in the code optimizer for the body of the function. - ScriptCollector collector = new ScriptCollector((ScriptObjWriter)ilGen); + // Splice in the code optimizer for the body of the function. + ScriptCollector collector = new ((ScriptObjWriter)ilGen); _ilGen = collector; // If this is the default state_entry() handler, output code to set all global @@ -1323,42 +1324,61 @@ private void GenerateFuncBody() string methname = ilGen.methName; if(methname == "default state_entry") { - - // if (!doGblInit) goto skipGblInit; - ScriptMyLabel skipGblInitLabel = ilGen.DefineLabel("__skipGblInit"); - PushXMRInst(); // instance - ilGen.Emit(curDeclFunc, OpCodes.Ldfld, doGblInitFieldInfo); // instance.doGblInit - ilGen.Emit(curDeclFunc, OpCodes.Brfalse, skipGblInitLabel); - - // $globalvarinit(); TokenDeclVar gviFunc = tokenScript.globalVarInit; - if(gviFunc.body.statements != null) + bool dogblinitcheck = gviFunc.body.statements != null; + if(!dogblinitcheck) { - gviFunc.location.CallPre(this, gviFunc); - gviFunc.location.CallPost(this, gviFunc); + foreach (TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) + { + if (sdType is TokenDeclSDTypeClass sdTypeClass) + { + TokenDeclVar sfiFunc = sdTypeClass.staticFieldInit; + if ((sfiFunc is not null) && (sfiFunc.body.statements is not null)) + { + dogblinitcheck = true; + break; + } + } + } } - // various $staticfieldinit(); - foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) + if (dogblinitcheck) { - if(sdType is TokenDeclSDTypeClass) + // generate if (!doGblInit) goto skipGblInit; + ScriptMyLabel skipGblInitLabel = ilGen.DefineLabel("__skipGblInit"); + PushXMRInst(); // instance + ilGen.Emit(curDeclFunc, OpCodes.Ldfld, doGblInitFieldInfo); // instance.doGblInit + ilGen.Emit(curDeclFunc, OpCodes.Brfalse, skipGblInitLabel); + + // $globalvarinit(); + if(gviFunc.body.statements != null) + { + gviFunc.location.CallPre(this, gviFunc); + gviFunc.location.CallPost(this, gviFunc); + } + + // various $staticfieldinit(); + foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { - TokenDeclVar sfiFunc = ((TokenDeclSDTypeClass)sdType).staticFieldInit; - if((sfiFunc != null) && (sfiFunc.body.statements != null)) + if(sdType is TokenDeclSDTypeClass sdTypeClass) { - sfiFunc.location.CallPre(this, sfiFunc); - sfiFunc.location.CallPost(this, sfiFunc); + TokenDeclVar sfiFunc = sdTypeClass.staticFieldInit; + if((sfiFunc is not null) && (sfiFunc.body.statements is not null)) + { + sfiFunc.location.CallPre(this, sfiFunc); + sfiFunc.location.CallPost(this, sfiFunc); + } } } - } - // doGblInit = 0; - PushXMRInst(); // instance - ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4_0); - ilGen.Emit(curDeclFunc, OpCodes.Stfld, doGblInitFieldInfo); // instance.doGblInit + // doGblInit = 0; + PushXMRInst(); // instance + ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4_0); + ilGen.Emit(curDeclFunc, OpCodes.Stfld, doGblInitFieldInfo); // instance.doGblInit - //skipGblInit: - ilGen.MarkLabel(skipGblInitLabel); + //skipGblInit: + ilGen.MarkLabel(skipGblInitLabel); + } } // If this is a script-defined type constructor, call the base constructor and call @@ -1399,7 +1419,7 @@ private void GenerateFuncBody() // returns 'void'. if (mightGetHere) { - if(!(curDeclFunc.retType is TokenTypeVoid)) + if(curDeclFunc.retType is not TokenTypeVoid) { ErrorMsg(curDeclFunc.body, "missing final return statement"); } @@ -1413,7 +1433,6 @@ private void GenerateFuncBody() // list below to look for active locals and temps. collector.Optimize(); _ilGen = collector.WriteOutAll(); - collector = null; List activeTemps = null; if (!isTrivial) @@ -1447,7 +1466,6 @@ private void GenerateFuncBody() // GenerateFrameCaptureCode(); // __endFin: // } - ScriptMyLabel endFin = null; if(!isTrivial) { ilGen.BeginFinallyBlock(); @@ -1457,7 +1475,7 @@ private void GenerateFuncBody() ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, stackframesize); ilGen.Emit(curDeclFunc, OpCodes.Add); ilGen.Emit(curDeclFunc, OpCodes.Stfld, stackLeftFieldInfo); - endFin = ilGen.DefineLabel("__endFin"); + ScriptMyLabel endFin = ilGen.DefineLabel("__endFin"); PushXMRInst(); ilGen.Emit(curDeclFunc, OpCodes.Ldfld, callModeFieldInfo); ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, XMRInstAbstract.CallMode_SAVE); @@ -1479,7 +1497,7 @@ private void GenerateFuncBody() ilGen.Emit(curDeclFunc, OpCodes.Stfld, heapUsedFieldInfo); } - if (!(curDeclFunc.retType is TokenTypeVoid)) + if (curDeclFunc.retType is not TokenTypeVoid) { ilGen.Emit(curDeclFunc, OpCodes.Ldloc, retValue); } @@ -1757,103 +1775,103 @@ public CallLabel(ScriptCodeGen scg, Token errorAt) private void GenerateStmt(TokenStmt stmt) { errorMessageToken = stmt; - if(stmt is TokenDeclVar) + if(stmt is TokenDeclVar TokenDeclVarstmt) { - GenerateDeclVar((TokenDeclVar)stmt); + GenerateDeclVar(TokenDeclVarstmt); return; } - if(stmt is TokenStmtBlock) + if(stmt is TokenStmtBlock TokenStmtBlockstmt) { - GenerateStmtBlock((TokenStmtBlock)stmt); + GenerateStmtBlock(TokenStmtBlockstmt); return; } - if(stmt is TokenStmtBreak) + if(stmt is TokenStmtBreak TokenStmtBreakstmt) { - GenerateStmtBreak((TokenStmtBreak)stmt); + GenerateStmtBreak(TokenStmtBreakstmt); return; } - if(stmt is TokenStmtCont) + if(stmt is TokenStmtCont TokenStmtContstmt) { - GenerateStmtCont((TokenStmtCont)stmt); + GenerateStmtCont(TokenStmtContstmt); return; } - if(stmt is TokenStmtDo) + if(stmt is TokenStmtDo TokenStmtDostmt) { - GenerateStmtDo((TokenStmtDo)stmt); + GenerateStmtDo(TokenStmtDostmt); return; } - if(stmt is TokenStmtFor) + if(stmt is TokenStmtFor TokenStmtForstmt) { - GenerateStmtFor((TokenStmtFor)stmt); + GenerateStmtFor(TokenStmtForstmt); return; } - if(stmt is TokenStmtForEach) + if(stmt is TokenStmtForEach TokenStmtForEachstmt) { - GenerateStmtForEach((TokenStmtForEach)stmt); + GenerateStmtForEach(TokenStmtForEachstmt); return; } - if(stmt is TokenStmtIf) + if(stmt is TokenStmtIf TokenStmtIfstmt) { - GenerateStmtIf((TokenStmtIf)stmt); + GenerateStmtIf(TokenStmtIfstmt); return; } - if(stmt is TokenStmtJump) + if(stmt is TokenStmtJump TokenStmtJumpstmt) { - GenerateStmtJump((TokenStmtJump)stmt); + GenerateStmtJump(TokenStmtJumpstmt); return; } - if(stmt is TokenStmtLabel) + if(stmt is TokenStmtLabel TokenStmtLabelstmt) { - GenerateStmtLabel((TokenStmtLabel)stmt); + GenerateStmtLabel(TokenStmtLabelstmt); return; } - if(stmt is TokenStmtNewobj) + if(stmt is TokenStmtNewobj TokenStmtNewobjstmt) { - GenerateStmtNewobj((TokenStmtNewobj)stmt); + GenerateStmtNewobj(TokenStmtNewobjstmt); return; } if(stmt is TokenStmtNull) { return; } - if(stmt is TokenStmtRet) + if(stmt is TokenStmtRet TokenStmtRetstmt) { - GenerateStmtRet((TokenStmtRet)stmt); + GenerateStmtRet(TokenStmtRetstmt); return; } - if(stmt is TokenStmtRVal) + if(stmt is TokenStmtRVal TokenStmtRValstmt) { - GenerateStmtRVal((TokenStmtRVal)stmt); + GenerateStmtRVal(TokenStmtRValstmt); return; } - if(stmt is TokenStmtState) + if(stmt is TokenStmtState TokenStmtStatestmt) { - GenerateStmtState((TokenStmtState)stmt); + GenerateStmtState(TokenStmtStatestmt); return; } - if(stmt is TokenStmtSwitch) + if(stmt is TokenStmtSwitch TokenStmtSwitchstmt) { - GenerateStmtSwitch((TokenStmtSwitch)stmt); + GenerateStmtSwitch(TokenStmtSwitchstmt); return; } - if(stmt is TokenStmtThrow) + if(stmt is TokenStmtThrow TokenStmtThrowstmt) { - GenerateStmtThrow((TokenStmtThrow)stmt); + GenerateStmtThrow(TokenStmtThrowstmt); return; } - if(stmt is TokenStmtTry) + if(stmt is TokenStmtTry TokenStmtTrystmt) { - GenerateStmtTry((TokenStmtTry)stmt); + GenerateStmtTry(TokenStmtTrystmt); return; } - if(stmt is TokenStmtVarIniDef) + if(stmt is TokenStmtVarIniDef TokenStmtVarIniDefstmt) { - GenerateStmtVarIniDef((TokenStmtVarIniDef)stmt); + GenerateStmtVarIniDef(TokenStmtVarIniDefstmt); return; } - if(stmt is TokenStmtWhile) + if(stmt is TokenStmtWhile TokenStmtWhilestmt) { - GenerateStmtWhile((TokenStmtWhile)stmt); + GenerateStmtWhile(TokenStmtWhilestmt); return; } throw new Exception("unknown TokenStmt type " + stmt.GetType().ToString()); @@ -2063,7 +2081,7 @@ private void GenerateStmtForEach(TokenStmtForEach forEachStmt) if(forEachStmt.keyLVal != null) { keyLVal = GenerateFromLVal(forEachStmt.keyLVal); - if(!(keyLVal.type is TokenTypeObject)) + if(keyLVal.type is not TokenTypeObject) { ErrorMsg(forEachStmt.arrayRVal, "must be object"); } @@ -2071,12 +2089,12 @@ private void GenerateStmtForEach(TokenStmtForEach forEachStmt) if(forEachStmt.valLVal != null) { valLVal = GenerateFromLVal(forEachStmt.valLVal); - if(!(valLVal.type is TokenTypeObject)) + if(valLVal.type is not TokenTypeObject) { ErrorMsg(forEachStmt.arrayRVal, "must be object"); } } - if(!(arrayRVal.type is TokenTypeArray)) + if(arrayRVal.type is not TokenTypeArray) { ErrorMsg(forEachStmt.arrayRVal, "must be an array"); } @@ -2084,7 +2102,7 @@ private void GenerateStmtForEach(TokenStmtForEach forEachStmt) curBreakTarg = new BreakContTarg(this, "foreachbreak_" + forEachStmt.Unique); curContTarg = new BreakContTarg(this, "foreachcont_" + forEachStmt.Unique); - CompValuTemp indexVar = new CompValuTemp(new TokenTypeInt(forEachStmt), this); + CompValuTemp indexVar = new (new TokenTypeInt(forEachStmt), this); ScriptMyLabel loopLabel = ilGen.DefineLabel("foreachloop_" + forEachStmt.Unique); // indexVar = 0 @@ -2165,11 +2183,9 @@ private void GenerateStmtIf(TokenStmtIf ifStmt) if(!mightGetHere) return; - bool constVal; - - // Test condition and see if constant test expression. + // Test condition and see if constant test expression. CompValu testRVal = GenerateFromRVal(ifStmt.testRVal); - if(IsConstBoolExpr(testRVal, out constVal)) + if (IsConstBoolExpr(testRVal, out bool constVal)) { // Constant, output just either the true or else part. if(constVal) @@ -2217,14 +2233,13 @@ private void GenerateStmtJump(TokenStmtJump jumpStmt) if(!mightGetHere) return; - // Make sure the target label is defined somewhere in the function. - TokenStmtLabel stmtLabel; - if(!curDeclFunc.labels.TryGetValue(jumpStmt.label.val, out stmtLabel)) + // Make sure the target label is defined somewhere in the function. + if (!curDeclFunc.labels.TryGetValue(jumpStmt.label.val, out TokenStmtLabel stmtLabel)) { ErrorMsg(jumpStmt, "undefined label " + jumpStmt.label.val); return; } - if(!stmtLabel.labelTagged) + if (!stmtLabel.labelTagged) { stmtLabel.labelStruct = ilGen.DefineLabel("jump_" + stmtLabel.name.val); stmtLabel.labelTagged = true; @@ -2254,7 +2269,7 @@ private void EmitJumpCode(ScriptMyLabel target, TokenStmtBlock targetsBlock, Tok // } bool useLeave = false; TokenStmtBlock stmtBlock; - Stack finallyBlocksCalled = new Stack(); + Stack finallyBlocksCalled = new (); for(stmtBlock = curStmtBlock; stmtBlock != targetsBlock; stmtBlock = stmtBlock.outerStmtBlock) { if(stmtBlock == null) @@ -2318,12 +2333,13 @@ private void EmitJumpCode(ScriptMyLabel target, TokenStmtBlock targetsBlock, Tok { TokenStmtTry finallyBlock = finallyBlocksCalled.Pop(); string intername = "intr" + (++level) + "_" + target.name; - IntermediateLeave iLeave; - if(!finallyBlock.iLeaves.TryGetValue(intername, out iLeave)) + if (!finallyBlock.iLeaves.TryGetValue(intername, out IntermediateLeave iLeave)) { - iLeave = new IntermediateLeave(); - iLeave.jumpIntoLabel = ilGen.DefineLabel(intername); - iLeave.jumpAwayLabel = target; + iLeave = new IntermediateLeave + { + jumpIntoLabel = ilGen.DefineLabel(intername), + jumpAwayLabel = target + }; finallyBlock.iLeaves.Add(intername, iLeave); } target = iLeave.jumpIntoLabel; @@ -2335,7 +2351,7 @@ private void EmitJumpCode(ScriptMyLabel target, TokenStmtBlock targetsBlock, Tok // restore to that will properly jump back into the finally block. if(useLeave) { - new CallLabel(this, errorAt); + _ = new CallLabel(this, errorAt); ilGen.Emit(errorAt, OpCodes.Leave, target); openCallLabel = null; } @@ -2454,7 +2470,7 @@ private void GenerateStmtRet(TokenStmtRet retStmt) } } if(brokeOutOfTry) - new CallLabel(this, retStmt); + _ = new CallLabel(this, retStmt); ilGen.Emit(retStmt, OpCodes.Leave, retLabel); if(brokeOutOfTry) openCallLabel = null; @@ -2608,10 +2624,7 @@ private void GenerateStmtSwitchInt(CompValu testRVal, TokenStmtSwitch switchStmt } } - if(defaultLabel == null) - { - defaultLabel = ilGen.DefineLabel("default_" + switchStmt.Unique); - } + defaultLabel ??= ilGen.DefineLabel("default_" + switchStmt.Unique); // Output code to jump to the case statement's labels based on integer index on stack. // Note that each case still has the integer index on stack when jumped to. @@ -2754,9 +2767,9 @@ private void GenerateStmtSwitchStr(CompValu testRVal, TokenStmtSwitch switchStmt curBreakTarg = new BreakContTarg(this, "switchbreak_" + switchStmt.Unique); // Make sure value is in a temp so we don't compute it more than once. - if(!(testRVal is CompValuTemp)) + if(testRVal is not CompValuTemp) { - CompValuTemp temp = new CompValuTemp(testRVal.type, this); + CompValuTemp temp = new (testRVal.type, this); testRVal.PushVal(this, switchStmt); temp.Pop(this, switchStmt); testRVal = temp; @@ -2814,10 +2827,7 @@ private void GenerateStmtSwitchStr(CompValu testRVal, TokenStmtSwitch switchStmt caseTreeTop = BalanceTree(caseTreeTop); // Output compare and branch instructions in a tree-like fashion so we do O(log2 n) comparisons. - if(defaultLabel == null) - { - defaultLabel = ilGen.DefineLabel("default"); - } + defaultLabel ??= ilGen.DefineLabel("default"); OutputStrCase(testRVal, caseTreeTop, defaultLabel); // Output code for the cases themselves, in the order given by the programmer, @@ -3169,9 +3179,9 @@ private void GenerateStmtTry(TokenStmtTry tryStmt) */ private void GenerateStmtTryCatch(TokenStmtTry tryStmt) { - CompValuTemp tryCallNo = new CompValuTemp(tokenTypeInt, this); - CompValuTemp catCallNo = new CompValuTemp(tokenTypeInt, this); - CompValuTemp catThrown = new CompValuTemp(tokenTypeExc, this); + CompValuTemp tryCallNo = new (tokenTypeInt, this); + CompValuTemp catCallNo = new (tokenTypeInt, this); + CompValuTemp catThrown = new (tokenTypeExc, this); ScriptMyLabel tryCallSw = ilGen.DefineLabel("__tryCallSw_" + tryStmt.Unique); ScriptMyLabel catchRetro = ilGen.DefineLabel("__catchRetro_" + tryStmt.Unique); @@ -3183,7 +3193,7 @@ private void GenerateStmtTryCatch(TokenStmtTry tryStmt) ilGen.Emit(tryStmt, OpCodes.Ldnull); catThrown.Pop(this, tryStmt); - new CallLabel(this, tryStmt); // : + _ = new CallLabel(this, tryStmt); // : ilGen.BeginExceptionBlock(); // try { openCallLabel = null; @@ -3199,12 +3209,12 @@ private void GenerateStmtTryCatch(TokenStmtTry tryStmt) bool tryBlockFallsOutBottom = mightGetHere; if(tryBlockFallsOutBottom) { - new CallLabel(this, tryStmt); // : + _ = new CallLabel(this, tryStmt); // : ilGen.Emit(tryStmt, OpCodes.Leave, tryEnd); // leave tryEnd; openCallLabel = null; } - CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:: + CallLabel tryThrow = new (this, tryStmt); // tryThrow:: catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown); ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo); ilGen.Emit(tryStmt, OpCodes.Throw); @@ -3269,7 +3279,7 @@ private void GenerateStmtTryCatch(TokenStmtTry tryStmt) if(mightGetHere) { - new CallLabel(this, tryStmt.catchStmt); + _ = new CallLabel(this, tryStmt.catchStmt); ilGen.Emit(tryStmt.catchStmt, OpCodes.Leave, tryEnd); openCallLabel = null; } @@ -3340,14 +3350,14 @@ private void GenerateStmtTryCatch(TokenStmtTry tryStmt) */ private void GenerateStmtTryFinally(TokenStmtTry tryStmt) { - CompValuTemp finCallNo = new CompValuTemp(tokenTypeInt, this); - CompValuTemp tryCallNo = new CompValuTemp(tokenTypeInt, this); - CompValuTemp catThrown = new CompValuTemp(tokenTypeExc, this); + CompValuTemp finCallNo = new (tokenTypeInt, this); + CompValuTemp tryCallNo = new (tokenTypeInt, this); + CompValuTemp catThrown = new (tokenTypeExc, this); ScriptMyLabel tryCallSw = ilGen.DefineLabel("__tryCallSw_" + tryStmt.Unique); ScriptMyLabel catchRetro = ilGen.DefineLabel("__catchRetro_" + tryStmt.Unique); ScriptMyLabel finCallSw = ilGen.DefineLabel("__finCallSw_" + tryStmt.Unique); - BreakContTarg finEnd = new BreakContTarg(this, "__finEnd_" + tryStmt.Unique); + BreakContTarg finEnd = new (this, "__finEnd_" + tryStmt.Unique); ScriptMyLabel tryEnd = ilGen.DefineLabel("__tryEnd_" + tryStmt.Unique); SetCallNo(tryStmt, finCallNo, -1); @@ -3355,7 +3365,7 @@ private void GenerateStmtTryFinally(TokenStmtTry tryStmt) ilGen.Emit(tryStmt, OpCodes.Ldnull); catThrown.Pop(this, tryStmt); - new CallLabel(this, tryStmt); // : + _ = new CallLabel(this, tryStmt); // : ilGen.BeginExceptionBlock(); // try { ilGen.BeginExceptionBlock(); // try { openCallLabel = null; @@ -3371,7 +3381,7 @@ private void GenerateStmtTryFinally(TokenStmtTry tryStmt) if(mightGetHere) { - new CallLabel(this, tryStmt); // : + _ = new CallLabel(this, tryStmt); // : ilGen.Emit(tryStmt, OpCodes.Leave, tryEnd); // leave tryEnd; openCallLabel = null; } @@ -3379,12 +3389,12 @@ private void GenerateStmtTryFinally(TokenStmtTry tryStmt) foreach(IntermediateLeave iLeave in tryStmt.iLeaves.Values) { ilGen.MarkLabel(iLeave.jumpIntoLabel); // intr2_exit: - new CallLabel(this, tryStmt); // tryCallNo = n; + _ = new CallLabel(this, tryStmt); // tryCallNo = n; ilGen.Emit(tryStmt, OpCodes.Leave, iLeave.jumpAwayLabel); // __callNo_n_: leave int1_exit; openCallLabel = null; } - CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:: + CallLabel tryThrow = new (this, tryStmt); // tryThrow:: catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown); ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo); ilGen.Emit(tryStmt, OpCodes.Throw); @@ -3534,16 +3544,16 @@ private CompValu GenerateFromLVal(TokenLVal lVal) } private CompValu GenerateFromLVal(TokenLVal lVal, TokenType[] argsig) { - if(lVal is TokenLValArEle) - return GenerateFromLValArEle((TokenLValArEle)lVal); - if(lVal is TokenLValBaseField) - return GenerateFromLValBaseField((TokenLValBaseField)lVal, argsig); - if(lVal is TokenLValIField) - return GenerateFromLValIField((TokenLValIField)lVal, argsig); - if(lVal is TokenLValName) - return GenerateFromLValName((TokenLValName)lVal, argsig); - if(lVal is TokenLValSField) - return GenerateFromLValSField((TokenLValSField)lVal, argsig); + if(lVal is TokenLValArEle TokenLValArElelVal) + return GenerateFromLValArEle(TokenLValArElelVal); + if(lVal is TokenLValBaseField TokenLValBaseFieldlVal) + return GenerateFromLValBaseField(TokenLValBaseFieldlVal, argsig); + if(lVal is TokenLValIField TokenLValIFieldlVal) + return GenerateFromLValIField(TokenLValIFieldlVal, argsig); + if(lVal is TokenLValName TokenLValNamelVal) + return GenerateFromLValName(TokenLValNamelVal, argsig); + if(lVal is TokenLValSField TokenLValSFieldlVal) + return GenerateFromLValSField(TokenLValSFieldlVal, argsig); throw new Exception("bad lval class"); } @@ -3560,14 +3570,14 @@ private CompValu GenerateFromLValArEle(TokenLValArEle lVal) // Maybe it is a fixed array access. string basetypestring = baseCompValu.type.ToString(); - if(basetypestring.EndsWith("]")) + if(basetypestring.EndsWith(']')) { TokenRVal subRVal = lVal.subRVal; int nSubs = 1; - if(subRVal is TokenRValList) + if(subRVal is TokenRValList list) { - nSubs = ((TokenRValList)subRVal).nItems; - subRVal = ((TokenRValList)subRVal).rVal; + nSubs = list.nItems; + subRVal = list.rVal; } int rank = basetypestring.IndexOf(']') - basetypestring.IndexOf('['); @@ -3588,10 +3598,10 @@ private CompValu GenerateFromLValArEle(TokenLValArEle lVal) } // Maybe it is accessing the $idxprop property of a script-defined class. - if(baseCompValu.type is TokenTypeSDTypeClass) + if(baseCompValu.type is TokenTypeSDTypeClass typeclass) { - TokenName name = new TokenName(lVal, "$idxprop"); - TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)baseCompValu.type; + TokenName name = new (lVal, "$idxprop"); + TokenTypeSDTypeClass sdtType = typeclass; TokenDeclSDTypeClass sdtDecl = sdtType.decl; TokenDeclVar idxProp = FindThisMember(sdtDecl, name, null); if(idxProp == null) @@ -3613,10 +3623,10 @@ private CompValu GenerateFromLValArEle(TokenLValArEle lVal) } // Maybe they are accessing $idxprop property of a script-defined interface. - if(baseCompValu.type is TokenTypeSDTypeInterface) + if(baseCompValu.type is TokenTypeSDTypeInterface TokenTypeSDTypeInterfacebaseCompValutype) { - TokenName name = new TokenName(lVal, "$idxprop"); - TokenTypeSDTypeInterface sdtType = (TokenTypeSDTypeInterface)baseCompValu.type; + TokenName name = new (lVal, "$idxprop"); + TokenTypeSDTypeInterface sdtType = TokenTypeSDTypeInterfacebaseCompValutype; TokenDeclVar idxProp = FindInterfaceMember(sdtType, name, null, ref baseCompValu); if(idxProp == null) { @@ -3644,7 +3654,7 @@ private CompValu GenerateFromLValArEle(TokenLValArEle lVal) } // Access should be to XMR_Array otherwise. - if(!(baseCompValu.type is TokenTypeArray)) + if(baseCompValu.type is not TokenTypeArray) { ErrorMsg(lVal, "taking subscript of non-array"); return baseCompValu; @@ -3694,10 +3704,10 @@ private CompValu[] IdxPropCompValus(TokenLValArEle lVal, int nArgs) { TokenRVal subRVal = lVal.subRVal; int nSubs = 1; - if(subRVal is TokenRValList) + if(subRVal is TokenRValList list) { - nSubs = ((TokenRValList)subRVal).nItems; - subRVal = ((TokenRValList)subRVal).rVal; + nSubs = list.nItems; + subRVal = list.rVal; } if(nSubs != nArgs) @@ -3944,15 +3954,14 @@ private CompValu GenerateFromLValSField(TokenLValSField lVal, TokenType[] argsig TokenType stType = lVal.baseType; string fieldName = lVal.fieldName.val + ArgSigString(argsig); - // Maybe they are accessing a static member of a script-defined class. - if(stType is TokenTypeSDTypeClass) + // Maybe they are accessing a static member of a script-defined class. + if (stType is TokenTypeSDTypeClass sdtType) { - TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)stType; TokenDeclVar declVar = FindThisMember(sdtType.decl, lVal.fieldName, argsig); - if(declVar != null) + if (declVar != null) { CheckAccess(declVar, lVal.fieldName); - if((declVar.sdtFlags & ScriptReduce.SDT_STATIC) == 0) + if ((declVar.sdtFlags & ScriptReduce.SDT_STATIC) == 0) { ErrorMsg(lVal.fieldName, "static reference to non-static member " + fieldName); return new CompValuVoid(lVal.fieldName); @@ -4002,42 +4011,42 @@ private CompValu GenerateFromRVal(TokenRVal rVal, TokenType[] argsig) // Generate code for the computation and return resulting type and location. CompValu cVal = null; - if(rVal is TokenRValAsnPost) - cVal = GenerateFromRValAsnPost((TokenRValAsnPost)rVal); - else if (rVal is TokenRValAsnPre) - cVal = GenerateFromRValAsnPre((TokenRValAsnPre)rVal); - else if (rVal is TokenRValCall) - cVal = GenerateFromRValCall((TokenRValCall)rVal); - else if (rVal is TokenRValCast) - cVal = GenerateFromRValCast((TokenRValCast)rVal); - else if (rVal is TokenRValCondExpr) - cVal = GenerateFromRValCondExpr((TokenRValCondExpr)rVal); - else if (rVal is TokenRValConst) - cVal = GenerateFromRValConst((TokenRValConst)rVal); - else if (rVal is TokenRValInitDef) - cVal = GenerateFromRValInitDef((TokenRValInitDef)rVal); - else if (rVal is TokenRValIsType) - cVal = GenerateFromRValIsType((TokenRValIsType)rVal); - else if (rVal is TokenRValList) - cVal = GenerateFromRValList((TokenRValList)rVal); - else if (rVal is TokenRValNewArIni) - cVal = GenerateFromRValNewArIni((TokenRValNewArIni)rVal); - else if (rVal is TokenRValOpBin) - cVal = GenerateFromRValOpBin((TokenRValOpBin)rVal); - else if (rVal is TokenRValOpUn) - cVal = GenerateFromRValOpUn((TokenRValOpUn)rVal); - else if (rVal is TokenRValParen) - cVal = GenerateFromRValParen((TokenRValParen)rVal); - else if (rVal is TokenRValRot) - cVal = GenerateFromRValRot((TokenRValRot)rVal); - else if (rVal is TokenRValThis) - cVal = GenerateFromRValThis((TokenRValThis)rVal); - else if (rVal is TokenRValUndef) - cVal = GenerateFromRValUndef((TokenRValUndef)rVal); - else if (rVal is TokenRValVec) - cVal = GenerateFromRValVec((TokenRValVec)rVal); - else if (rVal is TokenLVal) - cVal = GenerateFromLVal((TokenLVal)rVal, argsig); + if(rVal is TokenRValAsnPost TokenRValAsnPostrVal) + cVal = GenerateFromRValAsnPost(TokenRValAsnPostrVal); + else if (rVal is TokenRValAsnPre TokenRValAsnPrerVal) + cVal = GenerateFromRValAsnPre(TokenRValAsnPrerVal); + else if (rVal is TokenRValCall TokenRValCallrVal) + cVal = GenerateFromRValCall(TokenRValCallrVal); + else if (rVal is TokenRValCast TokenRValCastrVal) + cVal = GenerateFromRValCast(TokenRValCastrVal); + else if (rVal is TokenRValCondExpr TokenRValCondExprrVal) + cVal = GenerateFromRValCondExpr(TokenRValCondExprrVal); + else if (rVal is TokenRValConst TokenRValConstrVal) + cVal = GenerateFromRValConst(TokenRValConstrVal); + else if (rVal is TokenRValInitDef TokenRValInitDefrVal) + cVal = GenerateFromRValInitDef(TokenRValInitDefrVal); + else if (rVal is TokenRValIsType TokenRValIsTyperVal) + cVal = GenerateFromRValIsType(TokenRValIsTyperVal); + else if (rVal is TokenRValList TokenRValListrVal) + cVal = GenerateFromRValList(TokenRValListrVal); + else if (rVal is TokenRValNewArIni TokenRValNewArInirVal) + cVal = GenerateFromRValNewArIni(TokenRValNewArInirVal); + else if (rVal is TokenRValOpBin TokenRValOpBinrVal) + cVal = GenerateFromRValOpBin(TokenRValOpBinrVal); + else if (rVal is TokenRValOpUn TokenRValOpUnrVal) + cVal = GenerateFromRValOpUn(TokenRValOpUnrVal); + else if (rVal is TokenRValParen TokenRValParenrVal) + cVal = GenerateFromRValParen(TokenRValParenrVal); + else if (rVal is TokenRValRot TokenRValRotrVal) + cVal = GenerateFromRValRot(TokenRValRotrVal); + else if (rVal is TokenRValThis TokenRValThisrVal) + cVal = GenerateFromRValThis(TokenRValThisrVal); + else if (rVal is TokenRValUndef TokenRValUndefrVal) + cVal = GenerateFromRValUndef(TokenRValUndefrVal); + else if (rVal is TokenRValVec TokenRValVecrVal) + cVal = GenerateFromRValVec(TokenRValVecrVal); + else if (rVal is TokenLVal TokenLValrVal) + cVal = GenerateFromLVal(TokenLValrVal, argsig); if(cVal == null) throw new Exception("bad rval class " + rVal.GetType().ToString()); @@ -4090,7 +4099,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) // of the delegate to select which overloaded method to use. if(opcodeIndex == "=") { - if(!(token.rValLeft is TokenLVal)) + if(token.rValLeft is not TokenLVal) { ErrorMsg(token, "invalid L-value for ="); return GenerateFromRVal(token.rValLeft); @@ -4112,7 +4121,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) { // We are adding something. Maybe it's a bunch of strings together. - List scorvs = new List(); + List scorvs = new (); if(StringConcatOperands(token.rValLeft, token.rValRight, scorvs, token.opcode)) { // Evaluate all the operands, right-to-left on purpose per LSL scripting. @@ -4180,9 +4189,9 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) // Compute left-hand operand and if true, compute right-hand operand. if(opcodeIndex == "&&&") { - bool leftVal, rightVal; + bool rightVal; left = GenerateFromRVal(token.rValLeft); - if(!IsConstBoolExpr(left, out leftVal)) + if(!IsConstBoolExpr(left, out bool leftVal)) { ScriptMyLabel falseLabel = ilGen.DefineLabel("ssandfalse"); left.PushVal(this, tokenTypeBool); @@ -4205,7 +4214,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) ilGen.MarkLabel(falseLabel); ilGen.Emit(token, OpCodes.Ldc_I4_0); ilGen.MarkLabel(doneLabel); - CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); + CompValuTemp retRVal = new (new TokenTypeInt(token), this); retRVal.Pop(this, token); return retRVal; } @@ -4219,7 +4228,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) if(!IsConstBoolExpr(right, out rightVal)) { right.PushVal(this, tokenTypeBool); - CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); + CompValuTemp retRVal = new (new TokenTypeInt(token), this); retRVal.Pop(this, token); return retRVal; } @@ -4230,9 +4239,9 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) // Compute left-hand operand and if false, compute right-hand operand. if(opcodeIndex == "|||") { - bool leftVal, rightVal; + bool rightVal; left = GenerateFromRVal(token.rValLeft); - if(!IsConstBoolExpr(left, out leftVal)) + if(!IsConstBoolExpr(left, out bool leftVal)) { ScriptMyLabel trueLabel = ilGen.DefineLabel("ssortrue"); left.PushVal(this, tokenTypeBool); @@ -4255,7 +4264,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) ilGen.MarkLabel(trueLabel); ilGen.Emit(token, OpCodes.Ldc_I4_1); ilGen.MarkLabel(doneLabel); - CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); + CompValuTemp retRVal = new (new TokenTypeInt(token), this); retRVal.Pop(this, token); return retRVal; } @@ -4269,7 +4278,7 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) if(!IsConstBoolExpr(right, out rightVal)) { right.PushVal(this, tokenTypeBool); - CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); + CompValuTemp retRVal = new (new TokenTypeInt(token), this); retRVal.Pop(this, token); return retRVal; } @@ -4284,12 +4293,11 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) // convert this to a call to that method with the right value as its single parameter. // Except don't if the right value is 'undef' so they can always compare to undef. TokenType leftType = token.rValLeft.GetRValType(this, null); - if((leftType is TokenTypeSDTypeClass) && !(right.type is TokenTypeUndef)) + if((leftType is TokenTypeSDTypeClass sdtType) && right.type is not TokenTypeUndef) { - TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)leftType; TokenDeclSDTypeClass sdtDecl = sdtType.decl; TokenType[] argsig = new TokenType[] { right.type }; - TokenName funcName = new TokenName(token.opcode, "$op" + opcodeIndex); + TokenName funcName = new (token.opcode, "$op" + opcodeIndex); TokenDeclVar declFunc = FindThisMember(sdtDecl, funcName, argsig); if(declFunc != null) { @@ -4306,19 +4314,18 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) string rightIndex = right.type.ToString(); string key = leftIndex + opcodeIndex + rightIndex; - // If that key exists in table, then the operation is defined between those types - // ... and it produces an R-value of type as given in the table. - BinOpStr binOpStr; - if(BinOpStr.defined.TryGetValue(key, out binOpStr)) + // If that key exists in table, then the operation is defined between those types + // ... and it produces an R-value of type as given in the table. + if (BinOpStr.defined.TryGetValue(key, out BinOpStr binOpStr)) { - // If table contained an explicit assignment type like +=, output the statement without - // casting the L-value, then return the L-value as the resultant value. - // - // Make sure we don't include comparisons (such as ==, >=, etc). - // Nothing like +=, -=, %=, etc, generate a boolean, only the comparisons. - if((binOpStr.outtype != typeof(bool)) && opcodeIndex.EndsWith("=") && (opcodeIndex != "!=")) + // If table contained an explicit assignment type like +=, output the statement without + // casting the L-value, then return the L-value as the resultant value. + // + // Make sure we don't include comparisons (such as ==, >=, etc). + // Nothing like +=, -=, %=, etc, generate a boolean, only the comparisons. + if ((binOpStr.outtype != typeof(bool)) && opcodeIndex.EndsWith('=') && (opcodeIndex != "!=")) { - if(!(token.rValLeft is TokenLVal)) + if (token.rValLeft is not TokenLVal) { ErrorMsg(token.rValLeft, "invalid L-value"); return GenerateFromRVal(token.rValLeft); @@ -4328,20 +4335,20 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) return left; } - // It's of the form left binop right. - // Compute left, perform operation then put result in a temp. + // It's of the form left binop right. + // Compute left, perform operation then put result in a temp. left = GenerateFromRVal(token.rValLeft); CompValu retRVal = new CompValuTemp(TokenType.FromSysType(token.opcode, binOpStr.outtype), this); binOpStr.emitBO(this, token, left, right, retRVal); return retRVal; } - // Nothing in the table, check for comparing object pointers because of the myriad of types possible. - // This will compare list pointers, null pointers, script-defined type pointers, array pointers, etc. - // It will show equal iff the memory addresses are equal and that is good enough. - if(!leftType.ToSysType().IsValueType && !right.type.ToSysType().IsValueType && ((opcodeIndex == "==") || (opcodeIndex == "!="))) + // Nothing in the table, check for comparing object pointers because of the myriad of types possible. + // This will compare list pointers, null pointers, script-defined type pointers, array pointers, etc. + // It will show equal iff the memory addresses are equal and that is good enough. + if (!leftType.ToSysType().IsValueType && !right.type.ToSysType().IsValueType && ((opcodeIndex == "==") || (opcodeIndex == "!="))) { - CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); + CompValuTemp retRVal = new (new TokenTypeInt(token), this); left = GenerateFromRVal(token.rValLeft); left.PushVal(this, token.rValLeft); right.PushVal(this, token.rValRight); @@ -4359,13 +4366,13 @@ private CompValu GenerateFromRValOpBin(TokenRValOpBin token) // So look up the key as if we didn't have the "=" to tell us if the operation is legal. // Also, the binary operation's output type must be the same as the L-value type. // Likewise, integer += float not allowed because result is float, but float += integer is ok. - if(opcodeIndex.EndsWith("=")) + if(opcodeIndex.EndsWith('=')) { - string op = opcodeIndex.Substring(0, opcodeIndex.Length - 1); + string op = opcodeIndex[..^1]; key = leftIndex + op + rightIndex; if(BinOpStr.defined.TryGetValue(key, out binOpStr)) { - if(!(token.rValLeft is TokenLVal)) + if(token.rValLeft is not TokenLVal) { ErrorMsg(token, "invalid L-value for ="); return GenerateFromRVal(token.rValLeft); @@ -4420,7 +4427,7 @@ private bool StringConcatOperands(TokenRVal leftRVal, TokenRVal rightRVal, List< */ TokenType leftType = leftRVal.GetRValType(this, null); TokenType rightType = rightRVal.GetRValType(this, null); - if(!(leftType is TokenTypeStr) && !(rightType is TokenTypeStr)) + if(leftType is not TokenTypeStr && rightType is not TokenTypeStr) return false; // Also, list+string => list so reject that too. @@ -4476,12 +4483,12 @@ private void StringConcatOperand(TokenType type, TokenRVal rVal, List rVal = rVal.TryComputeConstant(LookupBodyConstants, ref didOne); } while(didOne); - if(!(type is TokenTypeStr)) + if(type is not TokenTypeStr) goto pushasis; - if(!(rVal is TokenRValOpBin)) + if(rVal is not TokenRValOpBin) goto pushasis; TokenRValOpBin rValOpBin = (TokenRValOpBin)rVal; - if(!(rValOpBin.opcode is TokenKwAdd)) + if(rValOpBin.opcode is not TokenKwAdd) goto pushasis; if(StringConcatOperands(rValOpBin.rValLeft, rValOpBin.rValRight, scos, rValOpBin.opcode)) return; @@ -4498,14 +4505,13 @@ private CompValu GenerateFromRValOpUn(TokenRValOpUn token) { CompValu inRVal = GenerateFromRVal(token.rVal); - // Script-defined types can define their own methods to handle unary operators. - if(inRVal.type is TokenTypeSDTypeClass) + // Script-defined types can define their own methods to handle unary operators. + if (inRVal.type is TokenTypeSDTypeClass sdtType) { - TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)inRVal.type; TokenDeclSDTypeClass sdtDecl = sdtType.decl; - TokenName funcName = new TokenName(token.opcode, "$op" + token.opcode.ToString()); + TokenName funcName = new (token.opcode, "$op" + token.opcode.ToString()); TokenDeclVar declFunc = FindThisMember(sdtDecl, funcName, zeroArgs); - if(declFunc != null) + if (declFunc != null) { CheckAccess(declFunc, funcName); CompValu method = AccessInstanceMember(declFunc, inRVal, token, false); @@ -4513,7 +4519,7 @@ private CompValu GenerateFromRValOpUn(TokenRValOpUn token) } } - // Otherwise use the default. + // Otherwise use the default. return UnOpGenerate(inRVal, token.opcode); } @@ -4525,7 +4531,7 @@ private CompValu GenerateFromRValAsnPost(TokenRValAsnPost asnPost) CompValu lVal = GenerateFromLVal(asnPost.lVal); // Make up a temp to save original value in. - CompValuTemp result = new CompValuTemp(lVal.type, this); + CompValuTemp result = new (lVal.type, this); // Prepare to pop incremented value back into variable being incremented. lVal.PopPre(this, asnPost.lVal); @@ -4580,7 +4586,7 @@ private CompValu GenerateFromRValAsnPre(TokenRValAsnPre asnPre) CompValu lVal = GenerateFromLVal(asnPre.lVal); // Make up a temp to put result in. - CompValuTemp result = new CompValuTemp(lVal.type, this); + CompValuTemp result = new (lVal.type, this); // Prepare to pop incremented value back into variable being incremented. lVal.PopPre(this, asnPre.lVal); @@ -4709,15 +4715,14 @@ private CompValu GenerateACall(CompValu method, CompValu[] argRVals, Token call) } } - // Inline functions know how to generate their own call. - if(method is CompValuInline) + // Inline functions know how to generate their own call. + if (method is CompValuInline inline) { - CompValuInline inline = (CompValuInline)method; inline.declInline.CodeGen(this, call, result, argRVals); return result; } - // Push whatever the function/method needs as a this argument, if anything. + // Push whatever the function/method needs as a this argument, if anything. method.CallPre(this, call); // Push the script-visible args, left-to-right. @@ -4752,7 +4757,7 @@ public CompValu Trivialize(CompValu operand, Token errorAt) { if(operand.IsReadTrivial(this, errorAt)) return operand; - CompValuTemp temp = new CompValuTemp(operand.type, this); + CompValuTemp temp = new (operand.type, this); operand.PushVal(this, errorAt); temp.Pop(this, errorAt); return temp; @@ -4771,9 +4776,9 @@ private CompValu GenerateFromRValCast(TokenRValCast cast) // instaead of 'string ToString(float x)' or anything else TokenType[] argsig = null; TokenType outType = cast.castTo; - if(outType is TokenTypeSDTypeDelegate) + if(outType is TokenTypeSDTypeDelegate TokenTypeSDTypeDelegateoutType) { - argsig = ((TokenTypeSDTypeDelegate)outType).decl.GetArgTypes(); + argsig = TokenTypeSDTypeDelegateoutType.decl.GetArgTypes(); } // Generate the value that is being cast. @@ -4796,9 +4801,8 @@ private CompValu GenerateFromRValCast(TokenRValCast cast) */ private CompValu GenerateFromRValCondExpr(TokenRValCondExpr rValCondExpr) { - bool condVal; CompValu condValu = GenerateFromRVal(rValCondExpr.condExpr); - if(IsConstBoolExpr(condValu, out condVal)) + if (IsConstBoolExpr(condValu, out bool condVal)) { return GenerateFromRVal(condVal ? rValCondExpr.trueExpr : rValCondExpr.falseExpr); } @@ -4824,7 +4828,7 @@ private CompValu GenerateFromRValCondExpr(TokenRValCondExpr rValCondExpr) } ilGen.MarkLabel(doneLabel); - CompValuTemp retRVal = new CompValuTemp(trueValu.type, this); + CompValuTemp retRVal = new (trueValu.type, this); retRVal.Pop(this, rValCondExpr); return retRVal; } @@ -4833,7 +4837,7 @@ private CompValu GenerateFromRValCondExpr(TokenRValCondExpr rValCondExpr) * @brief Constant in the script somewhere * @returns where the constants value is stored */ - private CompValu GenerateFromRValConst(TokenRValConst rValConst) + private static CompValu GenerateFromRValConst(TokenRValConst rValConst) { switch(rValConst.type) { @@ -4884,7 +4888,7 @@ private CompValu GenerateFromRValList(TokenRValList rValList) } // This is the temp that will hold the created list. - CompValuTemp newList = new CompValuTemp(new TokenTypeList(rValList.rVal), this); + CompValuTemp newList = new (new TokenTypeList(rValList.rVal), this); // Create a temp object[] array to hold all the initial values. ilGen.Emit(rValList, OpCodes.Ldc_I4, rValList.nItems); @@ -4917,12 +4921,17 @@ private CompValu GenerateFromRValList(TokenRValList rValList) ilGen.Emit(val, OpCodes.Newobj, lslFloatConstructorInfo); ilGen.Emit(val, OpCodes.Box, typeof(LSL_Float)); } - else if(eRVal.type is TokenTypeInt) + else if (eRVal.type is TokenTypeInt) + { + ilGen.Emit(val, OpCodes.Newobj, lslIntegerConstructorInfo); + ilGen.Emit(val, OpCodes.Box, typeof(LSL_Integer)); + } + else if (eRVal.type is TokenTypeBool) { ilGen.Emit(val, OpCodes.Newobj, lslIntegerConstructorInfo); ilGen.Emit(val, OpCodes.Box, typeof(LSL_Integer)); } - else if((eRVal.type is TokenTypeKey) || (eRVal.type is TokenTypeStr)) + else if ((eRVal.type is TokenTypeKey) || (eRVal.type is TokenTypeStr)) { ilGen.Emit(val, OpCodes.Newobj, lslStringConstructorInfo); ilGen.Emit(val, OpCodes.Box, typeof(LSL_String)); @@ -4981,7 +4990,7 @@ private CompValu MallocAndInitArray(TokenType arrayType, TokenList values) // Output a call to malloc the array with all default values // array = ArrayType.$new (dimSizes[0], dimSizes[1], ...) - CompValuTemp array = new CompValuTemp(arrayType, this); + CompValuTemp array = new (arrayType, this); PushXMRInst(); for(int k = 0; k < rank; k++) { @@ -5028,9 +5037,8 @@ private static void FillInDimSizes(int[] dimSizes, int dimNo, int rank, TokenLis // its size is the size of the largest initializer list at the next inner level foreach(Token val in values.tl) { - if(val is TokenList) + if (val is TokenList subvals) { - TokenList subvals = (TokenList)val; FillInDimSizes(dimSizes, dimNo, rank, subvals); } } @@ -5057,32 +5065,31 @@ private void FillInInitVals(CompValu array, TokenDeclVar setMeth, int[] subscrip { CompValu initValue = null; - // If it is a sublist, process it. - // If we don't have enough subscripts yet, hopefully that sublist will have enough. - // If we already have enough subscripts, then that sublist can be for an element of this supposedly jagged array. - if(val is TokenList) + // If it is a sublist, process it. + // If we don't have enough subscripts yet, hopefully that sublist will have enough. + // If we already have enough subscripts, then that sublist can be for an element of this supposedly jagged array. + if (val is TokenList sublist) { - TokenList sublist = (TokenList)val; - if(dimNo + 1 < rank) + if (dimNo + 1 < rank) { - // We don't have enough subscripts yet, hopefully the sublist has the rest. + // We don't have enough subscripts yet, hopefully the sublist has the rest. FillInInitVals(array, setMeth, subscripts, dimNo + 1, rank, sublist, eleType); } - else if((eleType is TokenTypeSDTypeClass) && (((TokenTypeSDTypeClass)eleType).decl.arrayOfType == null)) + else if ((eleType is TokenTypeSDTypeClass eleTypeclass) && (eleTypeclass.decl.arrayOfType is null)) { - // If we aren't a jagged array either, we can't do anything with the sublist. + // If we aren't a jagged array either, we can't do anything with the sublist. ErrorMsg(val, "too many brace levels"); } else { - // We are a jagged array, so malloc a subarray and initialize it with the sublist. - // Then we can use that subarray to fill this array's element. + // We are a jagged array, so malloc a subarray and initialize it with the sublist. + // Then we can use that subarray to fill this array's element. initValue = MallocAndInitArray(eleType, sublist); } } - // If it is a value expression, then output code to compute the value. - if(val is TokenRVal) + // If it is a value expression, then output code to compute the value. + if (val is TokenRVal val1) { if(dimNo + 1 < rank) { @@ -5090,7 +5097,7 @@ private void FillInInitVals(CompValu array, TokenDeclVar setMeth, int[] subscrip } else { - initValue = GenerateFromRVal((TokenRVal)val); + initValue = GenerateFromRVal(val1); } } @@ -5156,7 +5163,7 @@ private CompValu GenerateFromRValThis(TokenRValThis zhis) * It is a runtime error to cast this value to any other type, eg, * we don't allow list or string variables to be null pointers. */ - private CompValu GenerateFromRValUndef(TokenRValUndef rValUndef) + private static CompValu GenerateFromRValUndef(TokenRValUndef rValUndef) { return new CompValuNull(new TokenTypeUndef(rValUndef)); } @@ -5187,10 +5194,10 @@ private CompValu GenerateFromRValInitDef(TokenRValInitDef rValInitDef) } if(type is TokenTypeRot) { - CompValuFloat x = new CompValuFloat(type, ScriptBaseClass.ZERO_ROTATION.x); - CompValuFloat y = new CompValuFloat(type, ScriptBaseClass.ZERO_ROTATION.y); - CompValuFloat z = new CompValuFloat(type, ScriptBaseClass.ZERO_ROTATION.z); - CompValuFloat s = new CompValuFloat(type, ScriptBaseClass.ZERO_ROTATION.s); + CompValuFloat x = new (type, ScriptBaseClass.ZERO_ROTATION.x); + CompValuFloat y = new (type, ScriptBaseClass.ZERO_ROTATION.y); + CompValuFloat z = new (type, ScriptBaseClass.ZERO_ROTATION.z); + CompValuFloat s = new (type, ScriptBaseClass.ZERO_ROTATION.s); return new CompValuRot(type, x, y, z, s); } if((type is TokenTypeKey) || (type is TokenTypeStr)) @@ -5199,9 +5206,9 @@ private CompValu GenerateFromRValInitDef(TokenRValInitDef rValInitDef) } if(type is TokenTypeVec) { - CompValuFloat x = new CompValuFloat(type, ScriptBaseClass.ZERO_VECTOR.x); - CompValuFloat y = new CompValuFloat(type, ScriptBaseClass.ZERO_VECTOR.y); - CompValuFloat z = new CompValuFloat(type, ScriptBaseClass.ZERO_VECTOR.z); + CompValuFloat x = new (type, ScriptBaseClass.ZERO_VECTOR.x); + CompValuFloat y = new (type, ScriptBaseClass.ZERO_VECTOR.y); + CompValuFloat z = new (type, ScriptBaseClass.ZERO_VECTOR.z); return new CompValuVec(type, x, y, z); } if(type is TokenTypeInt) @@ -5226,7 +5233,7 @@ private CompValu GenerateFromRValInitDef(TokenRValInitDef rValInitDef) } // array and list - CompValuTemp temp = new CompValuTemp(type, this); + CompValuTemp temp = new (type, this); PushDefaultValue(type); temp.Pop(this, rValInitDef, type); return temp; @@ -5252,14 +5259,14 @@ private CompValu GenerateFromRValIsType(TokenRValIsType rValIsType) */ private CompValu GenerateFromTypeExp(CompValu val, TokenTypeExp typeExp) { - if(typeExp is TokenTypeExpBinOp) + if(typeExp is TokenTypeExpBinOp op1) { - CompValu left = GenerateFromTypeExp(val, ((TokenTypeExpBinOp)typeExp).leftOp); - CompValu right = GenerateFromTypeExp(val, ((TokenTypeExpBinOp)typeExp).rightOp); - CompValuTemp result = new CompValuTemp(tokenTypeBool, this); - Token op = ((TokenTypeExpBinOp)typeExp).binOp; - left.PushVal(this, ((TokenTypeExpBinOp)typeExp).leftOp); - right.PushVal(this, ((TokenTypeExpBinOp)typeExp).rightOp); + CompValu left = GenerateFromTypeExp(val, op1.leftOp); + CompValu right = GenerateFromTypeExp(val, op1.rightOp); + CompValuTemp result = new (tokenTypeBool, this); + Token op = op1.binOp; + left.PushVal(this, op1.leftOp); + right.PushVal(this, op1.rightOp); if(op is TokenKwAnd) { ilGen.Emit(typeExp, OpCodes.And); @@ -5275,25 +5282,25 @@ private CompValu GenerateFromTypeExp(CompValu val, TokenTypeExp typeExp) result.Pop(this, typeExp); return result; } - if(typeExp is TokenTypeExpNot) + if(typeExp is TokenTypeExpNot expnot) { - CompValu interm = GenerateFromTypeExp(val, ((TokenTypeExpNot)typeExp).typeExp); - CompValuTemp result = new CompValuTemp(tokenTypeBool, this); - interm.PushVal(this, ((TokenTypeExpNot)typeExp).typeExp, tokenTypeBool); + CompValu interm = GenerateFromTypeExp(val, expnot.typeExp); + CompValuTemp result = new (tokenTypeBool, this); + interm.PushVal(this, expnot.typeExp, tokenTypeBool); ilGen.Emit(typeExp, OpCodes.Ldc_I4_1); ilGen.Emit(typeExp, OpCodes.Xor); result.Pop(this, typeExp); return result; } - if(typeExp is TokenTypeExpPar) + if(typeExp is TokenTypeExpPar TokenTypeExpPartypeExp) { - return GenerateFromTypeExp(val, ((TokenTypeExpPar)typeExp).typeExp); + return GenerateFromTypeExp(val, TokenTypeExpPartypeExp.typeExp); } - if(typeExp is TokenTypeExpType) + if(typeExp is TokenTypeExpType TokenTypeExpTypetypeExp) { - CompValuTemp result = new CompValuTemp(tokenTypeBool, this); + CompValuTemp result = new (tokenTypeBool, this); val.PushVal(this, typeExp); - ilGen.Emit(typeExp, OpCodes.Isinst, ((TokenTypeExpType)typeExp).typeToken.ToSysType()); + ilGen.Emit(typeExp, OpCodes.Isinst, TokenTypeExpTypetypeExp.typeToken.ToSysType()); ilGen.Emit(typeExp, OpCodes.Ldnull); ilGen.Emit(typeExp, OpCodes.Ceq); ilGen.Emit(typeExp, OpCodes.Ldc_I4_1); @@ -5303,7 +5310,7 @@ private CompValu GenerateFromTypeExp(CompValu val, TokenTypeExp typeExp) } if(typeExp is TokenTypeExpUndef) { - CompValuTemp result = new CompValuTemp(tokenTypeBool, this); + CompValuTemp result = new (tokenTypeBool, this); val.PushVal(this, typeExp); ilGen.Emit(typeExp, OpCodes.Ldnull); ilGen.Emit(typeExp, OpCodes.Ceq); @@ -5409,32 +5416,31 @@ public void PushDefaultValue(TokenType type) * @returns true: expression is contant and has boolean value true * false: otherwise */ - private bool IsConstBoolExprTrue(CompValu expr) + private static bool IsConstBoolExprTrue(CompValu expr) { - bool constVal; - return IsConstBoolExpr(expr, out constVal) && constVal; + return IsConstBoolExpr(expr, out bool constVal) && constVal; } - private bool IsConstBoolExpr(CompValu expr, out bool constVal) + private static bool IsConstBoolExpr(CompValu expr, out bool constVal) { - if(expr is CompValuChar) + if(expr is CompValuChar CompValuCharexpr) { - constVal = ((CompValuChar)expr).x != 0; + constVal = CompValuCharexpr.x != 0; return true; } - if(expr is CompValuFloat) + if(expr is CompValuFloat CompValuFloatexpr) { - constVal = ((CompValuFloat)expr).x != (double)0; + constVal = CompValuFloatexpr.x != 0; return true; } - if(expr is CompValuInteger) + if(expr is CompValuInteger CompValuIntegerexpr) { - constVal = ((CompValuInteger)expr).x != 0; + constVal = CompValuIntegerexpr.x != 0; return true; } - if(expr is CompValuString) + if(expr is CompValuString CompValuStringexpr) { - string s = ((CompValuString)expr).x; + string s = CompValuStringexpr.x; constVal = s != ""; if(constVal && (expr.type is TokenTypeKey)) { @@ -5454,16 +5460,16 @@ private bool IsConstBoolExpr(CompValu expr, out bool constVal) * @returns true: expression is contant and has integer value * false: otherwise */ - private bool IsConstIntExpr(CompValu expr, out int constVal) + private static bool IsConstIntExpr(CompValu expr, out int constVal) { - if(expr is CompValuChar) + if(expr is CompValuChar CompValuCharexpr) { - constVal = (int)((CompValuChar)expr).x; + constVal = (int)CompValuCharexpr.x; return true; } - if(expr is CompValuInteger) + if(expr is CompValuInteger CompValuIntegerexpr) { - constVal = ((CompValuInteger)expr).x; + constVal = CompValuIntegerexpr.x; return true; } @@ -5478,11 +5484,11 @@ private bool IsConstIntExpr(CompValu expr, out int constVal) * @returns true: expression is contant and has string value * false: otherwise */ - private bool IsConstStrExpr(CompValu expr, out string constVal) + private static bool IsConstStrExpr(CompValu expr, out string constVal) { - if(expr is CompValuString) + if(expr is CompValuString exprstring) { - constVal = ((CompValuString)expr).x; + constVal = exprstring.x; return true; } constVal = ""; @@ -5512,16 +5518,18 @@ private static VarDict CreateLegalEventHandlers() int fullArgCount = fal.vars.Length; for(i = 0; i < fullArgCount; i++) { - TokenArgDecl shortArgList = new TokenArgDecl(null); + TokenArgDecl shortArgList = new (null); for(int j = 0; j < i; j++) { TokenDeclVar var = fal.vars[j]; shortArgList.AddArg(var.type, var.name); } - TokenDeclVar shortArgProto = new TokenDeclVar(null, null, null); - shortArgProto.name = new TokenName(null, fap.GetSimpleName()); - shortArgProto.retType = fap.retType; - shortArgProto.argDecl = shortArgList; + TokenDeclVar shortArgProto = new (null, null, null) + { + name = new TokenName(null, fap.GetSimpleName()), + retType = fap.retType, + argDecl = shortArgList + }; leh.AddEntry(shortArgProto); } } @@ -5536,7 +5544,7 @@ public void EmitCallCheckRun(Token errorAt, bool stack) { if(curDeclFunc.IsFuncTrivial(this)) throw new Exception(curDeclFunc.fullName + " is supposed to be trivial"); - new CallLabel(this, errorAt); // jump here when stack restored + _ = new CallLabel(this, errorAt); // jump here when stack restored PushXMRInst(); // instance ilGen.Emit(errorAt, OpCodes.Call, stack ? checkRunStackMethInfo : checkRunQuickMethInfo); openCallLabel = null; @@ -5593,7 +5601,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) { if(inRVal.type is TokenTypeFloat) { - CompValuTemp outRVal = new CompValuTemp(new TokenTypeFloat(opcode), this); + CompValuTemp outRVal = new (new TokenTypeFloat(opcode), this); inRVal.PushVal(this, opcode, outRVal.type); // push value to negate, make sure not LSL-boxed ilGen.Emit(opcode, OpCodes.Neg); // compute the negative outRVal.Pop(this, opcode); // pop into result @@ -5601,7 +5609,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) } if(inRVal.type is TokenTypeInt) { - CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this); + CompValuTemp outRVal = new (new TokenTypeInt(opcode), this); inRVal.PushVal(this, opcode, outRVal.type); // push value to negate, make sure not LSL-boxed ilGen.Emit(opcode, OpCodes.Neg); // compute the negative outRVal.Pop(this, opcode); // pop into result @@ -5609,7 +5617,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) } if(inRVal.type is TokenTypeRot) { - CompValuTemp outRVal = new CompValuTemp(inRVal.type, this); + CompValuTemp outRVal = new (inRVal.type, this); inRVal.PushVal(this, opcode); // push rotation, then call negate routine ilGen.Emit(opcode, OpCodes.Call, lslRotationNegateMethodInfo); outRVal.Pop(this, opcode); // pop into result @@ -5617,7 +5625,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) } if(inRVal.type is TokenTypeVec) { - CompValuTemp outRVal = new CompValuTemp(inRVal.type, this); + CompValuTemp outRVal = new (inRVal.type, this); inRVal.PushVal(this, opcode); // push vector, then call negate routine ilGen.Emit(opcode, OpCodes.Call, lslVectorNegateMethodInfo); outRVal.Pop(this, opcode); // pop into result @@ -5625,7 +5633,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) } if (inRVal.type is TokenTypeBool) { - CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this); + CompValuTemp outRVal = new (new TokenTypeInt(opcode), this); inRVal.PushVal(this, opcode, outRVal.type); // push value to negate, make sure not LSL-boxed ilGen.Emit(opcode, OpCodes.Neg); // compute the negative outRVal.Pop(this, opcode); // pop into result @@ -5640,7 +5648,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) { if(inRVal.type is TokenTypeInt) { - CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this); + CompValuTemp outRVal = new (new TokenTypeInt(opcode), this); inRVal.PushVal(this, opcode, outRVal.type); // push value to negate, make sure not LSL-boxed ilGen.Emit(opcode, OpCodes.Not); // compute the complement outRVal.Pop(this, opcode); // pop into result @@ -5657,7 +5665,7 @@ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) // everything like that. if(opcode is TokenKwExclam) { - CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this); + CompValuTemp outRVal = new (new TokenTypeInt(opcode), this); inRVal.PushVal(this, opcode, tokenTypeBool); // anything converts to boolean ilGen.Emit(opcode, OpCodes.Ldc_I4_1); // then XOR with 1 to flip it ilGen.Emit(opcode, OpCodes.Xor); @@ -5676,16 +5684,15 @@ private TokenRVal LookupInitConstants(TokenRVal rVal, ref bool didOne) { // If it is a static field of a script-defined type, look it up and hopefully we find a constant there. TokenDeclVar gblVar; - if(rVal is TokenLValSField) + if (rVal is TokenLValSField lvsf) { - TokenLValSField lvsf = (TokenLValSField)rVal; - if(lvsf.baseType is TokenTypeSDTypeClass) + if (lvsf.baseType is TokenTypeSDTypeClass basetypeclass) { - TokenDeclSDTypeClass sdtClass = ((TokenTypeSDTypeClass)lvsf.baseType).decl; + TokenDeclSDTypeClass sdtClass = basetypeclass.decl; gblVar = sdtClass.members.FindExact(lvsf.fieldName.val, null); - if(gblVar != null) + if (gblVar != null) { - if(gblVar.constant && (gblVar.init is TokenRValConst)) + if (gblVar.constant && (gblVar.init is TokenRValConst)) { didOne = true; return gblVar.init; @@ -5695,8 +5702,8 @@ private TokenRVal LookupInitConstants(TokenRVal rVal, ref bool didOne) return rVal; } - // Only other thing we handle is stand-alone names. - if(!(rVal is TokenLValName)) + // Only other thing we handle is stand-alone names. + if (rVal is not TokenLValName) return rVal; string name = ((TokenLValName)rVal).name.val; @@ -5754,12 +5761,11 @@ private TokenRVal LookupBodyConstants(TokenRVal rVal, ref bool didOne) { // If it is a static field of a script-defined type, look it up and hopefully we find a constant there. TokenDeclVar gblVar; - if(rVal is TokenLValSField) + if(rVal is TokenLValSField lvsf) { - TokenLValSField lvsf = (TokenLValSField)rVal; - if(lvsf.baseType is TokenTypeSDTypeClass) + if(lvsf.baseType is TokenTypeSDTypeClass TokenTypeSDTypeClasslvsfbaseType) { - TokenDeclSDTypeClass sdtClass = ((TokenTypeSDTypeClass)lvsf.baseType).decl; + TokenDeclSDTypeClass sdtClass = TokenTypeSDTypeClasslvsfbaseType.decl; gblVar = sdtClass.members.FindExact(lvsf.fieldName.val, null); if((gblVar != null) && gblVar.constant && (gblVar.init is TokenRValConst)) { @@ -5771,7 +5777,7 @@ private TokenRVal LookupBodyConstants(TokenRVal rVal, ref bool didOne) } // Only other thing we handle is stand-alone names. - if(!(rVal is TokenLValName)) + if(rVal is not TokenLValName) return rVal; string name = ((TokenLValName)rVal).name.val; @@ -5826,14 +5832,14 @@ private TokenRVal LookupBodyConstants(TokenRVal rVal, ref bool didOne) private static TokenRVal CompValuConst2RValConst(CompValu val, TokenRVal rVal) { - if(val is CompValuChar) - rVal = new TokenRValConst(rVal, ((CompValuChar)val).x); - if(val is CompValuFloat) - rVal = new TokenRValConst(rVal, ((CompValuFloat)val).x); - if(val is CompValuInteger) - rVal = new TokenRValConst(rVal, ((CompValuInteger)val).x); - if(val is CompValuString) - rVal = new TokenRValConst(rVal, ((CompValuString)val).x); + if(val is CompValuChar CompValuCharval) + rVal = new TokenRValConst(rVal, CompValuCharval.x); + if(val is CompValuFloat CompValuFloatval) + rVal = new TokenRValConst(rVal, CompValuFloatval.x); + if(val is CompValuInteger CompValuIntegerval) + rVal = new TokenRValConst(rVal, CompValuIntegerval.x); + if(val is CompValuString CompValuStringval) + rVal = new TokenRValConst(rVal, CompValuStringval.x); return rVal; } @@ -5914,10 +5920,12 @@ public TokenDeclVar FindNamedVar(TokenLValName lValName, TokenType[] argsig) ScriptConst scriptConst = ScriptConst.Lookup(lValName.name.val); if(scriptConst != null) { - TokenDeclVar var = new TokenDeclVar(lValName.name, null, tokenScript); - var.name = lValName.name; - var.type = scriptConst.rVal.type; - var.location = scriptConst.rVal; + TokenDeclVar var = new (lValName.name, null, tokenScript) + { + name = lValName.name, + type = scriptConst.rVal.type, + location = scriptConst.rVal + }; return var; } } @@ -5945,9 +5953,8 @@ public TokenDeclVar FindNamedVar(TokenLValName lValName, TokenType[] argsig) private TokenDeclVar FindInterfaceMember(TokenTypeSDTypeInterface sdtType, TokenName name, TokenType[] argsig, ref CompValu baseRVal) { TokenDeclSDTypeInterface sdtDecl = sdtType.decl; - TokenDeclSDTypeInterface impl; - TokenDeclVar declVar = sdtDecl.FindIFaceMember(this, name, argsig, out impl); - if((declVar != null) && (impl != sdtDecl)) + TokenDeclVar declVar = sdtDecl.FindIFaceMember(this, name, argsig, out TokenDeclSDTypeInterface impl); + if ((declVar != null) && (impl != sdtDecl)) { // Accessing a method or propterty of another interface that the primary interface says it implements. // In this case, we have to cast from the primary interface to that secondary interface. @@ -5976,7 +5983,7 @@ private TokenDeclVar FindInterfaceMember(TokenTypeSDTypeInterface sdtType, Token TokenType subIntfType = impl.MakeRefToken(name); // make a temp variable of the secondary interface type - CompValuTemp castBase = new CompValuTemp(subIntfType, this); + CompValuTemp castBase = new (subIntfType, this); // output code to cast from the primary interface to the secondary interface // this is 2 basic steps: @@ -6209,15 +6216,19 @@ private void CheckAccess(TokenDeclVar var, Token errorAt) public static string ArgSigString(TokenType[] argsig) { if(argsig == null) - return ""; - StringBuilder sb = new StringBuilder("("); - for(int i = 0; i < argsig.Length; i++) + return string.Empty; + if(argsig.Length == 0) + return "()"; + + StringBuilder sb = new (); + sb.Append('('); + for (int i = 0; i < argsig.Length; i++) { if(i > 0) - sb.Append(","); + sb.Append(','); sb.Append(argsig[i].ToString()); } - sb.Append(")"); + sb.Append(')'); return sb.ToString(); } @@ -6246,12 +6257,8 @@ public void ErrorMsg(Token token, string message) */ public static MethodInfo GetStaticMethod(Type owner, string name, Type[] args) { - MethodInfo mi = owner.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, args, null); - if(mi == null) - { - throw new Exception("undefined method " + owner.ToString() + "." + name); - } - return mi; + return owner.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, args, null) ?? + throw new Exception("undefined method " + owner.ToString() + "." + name); } // http://wiki.secondlife.com/wiki/Rotation 'negate a rotation' says just negate .s component @@ -6308,9 +6315,6 @@ public ScriptUndefinedStateException(string stateName) : base("undefined state " { this.stateName = stateName; } - protected ScriptUndefinedStateException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } /** @@ -6334,13 +6338,6 @@ private ScriptThrownException(object thrown) : base(thrown.ToString()) { this.thrown = thrown; } - - /** - * @brief Used by serialization/deserialization. - */ - protected ScriptThrownException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } /** @@ -6354,9 +6351,6 @@ public ScriptChangeStateException(int newState) { this.newState = newState; } - protected ScriptChangeStateException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } /** @@ -6373,7 +6367,7 @@ public class ScriptRestoreCatchException: Exception { // old code uses these - private object e; + private readonly object e; public ScriptRestoreCatchException(object e) { this.e = e; @@ -6382,13 +6376,13 @@ public static object Unwrap(object o) { if(o is IXMRUncatchable) return null; - if(o is ScriptRestoreCatchException) - return ((ScriptRestoreCatchException)o).e; + if(o is ScriptRestoreCatchException oe) + return oe.e; return o; } // new code uses these - private Exception ee; + private readonly Exception ee; public ScriptRestoreCatchException(Exception ee) { this.ee = ee; @@ -6397,8 +6391,8 @@ public static Exception Unwrap(Exception oo) { if(oo is IXMRUncatchable) return null; - if(oo is ScriptRestoreCatchException) - return ((ScriptRestoreCatchException)oo).ee; + if(oo is ScriptRestoreCatchException ooe) + return ooe.ee; return oo; } } @@ -6407,9 +6401,6 @@ public static Exception Unwrap(Exception oo) public class ScriptBadCallNoException: Exception { public ScriptBadCallNoException(int callNo) : base("bad callNo " + callNo) { } - protected ScriptBadCallNoException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } public class CVVMismatchException: Exception diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs index e53e350060f..9d7d6a452ff 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs @@ -83,7 +83,7 @@ public ScriptObjCode Compile() } if (tokenBegin == null) { - m_log.Debug ("[YEngine]: parsing errors on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); + m_log.Debug ($"[YEngine]: parsing errors at (primName:scriptName): {m_DescName} (partid: {m_PartUUID})"); return null; } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs index 5b762986c77..413b9fc2ada 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; using System.Reflection; -using System.Text; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; @@ -54,15 +53,14 @@ public class ScriptConst */ public static ScriptConst Lookup(string name) { - ScriptConst sc; - if(!scriptConstants.TryGetValue(name, out sc)) - sc = null; - return sc; + if(scriptConstants.TryGetValue(name, out ScriptConst sc)) + return sc; + return null; } private static Dictionary Init() { - Dictionary sc = new Dictionary(); + Dictionary sc = new(); // For every event code, define XMREVENTCODE_ and XMREVENTMASKn_ symbols. for(int i = 0; i < 64; i++) @@ -72,12 +70,12 @@ private static Dictionary Init() string s = ((ScriptEventCode)i).ToString(); if((s.Length > 0) && (s[0] >= 'a') && (s[0] <= 'z')) { - new ScriptConst(sc, + _ = new ScriptConst(sc, "XMREVENTCODE_" + s, new CompValuInteger(new TokenTypeInt(null), i)); int n = i / 32 + 1; int m = 1 << (i % 32); - new ScriptConst(sc, + _ = new ScriptConst(sc, "XMREVENTMASK" + n + "_" + s, new CompValuInteger(new TokenTypeInt(null), m)); } @@ -100,7 +98,7 @@ private static Dictionary Init() // this one accepts only upper-case named fields public static void AddInterfaceConstants(Dictionary sc, FieldInfo[] allFields) { - List ucfs = new List(allFields.Length); + List ucfs = new(allFields.Length); foreach(FieldInfo f in allFields) { string fieldName = f.Name; @@ -119,8 +117,7 @@ public static void AddInterfaceConstants(Dictionary sc, Fie // this one accepts all fields given to it public static void AddInterfaceConstants(Dictionary sc, IEnumerator fields) { - if(sc == null) - sc = scriptConstants; + sc ??= scriptConstants; for(fields.Reset(); fields.MoveNext();) { @@ -167,7 +164,7 @@ public static void AddInterfaceConstants(Dictionary sc, IEn } // Add to dictionary. - new ScriptConst(sc, constField.Name, cv); + _ = new ScriptConst(sc, constField.Name, cv); } } @@ -179,84 +176,81 @@ public static void AddInterfaceConstants(Dictionary sc, IEn */ public static ScriptConst AddConstant(string name, object value) { - CompValu cv = null; - - if(value is char) + CompValu cv; + if(value is char cvalue) { - cv = new CompValuChar(new TokenTypeChar(null), (char)value); + cv = new CompValuChar(new TokenTypeChar(null), cvalue); } - else if (value is double) + else if (value is double dvalue) { - cv = new CompValuFloat(new TokenTypeFloat(null), (double)(double)value); + cv = new CompValuFloat(new TokenTypeFloat(null), dvalue); } - else if (value is float) + else if (value is float fvalue) { - cv = new CompValuFloat(new TokenTypeFloat(null), (double)(float)value); + cv = new CompValuFloat(new TokenTypeFloat(null), (double)fvalue); } - else if (value is int) + else if (value is int ivalue) { - cv = new CompValuInteger(new TokenTypeInt(null), (int)value); + cv = new CompValuInteger(new TokenTypeInt(null), ivalue); } - else if (value is string) + else if (value is string svalue) { - cv = new CompValuString(new TokenTypeStr(null), (string)value); + cv = new CompValuString(new TokenTypeStr(null), svalue); } - else if (value is LSL_Float) + else if (value is LSL_Float lfvalue) { - cv = new CompValuFloat(new TokenTypeFloat(null), (double)((LSL_Float)value).value); + cv = new CompValuFloat(new TokenTypeFloat(null), lfvalue.value); } - else if (value is LSL_Integer) + else if (value is LSL_Integer livalue) { - cv = new CompValuInteger(new TokenTypeInt(null), ((LSL_Integer)value).value); + cv = new CompValuInteger(new TokenTypeInt(null), livalue.value); } - else if (value is LSL_Rotation) + else if (value is LSL_Rotation r) { - LSL_Rotation r = (LSL_Rotation)value; CompValu x = new CompValuFloat(new TokenTypeFloat(null), r.x); CompValu y = new CompValuFloat(new TokenTypeFloat(null), r.y); CompValu z = new CompValuFloat(new TokenTypeFloat(null), r.z); CompValu s = new CompValuFloat(new TokenTypeFloat(null), r.s); cv = new CompValuRot(new TokenTypeRot(null), x, y, z, s); } - else if (value is LSL_String) + else if (value is LSL_String lsvalue) { - cv = new CompValuString(new TokenTypeStr(null), (string)(LSL_String)value); + cv = new CompValuString(new TokenTypeStr(null), lsvalue.m_string); } - else if (value is LSL_Vector) + else if (value is LSL_Vector v) { - LSL_Vector v = (LSL_Vector)value; CompValu x = new CompValuFloat(new TokenTypeFloat(null), v.x); CompValu y = new CompValuFloat(new TokenTypeFloat(null), v.y); CompValu z = new CompValuFloat(new TokenTypeFloat(null), v.z); cv = new CompValuVec(new TokenTypeVec(null), x, y, z); } - else if (value is OpenMetaverse.Quaternion) + else if (value is OpenMetaverse.Quaternion or) { - OpenMetaverse.Quaternion r = (OpenMetaverse.Quaternion)value; - CompValu x = new CompValuFloat(new TokenTypeFloat(null), r.X); - CompValu y = new CompValuFloat(new TokenTypeFloat(null), r.Y); - CompValu z = new CompValuFloat(new TokenTypeFloat(null), r.Z); - CompValu s = new CompValuFloat(new TokenTypeFloat(null), r.W); + CompValu x = new CompValuFloat(new TokenTypeFloat(null), or.X); + CompValu y = new CompValuFloat(new TokenTypeFloat(null), or.Y); + CompValu z = new CompValuFloat(new TokenTypeFloat(null), or.Z); + CompValu s = new CompValuFloat(new TokenTypeFloat(null), or.W); cv = new CompValuRot(new TokenTypeRot(null), x, y, z, s); } - else if (value is OpenMetaverse.UUID) + else if (value is OpenMetaverse.UUID uvalue) { - cv = new CompValuString(new TokenTypeKey(null), value.ToString()); + cv = new CompValuString(new TokenTypeKey(null), uvalue.ToString()); } - else if (value is OpenMetaverse.Vector3) + else if (value is OpenMetaverse.Vector3 ov) { - OpenMetaverse.Vector3 v = (OpenMetaverse.Vector3)value; - CompValu x = new CompValuFloat(new TokenTypeFloat(null), v.X); - CompValu y = new CompValuFloat(new TokenTypeFloat(null), v.Y); - CompValu z = new CompValuFloat(new TokenTypeFloat(null), v.Z); + CompValu x = new CompValuFloat(new TokenTypeFloat(null), ov.X); + CompValu y = new CompValuFloat(new TokenTypeFloat(null), ov.Y); + CompValu z = new CompValuFloat(new TokenTypeFloat(null), ov.Z); cv = new CompValuVec(new TokenTypeVec(null), x, y, z); } - - if(cv == null) + else throw new Exception("bad type " + value.GetType().Name); - return new ScriptConst(scriptConstants, name, cv); + + var sc = new ScriptConst(name, cv); + scriptConstants[name] = sc; + return sc; } /* @@ -267,7 +261,12 @@ public static ScriptConst AddConstant(string name, object value) private ScriptConst(Dictionary lc, string name, CompValu rVal) { + this.name = name; + this.rVal = rVal; lc.Add(name, this); + } + private ScriptConst(string name, CompValu rVal) + { this.name = name; this.rVal = rVal; } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptInlines.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptInlines.cs index 51fab38d6d2..d7df7d7829e 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptInlines.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptInlines.cs @@ -63,6 +63,8 @@ private static VarDict CreateDictionary() /* * For those listed in noCheckRun, we just generate the call (simple computations). * For all others, we generate the call then a call to CheckRun(). + * note to self: a change here implies change on magic numbers to invalidate older code and + * script state */ noCheckRuns = new HashSet() { "llBase64ToString", @@ -81,8 +83,6 @@ private static VarDict CreateDictionary() "llList2Float", "llList2Integer", "llList2Key", - "llList2List", - "llList2ListStrided", "llList2Rot", "llList2String", "llList2Vector", @@ -151,25 +151,7 @@ private static VarDict CreateDictionary() VarDict ifd = new VarDict(false); Type[] oneDoub = new Type[] { typeof(double) }; Type[] twoDoubs = new Type[] { typeof(double), typeof(double) }; - - /* - * Mono generates an FPU instruction for many math calls. - */ - /* just use lsl api alos this have cast issues - new TokenDeclInline_LLAbs(ifd); - new TokenDeclInline_Math(ifd, "llAcos(float)", "Acos", oneDoub); - new TokenDeclInline_Math(ifd, "llAsin(float)", "Asin", oneDoub); - new TokenDeclInline_Math(ifd, "llAtan2(float,float)", "Atan2", twoDoubs); - new TokenDeclInline_Math(ifd, "llCos(float)", "Cos", oneDoub); - new TokenDeclInline_Math(ifd, "llFabs(float)", "Abs", oneDoub); - new TokenDeclInline_Math(ifd, "llLog(float)", "Log", oneDoub); - new TokenDeclInline_Math(ifd, "llLog10(float)", "Log10", oneDoub); - new TokenDeclInline_Math(ifd, "llPow(float,float)", "Pow", twoDoubs); - new TokenDeclInline_LLRound(ifd); - new TokenDeclInline_Math(ifd, "llSin(float)", "Sin", oneDoub); - new TokenDeclInline_Math(ifd, "llSqrt(float)", "Sqrt", oneDoub); - new TokenDeclInline_Math(ifd, "llTan(float)", "Tan", oneDoub); - */ + /* * Something weird about the code generation for these calls, so they all have their own handwritten code generators. */ @@ -212,14 +194,11 @@ public static void AddInterfaceMethods(VarDict ifd, MethodInfo[] ifaceMethods, F // this one accepts all methods given to it public static void AddInterfaceMethods(VarDict ifd, IEnumerator ifaceMethods, FieldInfo acf) { - if(ifd == null) - ifd = inlineFunctions; + ifd ??= inlineFunctions; for(ifaceMethods.Reset(); ifaceMethods.MoveNext();) { MethodInfo ifaceMethod = ifaceMethods.Current; - string key = ifaceMethod.Name; - try { /* @@ -228,9 +207,7 @@ public static void AddInterfaceMethods(VarDict ifd, IEnumerator ifac * If function begins with xmr, assume we will not call CheckRun() * Otherwise, assume we will call CheckRun() */ - bool dcr = !key.StartsWith("xmr"); - if(dcr && noCheckRuns.Contains(key)) - dcr = false; + bool dcr = !(ifaceMethod.Name.StartsWith("xmr") || noCheckRuns.Contains(ifaceMethod.Name)); /* * Add function to dictionary. @@ -305,8 +282,7 @@ protected TokenDeclInline(VarDict ifd, triviality = (doCheckRun || isTaggedCallsCheckRun) ? Triviality.complex : Triviality.trivial; location = new CompValuInline(this); - if(ifd == null) - ifd = inlineFunctions; + ifd ??= inlineFunctions; ifd.AddEntry(this); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs index bbdec99e186..b72806f1385 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs @@ -163,8 +163,7 @@ public ScriptObjCode(BinaryReader objFileReader, TextWriter asmFileWriter, TextW } finally { - if(objectTokens != null) - objectTokens.Close(); + objectTokens?.Close(); } // We enter all script event handler methods in the ScriptEventHandler table. diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs index 6ab0bb5763b..0fda5338a00 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs @@ -60,15 +60,12 @@ public enum ScriptObjWriterCode: byte public class ScriptObjWriter: ScriptMyILGen { - private static Dictionary opCodes = PopulateOpCodes(); - private static Dictionary string2Type = PopulateS2T(); - private static Dictionary type2String = PopulateT2S(); + private static readonly Dictionary opCodes = PopulateOpCodes(); + private static readonly Dictionary string2Type = PopulateS2T(); + private static readonly Dictionary type2String = PopulateT2S(); - private static MethodInfo monoGetCurrentOffset = typeof(ILGenerator).GetMethod("Mono_GetCurrentOffset", - BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, - new Type[] { typeof(ILGenerator) }, null); - - private static readonly OpCode[] opCodesLdcI4M1P8 = new OpCode[] { + private static readonly OpCode[] opCodesLdcI4M1P8 = new OpCode[] + { OpCodes.Ldc_I4_M1, OpCodes.Ldc_I4_0, OpCodes.Ldc_I4_1, OpCodes.Ldc_I4_2, OpCodes.Ldc_I4_3, OpCodes.Ldc_I4_4, OpCodes.Ldc_I4_5, OpCodes.Ldc_I4_6, OpCodes.Ldc_I4_7, OpCodes.Ldc_I4_8 }; @@ -78,18 +75,11 @@ public class ScriptObjWriter: ScriptMyILGen private int lastErrorAtLine = 0; private int lastErrorAtPosn = 0; - private Dictionary sdTypesRev = new Dictionary(); + private readonly Dictionary sdTypesRev = new (); public int labelNumber = 0; public int localNumber = 0; - private string _methName; - public string methName - { - get - { - return _methName; - } - } + public string methName { get; private set;} public Type retType; public Type[] argTypes; @@ -116,7 +106,7 @@ public string methName */ public ScriptObjWriter(TokenScript tokenScript, string methName, Type retType, Type[] argTypes, string[] argNames, BinaryWriter objFileWriter) { - this._methName = methName; + this.methName = methName; this.retType = retType; this.argTypes = argTypes; this.objFileWriter = objFileWriter; @@ -174,11 +164,13 @@ public void EndMethod() */ public ScriptMyLocal DeclareLocal(Type type, string name) { - ScriptMyLocal myLocal = new ScriptMyLocal(); - myLocal.type = type; - myLocal.name = name; - myLocal.number = localNumber++; - myLocal.isReferenced = true; // so ScriptCollector won't optimize references away + ScriptMyLocal myLocal = new () + { + type = type, + name = name, + number = localNumber++, + isReferenced = true // so ScriptCollector won't optimize references away + }; return DeclareLocal(myLocal); } public ScriptMyLocal DeclareLocal(ScriptMyLocal myLocal) @@ -195,9 +187,11 @@ public ScriptMyLocal DeclareLocal(ScriptMyLocal myLocal) */ public ScriptMyLabel DefineLabel(string name) { - ScriptMyLabel myLabel = new ScriptMyLabel(); - myLabel.name = name; - myLabel.number = labelNumber++; + ScriptMyLabel myLabel = new() + { + name = name, + number = labelNumber++ + }; return DefineLabel(myLabel); } public ScriptMyLabel DefineLabel(ScriptMyLabel myLabel) @@ -282,7 +276,7 @@ public void Emit(Token errorAt, OpCode opcode, ScriptMyLabel[] myLabels) public void Emit(Token errorAt, OpCode opcode, ScriptObjWriter method) { if(method == null) - throw new ArgumentNullException("method"); + throw new ArgumentNullException(nameof(method)); objFileWriter.Write((byte)ScriptObjWriterCode.EmitMethodInt); WriteOpCode(errorAt, opcode); objFileWriter.Write(method.methName); @@ -380,15 +374,15 @@ public static void TheEnd(BinaryWriter objFileWriter) public static void CreateObjCode(Dictionary sdTypes, BinaryReader objReader, ScriptObjCode scriptObjCode, ObjectTokens objectTokens) { - Dictionary methods = new Dictionary(); + Dictionary methods = new (); DynamicMethod method = null; ILGenerator ilGen = null; - Dictionary labels = new Dictionary(); - Dictionary locals = new Dictionary(); - Dictionary labelNames = new Dictionary(); - Dictionary localNames = new Dictionary(); + Dictionary labels = new (); + Dictionary locals = new (); + Dictionary labelNames = new (); + Dictionary localNames = new (); object[] ilGenArg = new object[1]; - int offset = 0; + int offset; Dictionary srcLocs = null; string srcFile = ""; int srcLine = 0; @@ -397,11 +391,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi while(true) { // Get IL instruction offset at beginning of instruction. - offset = 0; - if((ilGen != null) && (monoGetCurrentOffset != null)) - { - offset = (int)monoGetCurrentOffset.Invoke(null, ilGenArg); - } + offset = ilGen is null ? 0 : ilGen.ILOffset; // Read and decode next internal format code from input file (.xmrobj file). ScriptObjWriterCode code = (ScriptObjWriterCode)objReader.ReadByte(); @@ -428,8 +418,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi localNames.Clear(); srcLocs = new Dictionary(); - if(objectTokens != null) - objectTokens.BegMethod(method); + objectTokens?.BegMethod(method); break; } @@ -442,8 +431,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi ilGenArg[0] = null; scriptObjCode.EndMethod(method, srcLocs); srcLocs = null; - if(objectTokens != null) - objectTokens.EndMethod(); + objectTokens?.EndMethod(); break; } @@ -455,8 +443,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi labels.Add(number, ilGen.DefineLabel()); labelNames.Add(number, name + "_" + number.ToString()); - if(objectTokens != null) - objectTokens.DefineLabel(number, name); + objectTokens?.DefineLabel(number, name); break; } @@ -470,8 +457,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi locals.Add(number, ilGen.DeclareLocal(syType)); localNames.Add(number, name + "_" + number.ToString()); - if(objectTokens != null) - objectTokens.DefineLocal(number, name, type, syType); + objectTokens?.DefineLocal(number, name, type, syType); break; } @@ -492,8 +478,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi argNames[i] = objReader.ReadString(); } methods.Add(methName, new DynamicMethod(methName, retType, argTypes)); - if(objectTokens != null) - objectTokens.DefineMethod(methName, retType, argTypes, argNames); + objectTokens?.DefineMethod(methName, retType, argTypes, argNames); break; } @@ -504,8 +489,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi ilGen.MarkLabel(labels[number]); - if(objectTokens != null) - objectTokens.MarkLabel(offset, number); + objectTokens?.MarkLabel(offset, number); break; } @@ -513,8 +497,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi case ScriptObjWriterCode.BegExcBlk: { ilGen.BeginExceptionBlock(); - if(objectTokens != null) - objectTokens.BegExcBlk(offset); + objectTokens?.BegExcBlk(offset); break; } @@ -522,24 +505,21 @@ public static void CreateObjCode(Dictionary sdTypes, Bi { Type excType = GetTypeFromStr(sdTypes, objReader.ReadString()); ilGen.BeginCatchBlock(excType); - if(objectTokens != null) - objectTokens.BegCatBlk(offset, excType); + objectTokens?.BegCatBlk(offset, excType); break; } case ScriptObjWriterCode.BegFinBlk: { ilGen.BeginFinallyBlock(); - if(objectTokens != null) - objectTokens.BegFinBlk(offset); + objectTokens?.BegFinBlk(offset); break; } case ScriptObjWriterCode.EndExcBlk: { ilGen.EndExceptionBlock(); - if(objectTokens != null) - objectTokens.EndExcBlk(offset); + objectTokens?.EndExcBlk(offset); break; } @@ -551,8 +531,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode); - if(objectTokens != null) - objectTokens.EmitNull(offset, opCode); + objectTokens?.EmitNull(offset, opCode); break; } @@ -567,8 +546,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, field); - if(objectTokens != null) - objectTokens.EmitField(offset, opCode, field); + objectTokens?.EmitField(offset, opCode, field); break; } @@ -580,8 +558,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, locals[number]); - if(objectTokens != null) - objectTokens.EmitLocal(offset, opCode, number); + objectTokens?.EmitLocal(offset, opCode, number); break; } @@ -595,8 +572,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, type); - if(objectTokens != null) - objectTokens.EmitType(offset, opCode, type); + objectTokens?.EmitType(offset, opCode, type); break; } @@ -609,8 +585,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, labels[number]); - if(objectTokens != null) - objectTokens.EmitLabel(offset, opCode, number); + objectTokens?.EmitLabel(offset, opCode, number); break; } @@ -630,8 +605,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, lbls); - if(objectTokens != null) - objectTokens.EmitLabels(offset, opCode, nums); + objectTokens?.EmitLabels(offset, opCode, nums); break; } @@ -652,8 +626,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, methInfo); - if(objectTokens != null) - objectTokens.EmitMethod(offset, opCode, methInfo); + objectTokens?.EmitMethod(offset, opCode, methInfo); break; } @@ -668,8 +641,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, methInfo); - if(objectTokens != null) - objectTokens.EmitMethod(offset, opCode, methInfo); + objectTokens?.EmitMethod(offset, opCode, methInfo); break; } @@ -689,8 +661,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, ctorInfo); - if(objectTokens != null) - objectTokens.EmitCtor(offset, opCode, ctorInfo); + objectTokens?.EmitCtor(offset, opCode, ctorInfo); break; } @@ -707,8 +678,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, value); - if(objectTokens != null) - objectTokens.EmitDouble(offset, opCode, value); + objectTokens?.EmitDouble(offset, opCode, value); break; } @@ -724,8 +694,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, value); - if(objectTokens != null) - objectTokens.EmitFloat(offset, opCode, value); + objectTokens?.EmitFloat(offset, opCode, value); break; } @@ -742,8 +711,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi { opCode = opCodesLdcI4M1P8[value + 1]; ilGen.Emit(opCode); - if(objectTokens != null) - objectTokens.EmitNull(offset, opCode); + objectTokens?.EmitNull(offset, opCode); break; } if((value >= 0) && (value <= 127)) @@ -755,9 +723,9 @@ public static void CreateObjCode(Dictionary sdTypes, Bi } ilGen.Emit(opCode, value); - pemitint: - if(objectTokens != null) - objectTokens.EmitInteger(offset, opCode, value); + + pemitint: + objectTokens?.EmitInteger(offset, opCode, value); break; } @@ -769,8 +737,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); ilGen.Emit(opCode, value); - if(objectTokens != null) - objectTokens.EmitString(offset, opCode, value); + objectTokens?.EmitString(offset, opCode, value); break; } @@ -786,7 +753,7 @@ public static void CreateObjCode(Dictionary sdTypes, Bi */ private static Dictionary PopulateOpCodes() { - Dictionary opCodeDict = new Dictionary(); + Dictionary opCodeDict = new (); FieldInfo[] fields = typeof(OpCodes).GetFields(); for(int i = 0; i < fields.Length; i++) { @@ -850,11 +817,12 @@ private static OpCode ReadOpCode(BinaryReader objReader, ref string srcFile, ref */ private static void SaveSrcLoc(Dictionary srcLocs, int offset, string srcFile, int srcLine, int srcPosn) { - ScriptSrcLoc srcLoc = new ScriptSrcLoc(); - srcLoc.file = srcFile; - srcLoc.line = srcLine; - srcLoc.posn = srcPosn; - srcLocs[offset] = srcLoc; + srcLocs[offset] = new ScriptSrcLoc() + { + file = srcFile, + line = srcLine, + posn = srcPosn + }; } /** @@ -864,52 +832,51 @@ private static void SaveSrcLoc(Dictionary srcLocs, int offset */ private static Dictionary PopulateS2T() { - Dictionary s2t = new Dictionary(); - - s2t.Add("badcallx", typeof(ScriptBadCallNoException)); - s2t.Add("binopstr", typeof(BinOpStr)); - s2t.Add("bool", typeof(bool)); - s2t.Add("char", typeof(char)); - s2t.Add("delegate", typeof(Delegate)); - s2t.Add("delarr[]", typeof(Delegate[])); - s2t.Add("double", typeof(double)); - s2t.Add("exceptn", typeof(Exception)); - s2t.Add("float", typeof(float)); - s2t.Add("htlist", typeof(HeapTrackerList)); - s2t.Add("htobject", typeof(HeapTrackerObject)); - s2t.Add("htstring", typeof(HeapTrackerString)); - s2t.Add("inlfunc", typeof(CompValuInline)); - s2t.Add("int", typeof(int)); - s2t.Add("int*", typeof(int).MakeByRefType()); - s2t.Add("intrlokd", typeof(System.Threading.Interlocked)); - s2t.Add("lslfloat", typeof(LSL_Float)); - s2t.Add("lslint", typeof(LSL_Integer)); - s2t.Add("lsllist", typeof(LSL_List)); - s2t.Add("lslrot", typeof(LSL_Rotation)); - s2t.Add("lslstr", typeof(LSL_String)); - s2t.Add("lslvec", typeof(LSL_Vector)); - s2t.Add("math", typeof(Math)); - s2t.Add("midround", typeof(MidpointRounding)); - s2t.Add("object", typeof(object)); - s2t.Add("object*", typeof(object).MakeByRefType()); - s2t.Add("object[]", typeof(object[])); - s2t.Add("scrbase", typeof(ScriptBaseClass)); - s2t.Add("scrcode", typeof(ScriptCodeGen)); - s2t.Add("sdtclobj", typeof(XMRSDTypeClObj)); - s2t.Add("string", typeof(string)); - s2t.Add("typecast", typeof(TypeCast)); - s2t.Add("undstatx", typeof(ScriptUndefinedStateException)); - s2t.Add("void", typeof(void)); - s2t.Add("xmrarray", typeof(XMR_Array)); - s2t.Add("xmrinst", typeof(XMRInstAbstract)); - - return s2t; + return new Dictionary + { + { "badcallx", typeof(ScriptBadCallNoException) }, + { "binopstr", typeof(BinOpStr) }, + { "bool", typeof(bool) }, + { "char", typeof(char) }, + { "delegate", typeof(Delegate) }, + { "delarr[]", typeof(Delegate[]) }, + { "double", typeof(double) }, + { "exceptn", typeof(Exception) }, + { "float", typeof(float) }, + { "htlist", typeof(HeapTrackerList) }, + { "htobject", typeof(HeapTrackerObject) }, + { "htstring", typeof(HeapTrackerString) }, + { "inlfunc", typeof(CompValuInline) }, + { "int", typeof(int) }, + { "int*", typeof(int).MakeByRefType() }, + { "intrlokd", typeof(System.Threading.Interlocked) }, + { "lslfloat", typeof(LSL_Float) }, + { "lslint", typeof(LSL_Integer) }, + { "lsllist", typeof(LSL_List) }, + { "lslrot", typeof(LSL_Rotation) }, + { "lslstr", typeof(LSL_String) }, + { "lslvec", typeof(LSL_Vector) }, + { "math", typeof(Math) }, + { "midround", typeof(MidpointRounding) }, + { "object", typeof(object) }, + { "object*", typeof(object).MakeByRefType() }, + { "object[]", typeof(object[]) }, + { "scrbase", typeof(ScriptBaseClass) }, + { "scrcode", typeof(ScriptCodeGen) }, + { "sdtclobj", typeof(XMRSDTypeClObj) }, + { "string", typeof(string) }, + { "typecast", typeof(TypeCast) }, + { "undstatx", typeof(ScriptUndefinedStateException) }, + { "void", typeof(void) }, + { "xmrarray", typeof(XMR_Array) }, + { "xmrinst", typeof(XMRInstAbstract) } + }; } private static Dictionary PopulateT2S() { Dictionary s2t = PopulateS2T(); - Dictionary t2s = new Dictionary(); + Dictionary t2s = new (); foreach(KeyValuePair kvp in s2t) { t2s.Add(kvp.Value, kvp.Key); @@ -936,14 +903,12 @@ private string GetStrFromType(Type t) } private string GetStrFromTypeWork(Type t) { - string s; - // internal fixed types like int and xmrarray etc - if(type2String.TryGetValue(t, out s)) + if (type2String.TryGetValue(t, out string s)) return s; // script-defined types - if(sdTypesRev.TryGetValue(t, out s)) + if (sdTypesRev.TryGetValue(t, out s)) return "sdt$" + s; // inline function types @@ -957,15 +922,13 @@ private string GetStrFromTypeWork(Type t) private static Type GetTypeFromStr(Dictionary sdTypes, string s) { - Type t; - // internal fixed types like int and xmrarray etc - if(string2Type.TryGetValue(s, out t)) + if (string2Type.TryGetValue(s, out Type t)) return t; // script-defined types - if(s.StartsWith("sdt$")) - return sdTypes[s.Substring(4)].GetSysType(); + if (s.StartsWith("sdt$")) + return sdTypes[s[4..]].GetSysType(); // inline function types t = TokenDeclSDTypeDelegate.TryGetInlineSysType(s); diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs index b31681ad38c..e1276c69bf4 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs @@ -72,7 +72,7 @@ public class ScriptReduce private const int ASNPR = 50; - private static Dictionary precedence = PrecedenceInit(); + private readonly static Dictionary precedence = PrecedenceInit(); private static readonly Type[] brkCloseOnly = new Type[] { typeof(TokenKwBrkClose) }; private static readonly Type[] cmpGTOnly = new Type[] { typeof(TokenKwCmpGT) }; @@ -88,58 +88,58 @@ public class ScriptReduce */ private static Dictionary PrecedenceInit() { - Dictionary p = new Dictionary(); - - // http://www.lslwiki.net/lslwiki/wakka.php?wakka=operators - - p.Add(typeof(TokenKwComma), 30); + return new Dictionary() + { + // http://www.lslwiki.net/lslwiki/wakka.php?wakka=operators - p.Add(typeof(TokenKwAsnLSh), ASNPR); // all assignment operators of equal precedence - p.Add(typeof(TokenKwAsnRSh), ASNPR); // ... so they get processed strictly right-to-left - p.Add(typeof(TokenKwAsnAdd), ASNPR); - p.Add(typeof(TokenKwAsnAnd), ASNPR); - p.Add(typeof(TokenKwAsnSub), ASNPR); - p.Add(typeof(TokenKwAsnMul), ASNPR); - p.Add(typeof(TokenKwAsnDiv), ASNPR); - p.Add(typeof(TokenKwAsnMod), ASNPR); - p.Add(typeof(TokenKwAsnOr), ASNPR); - p.Add(typeof(TokenKwAsnXor), ASNPR); - p.Add(typeof(TokenKwAssign), ASNPR); + { typeof(TokenKwComma), 30 }, - p.Add(typeof(TokenKwQMark), 60); + { typeof(TokenKwAsnLSh), ASNPR }, // all assignment operators of equal precedence + { typeof(TokenKwAsnRSh), ASNPR }, // ... so they get processed strictly right-to-left + { typeof(TokenKwAsnAdd), ASNPR }, + { typeof(TokenKwAsnAnd), ASNPR }, + { typeof(TokenKwAsnSub), ASNPR }, + { typeof(TokenKwAsnMul), ASNPR }, + { typeof(TokenKwAsnDiv), ASNPR }, + { typeof(TokenKwAsnMod), ASNPR }, + { typeof(TokenKwAsnOr), ASNPR }, + { typeof(TokenKwAsnXor), ASNPR }, + { typeof(TokenKwAssign), ASNPR }, - p.Add(typeof(TokenKwOrOrOr), 70); - p.Add(typeof(TokenKwAndAndAnd), 80); + { typeof(TokenKwQMark), 60 }, - p.Add(typeof(TokenKwOrOr), 100); + { typeof(TokenKwOrOrOr), 70 }, + { typeof(TokenKwAndAndAnd), 80 }, - p.Add(typeof(TokenKwAndAnd), 120); + { typeof(TokenKwOrOr), 100 }, - p.Add(typeof(TokenKwOr), 140); + //{ typeof(TokenKwAndAnd), 120 }, + { typeof(TokenKwAndAnd), 100 }, - p.Add(typeof(TokenKwXor), 160); + { typeof(TokenKwOr), 140 }, - p.Add(typeof(TokenKwAnd), 180); + { typeof(TokenKwXor), 160 }, - p.Add(typeof(TokenKwCmpEQ), 200); - p.Add(typeof(TokenKwCmpNE), 200); + { typeof(TokenKwAnd), 180 }, - p.Add(typeof(TokenKwCmpLT), 240); - p.Add(typeof(TokenKwCmpLE), 240); - p.Add(typeof(TokenKwCmpGT), 240); - p.Add(typeof(TokenKwCmpGE), 240); + { typeof(TokenKwCmpEQ), 200 }, + { typeof(TokenKwCmpNE), 200 }, - p.Add(typeof(TokenKwRSh), 260); - p.Add(typeof(TokenKwLSh), 260); + { typeof(TokenKwCmpLT), 240 }, + { typeof(TokenKwCmpLE), 240 }, + { typeof(TokenKwCmpGT), 240 }, + { typeof(TokenKwCmpGE), 240 }, - p.Add(typeof(TokenKwAdd), 280); - p.Add(typeof(TokenKwSub), 280); + { typeof(TokenKwRSh), 260 }, + { typeof(TokenKwLSh), 260 }, - p.Add(typeof(TokenKwMul), 320); - p.Add(typeof(TokenKwDiv), 320); - p.Add(typeof(TokenKwMod), 320); + { typeof(TokenKwAdd), 280 }, + { typeof(TokenKwSub), 280 }, - return p; + { typeof(TokenKwMul), 320 }, + { typeof(TokenKwDiv), 320 }, + { typeof(TokenKwMod), 320 } + }; } /** @@ -223,18 +223,20 @@ private ScriptReduce(TokenBegin tokenBegin) // Create a function $globalvarinit to hold all explicit // global variable initializations. - TokenDeclVar gviFunc = new TokenDeclVar(tokenBegin, null, tokenScript); + TokenDeclVar gviFunc = new (tokenBegin, null, tokenScript); gviFunc.name = new TokenName(gviFunc, "$globalvarinit"); gviFunc.retType = new TokenTypeVoid(gviFunc); gviFunc.argDecl = new TokenArgDecl(gviFunc); - TokenStmtBlock gviBody = new TokenStmtBlock(gviFunc); - gviBody.function = gviFunc; + TokenStmtBlock gviBody = new (gviFunc) + { + function = gviFunc + }; gviFunc.body = gviBody; tokenScript.globalVarInit = gviFunc; tokenScript.AddVarEntry(gviFunc); // Scan through the tokens until we reach the end. - for(Token token = tokenBegin.nextToken; !(token is TokenEnd);) + for(Token token = tokenBegin.nextToken; token is not TokenEnd;) { if(token is TokenKwSemi) { @@ -260,12 +262,12 @@ private ScriptReduce(TokenBegin tokenBegin) ((token.nextToken.nextToken is TokenKwSemi) || (token.nextToken.nextToken is TokenKwAssign))) { - TokenDeclVar var = ParseDeclVar(ref token, gviFunc); - if(var != null) + TokenDeclVar tdvar = ParseDeclVar(ref token, gviFunc); + if(tdvar != null) { // = ; - TokenLValName left = new TokenLValName(var.name, tokenScript.variablesStack); - DoVarInit(gviFunc, left, var.init); + TokenLValName left = new (tdvar.name, tokenScript.variablesStack); + DoVarInit(gviFunc, left, tdvar.init); } continue; } @@ -281,12 +283,10 @@ private ScriptReduce(TokenBegin tokenBegin) // // global function returning specified type - if(token is TokenType) + if(token is TokenType tokenType) { - TokenType tokenType = (TokenType)token; - token = token.nextToken; - if(!(token is TokenName)) + if(token is not TokenName) { ErrorMsg(token, "expecting variable/function name"); token = SkipPastSemi(token); @@ -294,7 +294,7 @@ private ScriptReduce(TokenBegin tokenBegin) } TokenName tokenName = (TokenName)token; token = token.nextToken; - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, " must be followed by ; = or ("); token = SkipPastSemi(token); @@ -317,7 +317,7 @@ private ScriptReduce(TokenBegin tokenBegin) { TokenName tokenName = (TokenName)token; token = token.nextToken; - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, "looking for open paren after assuming " + tokenName.val + " is a function name"); @@ -337,7 +337,7 @@ private ScriptReduce(TokenBegin tokenBegin) // default if(token is TokenKwDefault) { - TokenDeclState tokenDeclState = new TokenDeclState(token); + TokenDeclState tokenDeclState = new (token); token = token.nextToken; tokenDeclState.body = ParseStateBody(ref token); if(tokenDeclState.body == null) @@ -354,15 +354,15 @@ private ScriptReduce(TokenBegin tokenBegin) // state if(token is TokenKwState) { - TokenDeclState tokenDeclState = new TokenDeclState(token); + TokenDeclState tokenDeclState = new (token); token = token.nextToken; - if(!(token is TokenName)) + if(token is not TokenName TokenNametoken) { ErrorMsg(token, "state must be followed by state name"); token = SkipPastSemi(token); continue; } - tokenDeclState.name = (TokenName)token; + tokenDeclState.name = TokenNametoken; token = token.nextToken; tokenDeclState.body = ParseStateBody(ref token); if(tokenDeclState.body == null) @@ -405,13 +405,13 @@ private ScriptReduce(TokenBegin tokenBegin) */ private void ParseSDTypePreScanPassOne(Token tokenBegin) { - Stack braceLevels = new Stack(); - Stack outerLevels = new Stack(); + Stack braceLevels = new(); + Stack outerLevels = new(); int openBraceLevel = 0; braceLevels.Push(-1); outerLevels.Push(null); - - for(Token t = tokenBegin; !((t = t.nextToken) is TokenEnd);) + Token t = tokenBegin; + while((t = t.nextToken) is not TokenEnd) { // Keep track of nested definitions so we can link them up. // We also need to detect the end of class and interface definitions. @@ -442,7 +442,7 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) { Token kw = t; t = t.nextToken; - if(!(t is TokenName)) + if(t is not TokenName) { ErrorMsg(t, "expecting class or interface name"); t = SkipPastSemi(t).prevToken; @@ -520,7 +520,7 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) TokenName delName = null; Token u; int angles = 0; - for(u = t; !(u is TokenKwParOpen); u = u.nextToken) + for(u = t; u is not TokenKwParOpen; u = u.nextToken) { if((u is TokenKwSemi) || (u is TokenEnd)) break; @@ -530,10 +530,10 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) angles--; if(u is TokenKwRSh) angles -= 2; // idiot >> - if((angles == 0) && (u is TokenName)) - delName = (TokenName)u; + if((angles == 0) && (u is TokenName name)) + delName = name; } - if(!(u is TokenKwParOpen)) + if(u is not TokenKwParOpen) { ErrorMsg(u, "expecting ( for delegate parameter list"); t = SkipPastSemi(t).prevToken; @@ -548,11 +548,13 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) if(retType == delName) retType = null; - // Malloc the script-defined type object. - TokenDeclSDTypeDelegate decl = new TokenDeclSDTypeDelegate(delName); - decl.outerSDType = outerLevels.Peek(); + // Malloc the script-defined type object. + TokenDeclSDTypeDelegate decl = new (delName) + { + outerSDType = outerLevels.Peek() + }; - // Check for generic parameter list. + // Check for generic parameter list. t = delName.nextToken; if(!ParseGenProtoParamList(ref t, decl)) continue; @@ -581,7 +583,7 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) // Scan for terminating ';'. // There cannot be an intervening class, delegate, interfate, typedef, { or }. - for(t = decl; !(t is TokenKwSemi); t = u) + for(t = decl; t is not TokenKwSemi; t = u) { u = t.nextToken; if((u is TokenEnd) || @@ -608,7 +610,7 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) Token kw = t; t = t.nextToken; - if(!(t is TokenName)) + if(t is not TokenName) { ErrorMsg(t, "expecting typedef name"); t = SkipPastSemi(t).prevToken; @@ -617,12 +619,14 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) TokenName tdName = (TokenName)t; t = t.nextToken; - // Malloc the script-defined type object. - TokenDeclSDTypeTypedef decl = new TokenDeclSDTypeTypedef(tdName); - decl.outerSDType = outerLevels.Peek(); + // Malloc the script-defined type object. + TokenDeclSDTypeTypedef decl = new (tdName) + { + outerSDType = outerLevels.Peek() + }; - // Check for generic parameter list. - if(!ParseGenProtoParamList(ref t, decl)) + // Check for generic parameter list. + if (!ParseGenProtoParamList(ref t, decl)) continue; // Enter it in name lists so it can be seen by others. @@ -639,7 +643,7 @@ private void ParseSDTypePreScanPassOne(Token tokenBegin) // Scan for terminating ';'. // There cannot be an intervening class, delegate, interfate, typedef, { or }. Token u; - for(t = decl; !(t is TokenKwSemi); t = u) + for(t = decl; t is not TokenKwSemi; t = u) { u = t.nextToken; if((u is TokenEnd) || @@ -673,15 +677,15 @@ private bool ParseGenProtoParamList(ref Token t, TokenDeclSDType decl) { // Maybe there aren't any generic parameters. // If so, leave decl.genParams = null. - if(!(t is TokenKwCmpLT)) + if(t is not TokenKwCmpLT) return true; // Build list of generic parameter names. - Dictionary parms = new Dictionary(); + Dictionary parms = new(); do { t = t.nextToken; - if(!(t is TokenName)) + if(t is not TokenName) { ErrorMsg(t, "expecting generic parameter name"); break; @@ -694,7 +698,7 @@ private bool ParseGenProtoParamList(ref Token t, TokenDeclSDType decl) t = t.nextToken; } while(t is TokenKwComma); - if(!(t is TokenKwCmpGT)) + if(t is not TokenKwCmpGT) { ErrorMsg(t, "expecting , for more params or > to end param list"); return false; @@ -713,17 +717,15 @@ private bool ParseGenProtoParamList(ref Token t, TokenDeclSDType decl) public Token CatalogSDTypeDecl(TokenDeclSDType decl) { string longName = decl.longName.val; - TokenDeclSDType dupDecl; - if(!tokenScript.sdSrcTypesTryGetValue(longName, out dupDecl)) + if (!tokenScript.sdSrcTypesTryGetValue(longName, out TokenDeclSDType dupDecl)) { tokenScript.sdSrcTypesAdd(longName, decl); - if(decl.outerSDType != null) - decl.outerSDType.innerSDTypes.Add(decl.shortName.val, decl); + decl.outerSDType?.innerSDTypes.Add(decl.shortName.val, decl); return null; } - if(!dupDecl.isPartial || !decl.isPartial) + if (!dupDecl.isPartial || !decl.isPartial) { ErrorMsg(decl, "duplicate definition of type " + longName); ErrorMsg(dupDecl, "previous definition here"); @@ -741,7 +743,7 @@ public Token CatalogSDTypeDecl(TokenDeclSDType decl) // Find old partial definition's opening brace. Token dupBrcOpen; - for(dupBrcOpen = dupDecl; !(dupBrcOpen is TokenKwBrcOpen); dupBrcOpen = dupBrcOpen.nextToken) + for(dupBrcOpen = dupDecl; dupBrcOpen is not TokenKwBrcOpen; dupBrcOpen = dupBrcOpen.nextToken) { if(dupBrcOpen == dupDecl.endToken) { @@ -752,7 +754,7 @@ public Token CatalogSDTypeDecl(TokenDeclSDType decl) // Find new partial definition's opening brace. Token brcOpen; - for(brcOpen = decl; !(brcOpen is TokenKwBrcOpen); brcOpen = brcOpen.nextToken) + for(brcOpen = decl; brcOpen is not TokenKwBrcOpen; brcOpen = brcOpen.nextToken) { if(brcOpen is TokenEnd) { @@ -821,10 +823,9 @@ private static bool GenericParametersMatch(TokenDeclSDType c1, TokenDeclSDType c return false; foreach(KeyValuePair kvp1 in gp1) { - int v2; - if(!gp2.TryGetValue(kvp1.Key, out v2)) + if (!gp2.TryGetValue(kvp1.Key, out int v2)) return false; - if(v2 != kvp1.Value) + if (v2 != kvp1.Value) return false; } return true; @@ -842,7 +843,7 @@ private static bool GenericParametersMatch(TokenDeclSDType c1, TokenDeclSDType c private void ParseSDTypePreScanPassTwo(Token tokenBegin) { - List noTypes = new List(); + List noTypes = new(); TokenDeclSDType outerSDType; uint repeat; @@ -852,7 +853,7 @@ private void ParseSDTypePreScanPassTwo(Token tokenBegin) outerSDType = null; noTypes.Clear(); - for(Token t = tokenBegin; !((t = t.nextToken) is TokenEnd);) + for(Token t = tokenBegin; (t = t.nextToken) is not TokenEnd;) { // Maybe it's time to pop out of an outer class definition. if((outerSDType != null) && (outerSDType.endToken == t)) @@ -864,9 +865,9 @@ private void ParseSDTypePreScanPassTwo(Token tokenBegin) // Skip completely over any script-defined generic prototypes. // We only need to process their instantiations which are non- // generic versions of the generics. - if((t is TokenDeclSDType) && (((TokenDeclSDType)t).genParams != null)) + if((t is TokenDeclSDType ttype) && ttype.genParams != null) { - t = ((TokenDeclSDType)t).endToken; + t = ttype.endToken; continue; } @@ -882,9 +883,9 @@ private void ParseSDTypePreScanPassTwo(Token tokenBegin) // We now have: // partial_class_Abc <== if we are here, just ignore the partial_class_Abc token // partial_class_Abc { public intenger one; public intenger two; } - if(t is TokenDeclSDType) + if(t is TokenDeclSDType ttype2) { - if(((TokenDeclSDType)t).endToken != t) + if(ttype2.endToken != t) outerSDType = (TokenDeclSDType)t; continue; @@ -892,7 +893,7 @@ private void ParseSDTypePreScanPassTwo(Token tokenBegin) // For names not preceded by a '.', scan the script-defined type definition // stack for that name. Splice the name out and replace with equivalent token. - if((t is TokenName) && !(t.prevToken is TokenKwDot)) + if((t is TokenName) && t.prevToken is not TokenKwDot) t = TrySpliceTypeRef(t, outerSDType, ref repeat, noTypes); // This handles types such as integer[,][], List[], etc. @@ -962,7 +963,7 @@ private Token TrySpliceTypeRef(Token t, TokenDeclSDType outerSDType, ref uint re if(decl.genParams != null) { t = t.nextToken; - if(!(t is TokenKwCmpLT)) + if(t is not TokenKwCmpLT) { ErrorMsg(t, "expecting < for generic argument list"); return t; @@ -973,7 +974,7 @@ private Token TrySpliceTypeRef(Token t, TokenDeclSDType outerSDType, ref uint re for(int i = 0; i < nArgs;) { t = t.nextToken; - if(!(t is TokenType)) + if(t is not TokenType) { repeat |= REPEAT_NOTYPE; noTypes.Add(t); @@ -986,7 +987,7 @@ private Token TrySpliceTypeRef(Token t, TokenDeclSDType outerSDType, ref uint re t = t.nextToken; if(++i < nArgs) { - if(!(t is TokenKwComma)) + if(t is not TokenKwComma) { ErrorMsg(t, "expecting , for more generic arguments"); return t; @@ -1007,7 +1008,7 @@ private Token TrySpliceTypeRef(Token t, TokenDeclSDType outerSDType, ref uint re v.nextToken.prevToken = v; t = u; } - if(!(t is TokenKwCmpGT)) + if(t is not TokenKwCmpGT) { ErrorMsg(t, "expecting > at end of generic argument list"); return t; @@ -1035,11 +1036,11 @@ private Token TrySpliceTypeRef(Token t, TokenDeclSDType outerSDType, ref uint re } // Maybe caller wants a subtype by putting a '.' following all that. - if(!(t.nextToken is TokenKwDot)) + if(t.nextToken is not TokenKwDot) break; - if(!(t.nextToken.nextToken is TokenName)) + if(t.nextToken.nextToken is not TokenName nextnextname) break; - tnamestr = ((TokenName)t.nextToken.nextToken).val; + tnamestr = nextnextname.val; if(!instdecl.innerSDTypes.TryGetValue(tnamestr, out decl)) break; t = t.nextToken.nextToken; @@ -1083,11 +1084,11 @@ private Token InstantiateJaggedArray(Token t, Token tokenBegin, ref uint repeat) Token start = t; TokenType ofType = (TokenType)t; - Stack ranks = new Stack(); + Stack ranks = new(); - // When script specifies 'float[,][]' it means a two-dimensional matrix - // that points to one-dimensional vectors of floats. So we would push - // a 2 then a 1 in this parsing code... + // When script specifies 'float[,][]' it means a two-dimensional matrix + // that points to one-dimensional vectors of floats. So we would push + // a 2 then a 1 in this parsing code... do { t = t.nextToken; // point at '[' @@ -1097,7 +1098,7 @@ private Token InstantiateJaggedArray(Token t, Token tokenBegin, ref uint repeat) rank++; // count '[' and ','s t = t.nextToken; // point at ',' or ']' } while(t is TokenKwComma); - if(!(t is TokenKwBrkClose)) + if(t is not TokenKwBrkClose) { ErrorMsg(t, "expecting only [ , or ] for array type specification"); return t; @@ -1142,7 +1143,7 @@ private TokenDeclSDType InstantiateFixedArray(int rank, TokenType ofType, Token // This makes it consistent with what the script-writer sees for both a type specification and when // referencing elements in a jagged array. string name = ofType.ToString(); - StringBuilder sb = new StringBuilder(name); + StringBuilder sb = new(name); int ix = name.IndexOf('['); if(ix < 0) ix = name.Length; @@ -1487,7 +1488,7 @@ private Token SpliceAfter(Token before, Token after) */ private bool ParseDeclSDTypes(ref Token token, TokenDeclSDType outerSDType, uint flags) { - if(!(token is TokenDeclSDType)) + if(token is not TokenDeclSDType) return false; TokenDeclSDType decl = (TokenDeclSDType)token; @@ -1575,9 +1576,9 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f u = u.nextToken; while(true) { - if(u is TokenTypeSDTypeClass) + if(u is TokenTypeSDTypeClass uc) { - TokenDeclSDTypeClass c = ((TokenTypeSDTypeClass)u).decl; + TokenDeclSDTypeClass c = uc.decl; if(tokdeclcl.extends == null) { tokdeclcl.extends = c; @@ -1587,9 +1588,9 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f ErrorMsg(u, "can extend from only one class"); } } - else if(u is TokenTypeSDTypeInterface) + else if(u is TokenTypeSDTypeInterface iu) { - TokenDeclSDTypeInterface i = ((TokenTypeSDTypeInterface)u).decl; + TokenDeclSDTypeInterface i = iu.decl; i.AddToClassDecl(tokdeclcl); } else @@ -1601,14 +1602,14 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f u = u.nextToken; // allow : in case it is spliced from multiple partial class definitions - if(!(u is TokenKwComma) && !(u is TokenKwColon)) + if(u is not TokenKwComma && u is not TokenKwColon) break; u = u.nextToken; } } // next must be '{' to open class declaration body - if(!(u is TokenKwBrcOpen)) + if(u is not TokenKwBrcOpen) { ErrorMsg(u, "expecting { to open class declaration body"); token = SkipPastSemi(token); @@ -1622,28 +1623,32 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f // Create a function $instfieldnit to hold all explicit // instance field initializations. - TokenDeclVar ifiFunc = new TokenDeclVar(tokdeclcl, null, tokenScript); + TokenDeclVar ifiFunc = new(tokdeclcl, null, tokenScript); ifiFunc.name = new TokenName(ifiFunc, "$instfieldinit"); ifiFunc.retType = new TokenTypeVoid(ifiFunc); ifiFunc.argDecl = new TokenArgDecl(ifiFunc); ifiFunc.sdtClass = tokdeclcl; ifiFunc.sdtFlags = SDT_PUBLIC | SDT_NEW; - TokenStmtBlock ifiBody = new TokenStmtBlock(ifiFunc); - ifiBody.function = ifiFunc; + TokenStmtBlock ifiBody = new(ifiFunc) + { + function = ifiFunc + }; ifiFunc.body = ifiBody; tokdeclcl.instFieldInit = ifiFunc; tokenScript.AddVarEntry(ifiFunc); // Create a function $staticfieldnit to hold all explicit // static field initializations. - TokenDeclVar sfiFunc = new TokenDeclVar(tokdeclcl, null, tokenScript); + TokenDeclVar sfiFunc = new(tokdeclcl, null, tokenScript); sfiFunc.name = new TokenName(sfiFunc, "$staticfieldinit"); sfiFunc.retType = new TokenTypeVoid(sfiFunc); sfiFunc.argDecl = new TokenArgDecl(sfiFunc); sfiFunc.sdtClass = tokdeclcl; sfiFunc.sdtFlags = SDT_PUBLIC | SDT_STATIC | SDT_NEW; - TokenStmtBlock sfiBody = new TokenStmtBlock(sfiFunc); - sfiBody.function = sfiFunc; + TokenStmtBlock sfiBody = new(sfiFunc) + { + function = sfiFunc + }; sfiFunc.body = sfiBody; tokdeclcl.staticFieldInit = sfiFunc; tokenScript.AddVarEntry(sfiFunc); @@ -1704,17 +1709,21 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f if((flags & SDT_STATIC) != 0) { // . = ; - TokenLValSField left = new TokenLValSField(var.init); - left.baseType = tokdeclcl.MakeRefToken(var); - left.fieldName = var.name; + TokenLValSField left = new(var.init) + { + baseType = tokdeclcl.MakeRefToken(var), + fieldName = var.name + }; DoVarInit(sfiFunc, left, var.init); } else if(var.init != null) { // this. = ; - TokenLValIField left = new TokenLValIField(var.init); - left.baseRVal = new TokenRValThis(var.init, tokdeclcl); - left.fieldName = var.name; + TokenLValIField left = new(var.init) + { + baseRVal = new TokenRValThis(var.init, tokdeclcl), + fieldName = var.name + }; DoVarInit(ifiFunc, left, var.init); } } @@ -1767,7 +1776,7 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f // // method returning void - if((token is TokenName) || ((token is TokenKw) && ((TokenKw)token).sdtClassOp)) + if((token is TokenName) || (token is TokenKw kwt && kwt.sdtClassOp)) { ParseSDTClassMethodDecl(ref token, flags, tokdeclcl); continue; @@ -1781,13 +1790,15 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f // If script didn't specify any constructor, create a default no-argument one. if(!haveExplicitConstructor) { - TokenDeclVar tokenDeclFunc = new TokenDeclVar(token, null, tokenScript); - tokenDeclFunc.name = new TokenName(token, "$ctor"); - tokenDeclFunc.retType = new TokenTypeVoid(token); - tokenDeclFunc.argDecl = new TokenArgDecl(token); - tokenDeclFunc.sdtClass = tokdeclcl; - tokenDeclFunc.sdtFlags = SDT_PUBLIC | SDT_NEW; - tokenDeclFunc.body = new TokenStmtBlock(token); + TokenDeclVar tokenDeclFunc = new(token, null, tokenScript) + { + name = new TokenName(token, "$ctor"), + retType = new TokenTypeVoid(token), + argDecl = new TokenArgDecl(token), + sdtClass = tokdeclcl, + sdtFlags = SDT_PUBLIC | SDT_NEW, + body = new TokenStmtBlock(token) + }; tokenDeclFunc.body.function = tokenDeclFunc; if(tokdeclcl.extends != null) @@ -1815,7 +1826,7 @@ private void ParseDeclClass(ref Token token, TokenDeclSDType outerSDType, uint f * @param token = first token to evaluate * @returns flags found; token = unprocessed token */ - private Dictionary foundFlags = new Dictionary(); + private Dictionary foundFlags = new(); private uint ParseQualifierFlags(ref Token token) { foundFlags.Clear(); @@ -1883,8 +1894,7 @@ private Token AddQualifierFlag(Token token, uint add, uint confs) while(confs != 0) { uint conf = (uint)(confs & -confs); - Token confToken; - if(foundFlags.TryGetValue(conf, out confToken)) + if (foundFlags.TryGetValue(conf, out Token confToken)) { ErrorMsg(token, "conflicts with " + confToken.ToString()); } @@ -1944,7 +1954,7 @@ private TokenDeclVar ParseProperty(ref Token token, bool abs, bool imp) } // Should have an opening brace. - if(!(token is TokenKwBrcOpen)) + if(token is not TokenKwBrcOpen) { ErrorMsg(token, "expect { to open property definition"); token = SkipPastSemi(token); @@ -1957,16 +1967,18 @@ private TokenDeclVar ParseProperty(ref Token token, bool abs, bool imp) // 'set' { | ';' } TokenDeclVar getFunc = null; TokenDeclVar setFunc = null; - while(!(token is TokenKwBrcClose)) + while(token is not TokenKwBrcClose) { // Maybe create a getter function. if(token is TokenKwGet) { - getFunc = new TokenDeclVar(token, null, tokenScript); - getFunc.name = new TokenName(token, name.val + "$get"); - getFunc.retType = type; - getFunc.argDecl = args; - getFunc.implements = MakePropertyImplements(implements, "$get"); + getFunc = new TokenDeclVar(token, null, tokenScript) + { + name = new TokenName(token, name.val + "$get"), + retType = type, + argDecl = args, + implements = MakePropertyImplements(implements, "$get") + }; token = token.nextToken; if(!ParseFunctionBody(ref token, getFunc, abs)) @@ -1991,11 +2003,13 @@ private TokenDeclVar ParseProperty(ref Token token, bool abs, bool imp) } argDecl.AddArg(type, new TokenName(token, "value")); - setFunc = new TokenDeclVar(token, null, tokenScript); - setFunc.name = new TokenName(token, name.val + "$set"); - setFunc.retType = new TokenTypeVoid(token); - setFunc.argDecl = argDecl; - setFunc.implements = MakePropertyImplements(implements, "$set"); + setFunc = new TokenDeclVar(token, null, tokenScript) + { + name = new TokenName(token, name.val + "$set"), + retType = new TokenTypeVoid(token), + argDecl = argDecl, + implements = MakePropertyImplements(implements, "$set") + }; token = token.nextToken; if(!ParseFunctionBody(ref token, setFunc, abs)) @@ -2021,15 +2035,17 @@ private TokenDeclVar ParseProperty(ref Token token, bool abs, bool imp) return null; } - // Set up a variable for the property. - TokenDeclVar tokenDeclVar = new TokenDeclVar(name, null, tokenScript); - tokenDeclVar.type = type; - tokenDeclVar.name = name; - tokenDeclVar.getProp = getFunc; - tokenDeclVar.setProp = setFunc; + // Set up a variable for the property. + TokenDeclVar tokenDeclVar = new(name, null, tokenScript) + { + type = type, + name = name, + getProp = getFunc, + setProp = setFunc + }; - // Can't be same name already in block. - if(!tokenScript.AddVarEntry(tokenDeclVar)) + // Can't be same name already in block. + if (!tokenScript.AddVarEntry(tokenDeclVar)) { ErrorMsg(tokenDeclVar, "duplicate member " + name.val); return null; @@ -2048,9 +2064,10 @@ private TokenIntfImpl MakePropertyImplements(TokenIntfImpl implements, string su TokenIntfImpl gsimpls = null; for(TokenIntfImpl impl = implements; impl != null; impl = (TokenIntfImpl)impl.nextToken) { - TokenIntfImpl gsimpl = new TokenIntfImpl(impl.intfType, - new TokenName(impl.methName, impl.methName.val + suffix)); - gsimpl.nextToken = gsimpls; + TokenIntfImpl gsimpl = new(impl.intfType, new TokenName(impl.methName, impl.methName.val + suffix)) + { + nextToken = gsimpls + }; gsimpls = gsimpl; } return gsimpls; @@ -2070,14 +2087,14 @@ private void ParseSDTClassCtorDecl(ref Token token, uint flags, TokenDeclSDTypeC ErrorMsg(token, "cannot have abstract, override, static or virtual constructor"); } - TokenDeclVar tokenDeclFunc = new TokenDeclVar(token, null, tokenScript); + TokenDeclVar tokenDeclFunc = new(token, null, tokenScript); tokenDeclFunc.name = new TokenName(tokenDeclFunc, "$ctor"); tokenDeclFunc.retType = new TokenTypeVoid(token); tokenDeclFunc.sdtClass = tokdeclcl; tokenDeclFunc.sdtFlags = flags | SDT_NEW; token = token.nextToken; - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, "expecting ( for constructor argument list"); token = SkipPastSemi(token); @@ -2093,9 +2110,7 @@ private void ParseSDTClassCtorDecl(ref Token token, uint flags, TokenDeclSDTypeC try { // Set up reference to base constructor. - TokenLValBaseField baseCtor = new TokenLValBaseField(token, - new TokenName(token, "$ctor"), - tokdeclcl); + TokenLValBaseField baseCtor = new(token, new TokenName(token, "$ctor"), tokdeclcl); // Parse any base constructor call as if it were the first statement of the // constructor itself. @@ -2106,7 +2121,7 @@ private void ParseSDTClassCtorDecl(ref Token token, uint flags, TokenDeclSDTypeC { token = token.nextToken; } - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, "expecting ( for base constructor call arguments"); token = SkipPastSemi(token); @@ -2158,11 +2173,11 @@ private void ParseSDTClassCtorDecl(ref Token token, uint flags, TokenDeclSDTypeC */ private void SetUpDefaultBaseCtorCall(TokenDeclVar thisCtor) { - TokenLValBaseField baseCtor = new TokenLValBaseField(thisCtor, - new TokenName(thisCtor, "$ctor"), - (TokenDeclSDTypeClass)thisCtor.sdtClass); - TokenRValCall rvc = new TokenRValCall(thisCtor); - rvc.meth = baseCtor; + TokenLValBaseField baseCtor = new(thisCtor, new TokenName(thisCtor, "$ctor"), (TokenDeclSDTypeClass)thisCtor.sdtClass); + TokenRValCall rvc = new(thisCtor) + { + meth = baseCtor + }; thisCtor.baseCtorCall = rvc; thisCtor.unknownTrivialityCalls.AddLast(rvc); } @@ -2213,9 +2228,9 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin // first thing following that should be return type // but we will fill in 'void' if it is missing u = u.nextToken; - if(u is TokenType) + if(u is TokenType tu) { - retType = (TokenType)u; + retType = tu; u = u.nextToken; } else @@ -2224,7 +2239,7 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin } // get list of argument types until we see a ')' - List args = new List(); + List args = new(); bool first = true; do { @@ -2232,7 +2247,7 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin { // first time should have '(' ')' or '(' - if(!(u is TokenKwParOpen)) + if(u is not TokenKwParOpen) { ErrorMsg(u, "expecting ( after delegate name"); token = SkipPastSemi(token); @@ -2246,7 +2261,7 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin else { // other times should have ',' - if(!(u is TokenKwComma)) + if(u is not TokenKwComma) { ErrorMsg(u, "expecting , separating arg types"); token = SkipPastSemi(token); @@ -2254,7 +2269,7 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin } u = u.nextToken; } - if(!(u is TokenType)) + if(u is not TokenType) { ErrorMsg(u, "expecting argument type"); token = SkipPastSemi(token); @@ -2268,14 +2283,14 @@ private void ParseDeclDelegate(ref Token token, TokenDeclSDType outerSDType, uin u = u.nextToken; // scanning ends on a ')' - } while(!(u is TokenKwParClose)); + } while(u is not TokenKwParClose); // fill in the return type and argment type array tokdecldel.SetRetArgTypes(retType, args.ToArray()); // and finally must have ';' to finish the delegate declaration statement u = u.nextToken; - if(!(u is TokenKwSemi)) + if(u is not TokenKwSemi) { ErrorMsg(u, "expecting ; after ) in delegate"); token = SkipPastSemi(token); @@ -2308,9 +2323,9 @@ private void ParseDeclInterface(ref Token token, TokenDeclSDType outerSDType, ui u = u.nextToken; while(true) { - if(u is TokenTypeSDTypeInterface) + if(u is TokenTypeSDTypeInterface iu) { - TokenDeclSDTypeInterface i = ((TokenTypeSDTypeInterface)u).decl; + TokenDeclSDTypeInterface i = iu.decl; if(!tokdeclin.implements.Contains(i)) { tokdeclin.implements.Add(i); @@ -2323,14 +2338,14 @@ private void ParseDeclInterface(ref Token token, TokenDeclSDType outerSDType, ui break; } u = u.nextToken; - if(!(u is TokenKwComma)) + if(u is not TokenKwComma) break; u = u.nextToken; } } // next must be '{' to open interface declaration body - if(!(u is TokenKwBrcOpen)) + if(u is not TokenKwBrcOpen) { ErrorMsg(u, "expecting { to open interface declaration body"); token = SkipPastSemi(token); @@ -2343,7 +2358,7 @@ private void ParseDeclInterface(ref Token token, TokenDeclSDType outerSDType, ui tokdeclin.methsNProps = tokenScript.variablesStack; // process declaration statements until '}' - while(!(token is TokenKwBrcClose)) + while(token is not TokenKwBrcClose) { if(token is TokenKwSemi) { @@ -2422,9 +2437,9 @@ private void ParseDeclInterface(ref Token token, TokenDeclSDType outerSDType, ui */ private TokenStateBody ParseStateBody(ref Token token) { - TokenStateBody tokenStateBody = new TokenStateBody(token); + TokenStateBody tokenStateBody = new(token); - if(!(token is TokenKwBrcOpen)) + if(token is not TokenKwBrcOpen) { ErrorMsg(token, "expecting { at beg of state"); token = SkipPastSemi(token); @@ -2432,7 +2447,7 @@ private TokenStateBody ParseStateBody(ref Token token) } token = token.nextToken; - while(!(token is TokenKwBrcClose)) + while(token is not TokenKwBrcClose) { if(token is TokenEnd) { @@ -2442,7 +2457,7 @@ private TokenStateBody ParseStateBody(ref Token token) TokenDeclVar tokenDeclFunc = ParseDeclFunc(ref token, false, false, false); if(tokenDeclFunc == null) return null; - if(!(tokenDeclFunc.retType is TokenTypeVoid)) + if(tokenDeclFunc.retType is not TokenTypeVoid) { ErrorMsg(tokenDeclFunc.retType, "event handlers don't have return types"); return null; @@ -2466,25 +2481,19 @@ private TokenStateBody ParseStateBody(ref Token token) */ private TokenDeclVar ParseDeclFunc(ref Token token, bool abs, bool imp, bool ops) { - TokenType retType; - if(token is TokenType) - { - retType = (TokenType)token; + if(token is TokenType retType) token = token.nextToken; - } else - { retType = new TokenTypeVoid(token); - } TokenName simpleName; - if((token is TokenKw) && ((TokenKw)token).sdtClassOp) + if((token is TokenKw Kwt) && Kwt.sdtClassOp) { if(!ops) ErrorMsg(token, "operator functions disallowed in static contexts"); simpleName = new TokenName(token, "$op" + token.ToString()); } - else if(!(token is TokenName)) + else if(token is not TokenName tname) { ErrorMsg(token, "expecting function name"); token = SkipPastSemi(token); @@ -2492,7 +2501,7 @@ private TokenDeclVar ParseDeclFunc(ref Token token, bool abs, bool imp, bool ops } else { - simpleName = (TokenName)token; + simpleName = tname; } token = token.nextToken; @@ -2513,11 +2522,13 @@ private TokenDeclVar ParseDeclFunc(ref Token token, bool abs, bool imp, bool ops */ private TokenDeclVar ParseDeclFunc(ref Token token, bool abs, bool imp, TokenType retType, TokenName simpleName) { - TokenDeclVar tokenDeclFunc = new TokenDeclVar(simpleName, null, tokenScript); - tokenDeclFunc.name = simpleName; - tokenDeclFunc.retType = retType; - tokenDeclFunc.argDecl = ParseFuncArgs(ref token, typeof(TokenKwParClose)); - if(tokenDeclFunc.argDecl == null) + TokenDeclVar tokenDeclFunc = new(simpleName, null, tokenScript) + { + name = simpleName, + retType = retType, + argDecl = ParseFuncArgs(ref token, typeof(TokenKwParClose)) + }; + if (tokenDeclFunc.argDecl == null) return null; if(token is TokenKwColon) @@ -2553,7 +2564,7 @@ private TokenIntfImpl ParseImplements(ref Token token, TokenName simpleName) do { token = token.nextToken; - if(!(token is TokenTypeSDTypeInterface)) + if(token is not TokenTypeSDTypeInterface) { ErrorMsg(token, "expecting interface type"); token = SkipPastSemi(token); @@ -2562,13 +2573,15 @@ private TokenIntfImpl ParseImplements(ref Token token, TokenName simpleName) TokenTypeSDTypeInterface intfType = (TokenTypeSDTypeInterface)token; token = token.nextToken; TokenName methName = simpleName; - if((token is TokenKwDot) && (token.nextToken is TokenName)) + if((token is TokenKwDot) && (token.nextToken is TokenName tname)) { - methName = (TokenName)token.nextToken; + methName = tname; token = token.nextToken.nextToken; } - TokenIntfImpl intfImpl = new TokenIntfImpl(intfType, methName); - intfImpl.nextToken = implements; + TokenIntfImpl intfImpl = new(intfType, methName) + { + nextToken = implements + }; implements = intfImpl; } while(token is TokenKwComma); return implements; @@ -2671,8 +2684,7 @@ private TokenStmt ParseStmt(ref Token token) TokenRVal tokenRVal = ParseRVal(ref token, semiOnly); if(tokenRVal != null) { - TokenStmtRVal tokenStmtRVal = new TokenStmtRVal(tokenRVal); - tokenStmtRVal.rVal = tokenRVal; + TokenStmtRVal tokenStmtRVal = new(tokenRVal) { rVal = tokenRVal }; return tokenStmtRVal; } @@ -2691,22 +2703,24 @@ private TokenStmt ParseStmt(ref Token token) */ private TokenStmtBlock ParseStmtBlock(ref Token token) { - if(!(token is TokenKwBrcOpen)) + if(token is not TokenKwBrcOpen) { ErrorMsg(token, "statement block body must begin with a {"); token = SkipPastSemi(token); return null; } - TokenStmtBlock tokenStmtBlock = new TokenStmtBlock(token); - tokenStmtBlock.function = currentDeclFunc; - tokenStmtBlock.outerStmtBlock = currentStmtBlock; + TokenStmtBlock tokenStmtBlock = new(token) + { + function = currentDeclFunc, + outerStmtBlock = currentStmtBlock + }; currentStmtBlock = tokenStmtBlock; VarDict outerVariablesStack = tokenScript.variablesStack; try { Token prevStmt = null; token = token.nextToken; - while(!(token is TokenKwBrcClose)) + while(token is not TokenKwBrcClose) { if(token is TokenEnd) { @@ -2750,9 +2764,9 @@ private TokenStmtBlock ParseStmtBlock(ref Token token) */ private TokenStmtBreak ParseStmtBreak(ref Token token) { - TokenStmtBreak tokenStmtBreak = new TokenStmtBreak(token); + TokenStmtBreak tokenStmtBreak = new(token); token = token.nextToken; - if(!(token is TokenKwSemi)) + if(token is not TokenKwSemi) { ErrorMsg(token, "expecting ;"); token = SkipPastSemi(token); @@ -2771,9 +2785,9 @@ private TokenStmtBreak ParseStmtBreak(ref Token token) */ private TokenStmtCont ParseStmtCont(ref Token token) { - TokenStmtCont tokenStmtCont = new TokenStmtCont(token); + TokenStmtCont tokenStmtCont = new(token); token = token.nextToken; - if(!(token is TokenKwSemi)) + if(token is not TokenKwSemi) { ErrorMsg(token, "expecting ;"); token = SkipPastSemi(token); @@ -2793,12 +2807,12 @@ private TokenStmtCont ParseStmtCont(ref Token token) private TokenStmtDo ParseStmtDo(ref Token token) { currentDeclFunc.triviality = Triviality.complex; - TokenStmtDo tokenStmtDo = new TokenStmtDo(token); + TokenStmtDo tokenStmtDo = new(token); token = token.nextToken; tokenStmtDo.bodyStmt = ParseStmt(ref token); if(tokenStmtDo.bodyStmt == null) return null; - if(!(token is TokenKwWhile)) + if(token is not TokenKwWhile) { ErrorMsg(token, "expecting while clause"); return null; @@ -2807,7 +2821,7 @@ private TokenStmtDo ParseStmtDo(ref Token token) tokenStmtDo.testRVal = ParseRValParen(ref token); if(tokenStmtDo.testRVal == null) return null; - if(!(token is TokenKwSemi)) + if(token is not TokenKwSemi) { ErrorMsg(token, "while clause must terminate on semicolon"); token = SkipPastSemi(token); @@ -2829,9 +2843,9 @@ private TokenStmt ParseStmtFor(ref Token token) currentDeclFunc.triviality = Triviality.complex; // Create encapsulating token and skip past 'for (' - TokenStmtFor tokenStmtFor = new TokenStmtFor(token); + TokenStmtFor tokenStmtFor = new(token); token = token.nextToken; - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, "for must be followed by ("); return null; @@ -2839,7 +2853,7 @@ private TokenStmt ParseStmtFor(ref Token token) token = token.nextToken; // If a plain for, ie, not declaring a variable, it's straightforward. - if(!(token is TokenType)) + if(token is not TokenType) { tokenStmtFor.initStmt = ParseStmt(ref token); if(tokenStmtFor.initStmt == null) @@ -2847,11 +2861,13 @@ private TokenStmt ParseStmtFor(ref Token token) return ParseStmtFor2(tokenStmtFor, ref token) ? tokenStmtFor : null; } - // Initialization declares a variable, so encapsulate it in a block so - // variable has scope only in the for statement, including its body. - TokenStmtBlock forStmtBlock = new TokenStmtBlock(tokenStmtFor); - forStmtBlock.outerStmtBlock = currentStmtBlock; - forStmtBlock.function = currentDeclFunc; + // Initialization declares a variable, so encapsulate it in a block so + // variable has scope only in the for statement, including its body. + TokenStmtBlock forStmtBlock = new(tokenStmtFor) + { + outerStmtBlock = currentStmtBlock, + function = currentDeclFunc + }; currentStmtBlock = forStmtBlock; tokenScript.PushVarFrame(true); @@ -2918,33 +2934,33 @@ private TokenStmt ParseStmtForEach(ref Token token) currentDeclFunc.triviality = Triviality.complex; // Create encapsulating token and skip past 'foreach (' - TokenStmtForEach tokenStmtForEach = new TokenStmtForEach(token); + TokenStmtForEach tokenStmtForEach = new(token); token = token.nextToken; - if(!(token is TokenKwParOpen)) + if(token is not TokenKwParOpen) { ErrorMsg(token, "foreach must be followed by ("); return null; } token = token.nextToken; - if(token is TokenName) + if(token is TokenName tname) { - tokenStmtForEach.keyLVal = new TokenLValName((TokenName)token, tokenScript.variablesStack); + tokenStmtForEach.keyLVal = new TokenLValName(tname, tokenScript.variablesStack); token = token.nextToken; } - if(!(token is TokenKwComma)) + if(token is not TokenKwComma) { ErrorMsg(token, "expecting comma"); token = SkipPastSemi(token); return null; } token = token.nextToken; - if(token is TokenName) + if(token is TokenName tname2) { - tokenStmtForEach.valLVal = new TokenLValName((TokenName)token, tokenScript.variablesStack); + tokenStmtForEach.valLVal = new TokenLValName(tname2, tokenScript.variablesStack); token = token.nextToken; } - if(!(token is TokenKwIn)) + if(token is not TokenKwIn) { ErrorMsg(token, "expecting 'in'"); token = SkipPastSemi(token); @@ -2954,7 +2970,7 @@ private TokenStmt ParseStmtForEach(ref Token token) tokenStmtForEach.arrayRVal = GetOperand(ref token); if(tokenStmtForEach.arrayRVal == null) return null; - if(!(token is TokenKwParClose)) + if(token is not TokenKwParClose) { ErrorMsg(token, "expecting )"); token = SkipPastSemi(token); @@ -2969,7 +2985,7 @@ private TokenStmt ParseStmtForEach(ref Token token) private TokenStmtIf ParseStmtIf(ref Token token) { - TokenStmtIf tokenStmtIf = new TokenStmtIf(token); + TokenStmtIf tokenStmtIf = new(token); token = token.nextToken; tokenStmtIf.testRVal = ParseRValParen(ref token); if(tokenStmtIf.testRVal == null) @@ -2990,9 +3006,9 @@ private TokenStmtIf ParseStmtIf(ref Token token) private TokenStmtJump ParseStmtJump(ref Token token) { // Create jump statement token to encapsulate the whole statement. - TokenStmtJump tokenStmtJump = new TokenStmtJump(token); + TokenStmtJump tokenStmtJump = new(token); token = token.nextToken; - if(!(token is TokenName) || !(token.nextToken is TokenKwSemi)) + if(token is not TokenName || token.nextToken is not TokenKwSemi) { ErrorMsg(token, "expecting label;"); token = SkipPastSemi(token); @@ -3022,17 +3038,18 @@ private TokenStmtJump ParseStmtJump(ref Token token) */ private TokenStmtLabel ParseStmtLabel(ref Token token) { - if(!(token.nextToken is TokenName) || - !(token.nextToken.nextToken is TokenKwSemi)) + if(token.nextToken is not TokenName tname || token.nextToken.nextToken is not TokenKwSemi) { ErrorMsg(token, "invalid label"); token = SkipPastSemi(token); return null; } - TokenStmtLabel stmtLabel = new TokenStmtLabel(token); - stmtLabel.name = (TokenName)token.nextToken; - stmtLabel.block = currentStmtBlock; - if(currentDeclFunc.labels.ContainsKey(stmtLabel.name.val)) + TokenStmtLabel stmtLabel = new(token) + { + name = tname, + block = currentStmtBlock + }; + if (currentDeclFunc.labels.ContainsKey(stmtLabel.name.val)) { ErrorMsg(token.nextToken, "duplicate label"); ErrorMsg(currentDeclFunc.labels[stmtLabel.name.val], "previously defined here"); @@ -3046,14 +3063,14 @@ private TokenStmtLabel ParseStmtLabel(ref Token token) private TokenStmtNull ParseStmtNull(ref Token token) { - TokenStmtNull tokenStmtNull = new TokenStmtNull(token); + TokenStmtNull tokenStmtNull = new(token); token = token.nextToken; return tokenStmtNull; } private TokenStmtRet ParseStmtRet(ref Token token) { - TokenStmtRet tokenStmtRet = new TokenStmtRet(token); + TokenStmtRet tokenStmtRet = new(token); token = token.nextToken; if(token is TokenKwSemi) { @@ -3070,7 +3087,7 @@ private TokenStmtRet ParseStmtRet(ref Token token) private TokenStmtSwitch ParseStmtSwitch(ref Token token) { - TokenStmtSwitch tokenStmtSwitch = new TokenStmtSwitch(token); + TokenStmtSwitch tokenStmtSwitch = new(token); token = token.nextToken; tokenStmtSwitch.testRVal = ParseRValParen(ref token); if(tokenStmtSwitch.testRVal == null) @@ -3172,17 +3189,17 @@ private TokenStmtSwitch ParseStmtSwitch(ref Token token) private TokenStmtState ParseStmtState(ref Token token) { - TokenStmtState tokenStmtState = new TokenStmtState(token); + TokenStmtState tokenStmtState = new(token); token = token.nextToken; - if((!(token is TokenName) && !(token is TokenKwDefault)) || !(token.nextToken is TokenKwSemi)) + if((token is not TokenName && token is not TokenKwDefault) || token.nextToken is not TokenKwSemi) { ErrorMsg(token, "expecting state;"); token = SkipPastSemi(token); return null; } - if(token is TokenName) + if(token is TokenName tname) { - tokenStmtState.state = (TokenName)token; + tokenStmtState.state = tname; } token = token.nextToken.nextToken; return tokenStmtState; @@ -3190,7 +3207,7 @@ private TokenStmtState ParseStmtState(ref Token token) private TokenStmtThrow ParseStmtThrow(ref Token token) { - TokenStmtThrow tokenStmtThrow = new TokenStmtThrow(token); + TokenStmtThrow tokenStmtThrow = new(token); token = token.nextToken; if(token is TokenKwSemi) { @@ -3223,29 +3240,30 @@ private TokenStmtTry ParseStmtTry(ref Token token) TokenStmtTry tokenStmtTry; if(token is TokenKwCatch) { - if(!(token.nextToken is TokenKwParOpen) || - !(token.nextToken.nextToken is TokenType) || - !(token.nextToken.nextToken.nextToken is TokenName) || - !(token.nextToken.nextToken.nextToken.nextToken is TokenKwParClose)) + if(token.nextToken is not TokenKwParOpen || + token.nextToken.nextToken is not TokenType || + token.nextToken.nextToken.nextToken is not TokenName || + token.nextToken.nextToken.nextToken.nextToken is not TokenKwParClose) { ErrorMsg(token, "catch must be followed by ( ) { ... }"); return null; } token = token.nextToken.nextToken; // skip over 'catch' '(' - TokenDeclVar tag = new TokenDeclVar(token.nextToken, currentDeclFunc, tokenScript); - tag.type = (TokenType)token; + TokenDeclVar tag = new(token.nextToken, currentDeclFunc, tokenScript) { type = (TokenType)token }; token = token.nextToken; // skip over tag.name = (TokenName)token; token = token.nextToken.nextToken; // skip over ')' - if((!(tag.type is TokenTypeExc)) && (!(tag.type is TokenTypeStr))) + if((tag.type is not TokenTypeExc) && (tag.type is not TokenTypeStr)) { ErrorMsg(tag.type, "must be type 'exception' or 'string'"); } - tokenStmtTry = new TokenStmtTry(tryKw); - tokenStmtTry.tryStmt = WrapTryCatFinInBlock(body); - tokenStmtTry.catchVar = tag; + tokenStmtTry = new TokenStmtTry(tryKw) + { + tryStmt = WrapTryCatFinInBlock(body), + catchVar = tag + }; tokenScript.PushVarFrame(false); tokenScript.AddVarEntry(tag); tokenStmtTry.catchStmt = ParseStmtBlock(ref token); @@ -3261,10 +3279,12 @@ private TokenStmtTry ParseStmtTry(ref Token token) { token = token.nextToken; - tokenStmtTry = new TokenStmtTry(tryKw); - tokenStmtTry.tryStmt = WrapTryCatFinInBlock(body); - tokenStmtTry.finallyStmt = ParseStmtBlock(ref token); - if(tokenStmtTry.finallyStmt == null) + tokenStmtTry = new TokenStmtTry(tryKw) + { + tryStmt = WrapTryCatFinInBlock(body), + finallyStmt = ParseStmtBlock(ref token) + }; + if (tokenStmtTry.finallyStmt == null) return null; tokenStmtTry.tryStmt.isTry = true; tokenStmtTry.tryStmt.tryStmt = tokenStmtTry; @@ -3297,15 +3317,17 @@ private TokenStmtTry ParseStmtTry(ref Token token) */ private TokenStmtBlock WrapTryCatFinInBlock(TokenStmt body) { - if(body is TokenStmtBlock) - return (TokenStmtBlock)body; + if(body is TokenStmtBlock tb) + return tb; TokenStmtTry innerTry = (TokenStmtTry)body; - TokenStmtBlock wrapper = new TokenStmtBlock(body); - wrapper.statements = innerTry; - wrapper.outerStmtBlock = currentStmtBlock; - wrapper.function = currentDeclFunc; + TokenStmtBlock wrapper = new(body) + { + statements = innerTry, + outerStmtBlock = currentStmtBlock, + function = currentDeclFunc + }; innerTry.tryStmt.outerStmtBlock = wrapper; if(innerTry.catchStmt != null) @@ -3319,7 +3341,7 @@ private TokenStmtBlock WrapTryCatFinInBlock(TokenStmt body) private TokenStmtWhile ParseStmtWhile(ref Token token) { currentDeclFunc.triviality = Triviality.complex; - TokenStmtWhile tokenStmtWhile = new TokenStmtWhile(token); + TokenStmtWhile tokenStmtWhile = new(token); token = token.nextToken; tokenStmtWhile.testRVal = ParseRValParen(ref token); if(tokenStmtWhile.testRVal == null) @@ -3344,7 +3366,7 @@ private TokenStmtWhile ParseStmtWhile(ref Token token) */ private TokenDeclVar ParseDeclVar(ref Token token, TokenDeclVar initFunc) { - TokenDeclVar tokenDeclVar = new TokenDeclVar(token.nextToken, currentDeclFunc, tokenScript); + TokenDeclVar tokenDeclVar = new(token.nextToken, currentDeclFunc, tokenScript); // Handle constant declaration. // It ends up in the declared variables list for the statement block just like @@ -3355,7 +3377,7 @@ private TokenDeclVar ParseDeclVar(ref Token token, TokenDeclVar initFunc) if(token is TokenKwConst) { token = token.nextToken; - if(!(token is TokenName)) + if(token is not TokenName) { ErrorMsg(token, "expecting constant name"); token = SkipPastSemi(token); @@ -3363,7 +3385,7 @@ private TokenDeclVar ParseDeclVar(ref Token token, TokenDeclVar initFunc) } tokenDeclVar.name = (TokenName)token; token = token.nextToken; - if(!(token is TokenKwAssign)) + if(token is not TokenKwAssign) { ErrorMsg(token, "expecting ="); token = SkipPastSemi(token); @@ -3471,16 +3493,12 @@ private void DoVarInit(TokenDeclVar initFunc, TokenLVal left, TokenRVal init) TokenStmt stmt; if(init == null) { - TokenStmtVarIniDef tsvid = new TokenStmtVarIniDef(left); - tsvid.var = left; - stmt = tsvid; + stmt = new TokenStmtVarIniDef(left) { var = left }; } else { TokenKw op = new TokenKwAssign(left); - TokenStmtRVal tsrv = new TokenStmtRVal(init); - tsrv.rVal = new TokenRValOpBin(left, op, init); - stmt = tsrv; + stmt = new TokenStmtRVal(init) { rVal = new TokenRValOpBin(left, op, init) }; } // Add statement to end of initialization function. @@ -3511,7 +3529,7 @@ private void DoVarInit(TokenDeclVar initFunc, TokenLVal left, TokenRVal init) */ private TokenArgDecl ParseFuncArgs(ref Token token, Type end) { - TokenArgDecl tokenArgDecl = new TokenArgDecl(token); + TokenArgDecl tokenArgDecl = new(token); bool first = true; do @@ -3519,21 +3537,19 @@ private TokenArgDecl ParseFuncArgs(ref Token token, Type end) token = token.nextToken; if((token.GetType() == end) && first) break; - if(!(token is TokenType)) + if(!(token is TokenType type)) { ErrorMsg(token, "expecting arg type"); token = SkipPastSemi(token); return null; } - TokenType type = (TokenType)token; token = token.nextToken; - if(!(token is TokenName)) + if(token is not TokenName name) { ErrorMsg(token, "expecting arg name"); token = SkipPastSemi(token); return null; } - TokenName name = (TokenName)token; token = token.nextToken; if(!tokenArgDecl.AddArg(type, name)) @@ -3586,7 +3602,7 @@ public TokenRVal ParseRVal(ref Token token, Type[] termTokenTypes) // is if(token is TokenKwIs) { - TokenRValIsType tokenRValIsType = new TokenRValIsType(token); + TokenRValIsType tokenRValIsType = new(token); token = token.nextToken; // Parse the . @@ -3643,13 +3659,15 @@ public TokenRVal ParseRVal(ref Token token, Type[] termTokenTypes) // ? : if(binOp.token is TokenKwQMark) { - TokenRValCondExpr condExpr = new TokenRValCondExpr(binOp.token); - condExpr.condExpr = operands; - condExpr.trueExpr = ParseRVal(ref token, new Type[] { typeof(TokenKwColon) }); - condExpr.falseExpr = ParseRVal(ref token, termTokenTypes); - condExpr.prevToken = operands.prevToken; + TokenRValCondExpr condExpr = new(binOp.token) + { + condExpr = operands, + trueExpr = ParseRVal(ref token, new Type[] { typeof(TokenKwColon) }), + falseExpr = ParseRVal(ref token, termTokenTypes), + prevToken = operands.prevToken + }; operands = condExpr; - termTokenTypes = new Type[0]; + termTokenTypes = Array.Empty(); goto done; } @@ -3699,10 +3717,12 @@ private TokenTypeExp ParseTypeExp(ref Token token) TokenTypeExp rightOperand = GetTypeExp(ref token); if(rightOperand == null) return null; - TokenTypeExpBinOp typeExpBinOp = new TokenTypeExpBinOp(typeBinOp); - typeExpBinOp.leftOp = leftOperand; - typeExpBinOp.binOp = typeBinOp; - typeExpBinOp.rightOp = rightOperand; + TokenTypeExpBinOp typeExpBinOp = new(typeBinOp) + { + leftOp = leftOperand, + binOp = typeBinOp, + rightOp = rightOperand + }; leftOperand = typeExpBinOp; } return leftOperand; @@ -3712,7 +3732,7 @@ private TokenTypeExp GetTypeExp(ref Token token) { if(token is TokenKwTilde) { - TokenTypeExpNot typeExpNot = new TokenTypeExpNot(token); + TokenTypeExpNot typeExpNot = new(token); token = token.nextToken; typeExpNot.typeExp = GetTypeExp(ref token); if(typeExpNot.typeExp == null) @@ -3721,7 +3741,7 @@ private TokenTypeExp GetTypeExp(ref Token token) } if(token is TokenKwParOpen) { - TokenTypeExpPar typeExpPar = new TokenTypeExpPar(token); + TokenTypeExpPar typeExpPar = new(token); token = token.nextToken; typeExpPar.typeExp = GetTypeExp(ref token); if(typeExpPar.typeExp == null) @@ -3736,14 +3756,13 @@ private TokenTypeExp GetTypeExp(ref Token token) } if(token is TokenKwUndef) { - TokenTypeExpUndef typeExpUndef = new TokenTypeExpUndef(token); + TokenTypeExpUndef typeExpUndef = new(token); token = token.nextToken; return typeExpUndef; } - if(token is TokenType) + if(token is TokenType ttype) { - TokenTypeExpType typeExpType = new TokenTypeExpType(token); - typeExpType.typeToken = (TokenType)token; + TokenTypeExpType typeExpType = new(token) { typeToken = ttype }; token = token.nextToken; return typeExpType; } @@ -3764,13 +3783,12 @@ private TokenRVal GetOperand(ref Token token) // Prefix unary operators (eg ++, --) requiring an L-value. if((token is TokenKwIncr) || (token is TokenKwDecr)) { - TokenRValAsnPre asnPre = new TokenRValAsnPre(token); - asnPre.prefix = token; + TokenRValAsnPre asnPre = new(token) { prefix = token }; token = token.nextToken; TokenRVal op = GetOperand(ref token); if(op == null) return null; - if(!(op is TokenLVal)) + if(op is not TokenLVal) { ErrorMsg(op, "can pre{in,de}crement only an L-value"); return null; @@ -3788,10 +3806,9 @@ private TokenRVal GetOperand(ref Token token) // If followed by '++' or '--', it is post-{in,de}cremented. if((token is TokenKwIncr) || (token is TokenKwDecr)) { - TokenRValAsnPost asnPost = new TokenRValAsnPost(token); - asnPost.postfix = token; + TokenRValAsnPost asnPost = new(token) { postfix = token }; token = token.nextToken; - if(!(operand is TokenLVal)) + if(operand is not TokenLVal) { ErrorMsg(operand, "can post{in,de}crement only an L-value"); return null; @@ -3804,14 +3821,16 @@ private TokenRVal GetOperand(ref Token token) if(token is TokenKwDot) { token = token.nextToken; - if(!(token is TokenName)) + if(token is not TokenName) { ErrorMsg(token, ". must be followed by field/method name"); return null; } - TokenLValIField field = new TokenLValIField(token); - field.baseRVal = operand; - field.fieldName = (TokenName)token; + TokenLValIField field = new(token) + { + baseRVal = operand, + fieldName = (TokenName)token + }; operand = field; token = token.nextToken; goto modifiers; @@ -3820,7 +3839,7 @@ private TokenRVal GetOperand(ref Token token) // If followed by a '[', it is an array subscript. if(token is TokenKwBrkOpen) { - TokenLValArEle tokenLValArEle = new TokenLValArEle(token); + TokenLValArEle tokenLValArEle = new(token); token = token.nextToken; // Parse subscript(s) expression. @@ -3831,15 +3850,16 @@ private TokenRVal GetOperand(ref Token token) return null; } - // See if comma-separated list of values. - TokenRVal subscriptRVals; - int numSubscripts = SplitCommaRVals(tokenLValArEle.subRVal, out subscriptRVals); - if(numSubscripts > 1) + // See if comma-separated list of values. + int numSubscripts = SplitCommaRVals(tokenLValArEle.subRVal, out TokenRVal subscriptRVals); + if (numSubscripts > 1) { - // If so, put the values in an LSL_List object. - TokenRValList rValList = new TokenRValList(tokenLValArEle); - rValList.rVal = subscriptRVals; - rValList.nItems = numSubscripts; + // If so, put the values in an LSL_List object. + TokenRValList rValList = new(tokenLValArEle) + { + rVal = subscriptRVals, + nItems = numSubscripts + }; tokenLValArEle.subRVal = rValList; } @@ -3908,33 +3928,33 @@ private TokenRVal GetOperandNoMods(ref Token token) } // Constants. - if(token is TokenChar) + if(token is TokenChar tchar) { - TokenRValConst rValConst = new TokenRValConst(token, ((TokenChar)token).val); + TokenRValConst rValConst = new(token, tchar.val); token = token.nextToken; return rValConst; } - if(token is TokenFloat) + if(token is TokenFloat tfloat) { - TokenRValConst rValConst = new TokenRValConst(token, ((TokenFloat)token).val); + TokenRValConst rValConst = new(token, tfloat.val); token = token.nextToken; return rValConst; } - if(token is TokenInt) + if(token is TokenInt tint) { - TokenRValConst rValConst = new TokenRValConst(token, ((TokenInt)token).val); + TokenRValConst rValConst = new(token, tint.val); token = token.nextToken; return rValConst; } - if(token is TokenStr) + if(token is TokenStr tstr) { - TokenRValConst rValConst = new TokenRValConst(token, ((TokenStr)token).val); + TokenRValConst rValConst = new(token, tstr.val); token = token.nextToken; return rValConst; } - if(token is TokenKwUndef) + if(token is TokenKwUndef tundef) { - TokenRValUndef rValUndef = new TokenRValUndef((TokenKwUndef)token); + TokenRValUndef rValUndef = new(tundef); token = token.nextToken; return rValUndef; } @@ -3947,26 +3967,27 @@ private TokenRVal GetOperandNoMods(ref Token token) TokenRVal rValAll = ParseRVal(ref token, cmpGTOnly); if(rValAll == null) return null; - TokenRVal rVals; - int nVals = SplitCommaRVals(rValAll, out rVals); - switch(nVals) + int nVals = SplitCommaRVals(rValAll, out TokenRVal rVals); + switch (nVals) { case 3: { - TokenRValVec rValVec = new TokenRValVec(openBkt); - rValVec.xRVal = rVals; - rValVec.yRVal = (TokenRVal)rVals.nextToken; - rValVec.zRVal = (TokenRVal)rVals.nextToken.nextToken; - return rValVec; + return new TokenRValVec(openBkt) + { + xRVal = rVals, + yRVal = (TokenRVal)rVals.nextToken, + zRVal = (TokenRVal)rVals.nextToken.nextToken + }; } case 4: { - TokenRValRot rValRot = new TokenRValRot(openBkt); - rValRot.xRVal = rVals; - rValRot.yRVal = (TokenRVal)rVals.nextToken; - rValRot.zRVal = (TokenRVal)rVals.nextToken.nextToken; - rValRot.wRVal = (TokenRVal)rVals.nextToken.nextToken.nextToken; - return rValRot; + return new TokenRValRot(openBkt) + { + xRVal = rVals, + yRVal = (TokenRVal)rVals.nextToken, + zRVal = (TokenRVal)rVals.nextToken.nextToken, + wRVal = (TokenRVal)rVals.nextToken.nextToken.nextToken + }; } default: { @@ -3980,7 +4001,7 @@ private TokenRVal GetOperandNoMods(ref Token token) // '['value,...']', ie, list if(token is TokenKwBrkOpen) { - TokenRValList rValList = new TokenRValList(token); + TokenRValList rValList = new(token); token = token.nextToken; if(token is TokenKwBrkClose) { @@ -3999,9 +4020,11 @@ private TokenRVal GetOperandNoMods(ref Token token) // Maybe we have . referencing a static field or method of some type. if((token is TokenType) && (token.nextToken is TokenKwDot) && (token.nextToken.nextToken is TokenName)) { - TokenLValSField field = new TokenLValSField(token.nextToken.nextToken); - field.baseType = (TokenType)token; - field.fieldName = (TokenName)token.nextToken.nextToken; + TokenLValSField field = new(token.nextToken.nextToken) + { + baseType = (TokenType)token, + fieldName = (TokenName)token.nextToken.nextToken + }; token = token.nextToken.nextToken.nextToken; return field; } @@ -4009,13 +4032,13 @@ private TokenRVal GetOperandNoMods(ref Token token) // Maybe we have 'this' referring to the object of the instance method. if(token is TokenKwThis) { - if((currentDeclSDType == null) || !(currentDeclSDType is TokenDeclSDTypeClass)) + if((currentDeclSDType == null) || currentDeclSDType is not TokenDeclSDTypeClass) { ErrorMsg(token, "using 'this' outside class definition"); token = SkipPastSemi(token); return null; } - TokenRValThis zhis = new TokenRValThis(token, (TokenDeclSDTypeClass)currentDeclSDType); + TokenRValThis zhis = new(token, (TokenDeclSDTypeClass)currentDeclSDType); token = token.nextToken; return zhis; } @@ -4029,16 +4052,14 @@ private TokenRVal GetOperandNoMods(ref Token token) token = SkipPastSemi(token); return null; } - if(!(token.nextToken is TokenKwDot) || !(token.nextToken.nextToken is TokenName)) + if(token.nextToken is not TokenKwDot || token.nextToken.nextToken is not TokenName nextnexttname) { ErrorMsg(token, "base must be followed by . then field or method name"); - TokenRValThis zhis = new TokenRValThis(token, (TokenDeclSDTypeClass)currentDeclFunc.sdtClass); + TokenRValThis zhis = new(token, (TokenDeclSDTypeClass)currentDeclFunc.sdtClass); token = token.nextToken; return zhis; } - TokenLValBaseField baseField = new TokenLValBaseField(token, - (TokenName)token.nextToken.nextToken, - (TokenDeclSDTypeClass)currentDeclFunc.sdtClass); + TokenLValBaseField baseField = new(token, nextnexttname, (TokenDeclSDTypeClass)currentDeclFunc.sdtClass); token = token.nextToken.nextToken.nextToken; return baseField; } @@ -4048,15 +4069,17 @@ private TokenRVal GetOperandNoMods(ref Token token) // whose CIL code is generated by GenerateNewobjBody(). if(token is TokenKwNew) { - if(!(token.nextToken is TokenType)) + if(token.nextToken is not TokenType) { ErrorMsg(token.nextToken, "new must be followed by type"); token = SkipPastSemi(token); return null; } - TokenLValSField field = new TokenLValSField(token.nextToken.nextToken); - field.baseType = (TokenType)token.nextToken; - field.fieldName = new TokenName(token, "$new"); + TokenLValSField field = new(token.nextToken.nextToken) + { + baseType = (TokenType)token.nextToken, + fieldName = new TokenName(token, "$new") + }; token = token.nextToken.nextToken; return field; } @@ -4064,7 +4087,7 @@ private TokenRVal GetOperandNoMods(ref Token token) // All we got left is , eg, arg, function, global or local variable reference if(token is TokenName) { - TokenLValName name = new TokenLValName((TokenName)token, tokenScript.variablesStack); + TokenLValName name = new((TokenName)token, tokenScript.variablesStack); token = token.nextToken; return name; } @@ -4084,11 +4107,10 @@ private TokenRVal GetOperandNoMods(ref Token token) */ private TokenRValCall ParseRValCall(ref Token token, TokenRVal meth) { - // Set up basic function call struct with function name. - TokenRValCall rValCall = new TokenRValCall(token); - rValCall.meth = meth; + // Set up basic function call struct with function name. + TokenRValCall rValCall = new(token) { meth = meth }; - // Parse the call parameters, if any. + // Parse the call parameters, if any. token = token.nextToken; if(token is TokenKwParClose) { @@ -4115,7 +4137,7 @@ private TokenRValCall ParseRValCall(ref Token token, TokenRVal meth) */ private BinOp GetOperator(ref Token token) { - BinOp binOp = new BinOp(); + BinOp binOp = new(); if(precedence.TryGetValue(token.GetType(), out binOp.preced)) { binOp.token = (TokenKw)token; @@ -4150,7 +4172,7 @@ private class BinOp * @param right = right-hand operand * @returns resultant expression */ - private TokenRVal PerformBinOp(TokenRVal left, BinOp binOp, TokenRVal right) + private static TokenRVal PerformBinOp(TokenRVal left, BinOp binOp, TokenRVal right) { return new TokenRValOpBin(left, binOp.token, right); } @@ -4162,7 +4184,7 @@ private TokenRVal PerformBinOp(TokenRVal left, BinOp binOp, TokenRVal right) * @param right = right-hand operand * @returns resultant constant or expression */ - private TokenRVal PerformUnOp(Token unOp, TokenRVal right) + private static TokenRVal PerformUnOp(Token unOp, TokenRVal right) { return new TokenRValOpUn((TokenKw)unOp, right); } @@ -4177,9 +4199,8 @@ private TokenRVal PerformUnOp(Token unOp, TokenRVal right) */ private TokenRVal ParseRValNewArIni(ref Token token, TokenLValSField newCall) { - Stack stack = new Stack(); - TokenRValNewArIni arini = new TokenRValNewArIni(token); - arini.arrayType = newCall.baseType; + Stack stack = new(); + TokenRValNewArIni arini = new(token) { arrayType = newCall.baseType }; TokenList values = null; while(true) { @@ -4251,7 +4272,7 @@ private TokenRValParen ParseRValParen(ref Token token) token = SkipPastSemi(token); return null; } - TokenRValParen tokenRValParen = new TokenRValParen(token); + TokenRValParen tokenRValParen = new(token); token = token.nextToken; tokenRValParen.rVal = ParseRVal(ref token, parCloseOnly); if(tokenRValParen.rVal == null) @@ -4267,17 +4288,15 @@ private TokenRValParen ParseRValParen(ref Token token) */ private int SplitCommaRVals(TokenRVal rValAll, out TokenRVal rVals) { - if(!(rValAll is TokenRValOpBin) || !(((TokenRValOpBin)rValAll).opcode is TokenKwComma)) + if(rValAll is not TokenRValOpBin opBin || opBin.opcode is not TokenKwComma) { rVals = rValAll; if(rVals.nextToken != null) throw new Exception("expected null"); return 1; } - TokenRValOpBin opBin = (TokenRValOpBin)rValAll; - TokenRVal rValLeft, rValRight; - int leftCount = SplitCommaRVals(opBin.rValLeft, out rValLeft); - int rightCount = SplitCommaRVals(opBin.rValRight, out rValRight); + int leftCount = SplitCommaRVals(opBin.rValLeft, out TokenRVal rValLeft); + int rightCount = SplitCommaRVals(opBin.rValRight, out TokenRVal rValRight); rVals = rValLeft; while(rValLeft.nextToken != null) rValLeft = (TokenRVal)rValLeft.nextToken; @@ -4344,7 +4363,7 @@ public abstract class TokenDeclSDType: Token // see InstantiateGeneric() below public TokenDeclSDType outerSDType; // null if top-level // else points to defining script-defined type - public Dictionary innerSDTypes = new Dictionary(); + public Dictionary innerSDTypes = new(); // indexed by shortName public Token begToken; // token that begins the definition (might be this or something like 'public') public Token endToken; // the '}' or ';' that ends the definition @@ -4354,7 +4373,7 @@ public abstract class TokenDeclSDType: Token public TokenDeclSDTypeClass extends; // only non-null for TokenDeclSDTypeClass's public uint accessLevel; // SDT_PRIVATE, SDT_PROTECTED or SDT_PUBLIC // ... all top-level types are SDT_PUBLIC - public VarDict members = new VarDict(false); // declared fields, methods, properties if any + public VarDict members = new (false); // declared fields, methods, properties if any public Dictionary genParams; // list of parameters for generic prototypes // null for non-generic prototypes @@ -4441,10 +4460,10 @@ public TokenDeclSDType InstantiateGeneric(string name, TokenType[] genArgs, Scri instdecl.outerSDType = this.outerSDType; // The generic prototype may have stuff like 'public' just before it and we need to copy that too. - Token prefix; - for(prefix = this; (prefix = prefix.prevToken) != null;) + Token prefix = this; + while((prefix = prefix.prevToken) != null) { - if(!(prefix is TokenKwPublic) && !(prefix is TokenKwProtected) && !(prefix is TokenKwPrivate)) + if(prefix is not TokenKwPublic && prefix is not TokenKwProtected && prefix is not TokenKwPrivate) break; } this.begToken = prefix.nextToken; @@ -4458,15 +4477,14 @@ public TokenDeclSDType InstantiateGeneric(string name, TokenType[] genArgs, Scri // Splice instantiation (instdecl) in just before the beginning token of prototype (this.begToken). SpliceSourceToken(instdecl); - // Now for the fun part... Copy the rest of the prototype body to the - // instantiated body, replacing all generic parameter type tokens with - // the corresponding generic argument types. Note that the parameters - // are numbered starting with the outermost so we need the full genArgs - // array. Eg if we are doing 'Converter' from - // 'Dictionary.Converter', any V's are - // numbered [2]. Any [0]s or [1]s should be gone by now but it doesn't - // matter. - int index; + // Now for the fun part... Copy the rest of the prototype body to the + // instantiated body, replacing all generic parameter type tokens with + // the corresponding generic argument types. Note that the parameters + // are numbered starting with the outermost so we need the full genArgs + // array. Eg if we are doing 'Converter' from + // 'Dictionary.Converter', any V's are + // numbered [2]. Any [0]s or [1]s should be gone by now but it doesn't + // matter. Token it, pt; TokenDeclSDType innerProto = this; TokenDeclSDType innerInst = instdecl; @@ -4479,10 +4497,9 @@ public TokenDeclSDType InstantiateGeneric(string name, TokenType[] genArgs, Scri // if generic, eg doing Converter of Dictionary.Converter, we have to manually copy the W as well. // 2) outerSDType is transformed from Dictionary to Dictionary. // 3) innerSDTypes is rebuilt when/if we find classes that are inner to this one. - if(pt is TokenDeclSDType) + if(pt is TokenDeclSDType ptSDType) { // Make a new TokenDeclSDType{Class,Delegate,Interface}. - TokenDeclSDType ptSDType = (TokenDeclSDType)pt; TokenDeclSDType itSDType = ptSDType.MakeBlank(new TokenName(ptSDType.shortName, ptSDType.shortName.val)); // Set up the transformed outerSDType. @@ -4507,7 +4524,7 @@ public TokenDeclSDType InstantiateGeneric(string name, TokenType[] genArgs, Scri } // Check for an generic parameter to substitute out. - else if((pt is TokenName) && this.genParams.TryGetValue(((TokenName)pt).val, out index)) + else if((pt is TokenName namept) && this.genParams.TryGetValue(namept.val, out int index)) { it = genArgs[index].CopyToken(pt); } @@ -4561,7 +4578,7 @@ public static TokenDeclSDType ReadFromFile(Dictionary s int line = objFileReader.ReadInt32(); int posn = objFileReader.ReadInt32(); byte code = objFileReader.ReadByte(); - TokenName n = new TokenName(null, file, line, posn, name); + TokenName n = new(null, file, line, posn, name); TokenDeclSDType sdt; switch(code) { @@ -4602,8 +4619,7 @@ public static TokenDeclSDType ReadFromFile(Dictionary s */ protected TokenType MakeTypeToken(string name) { - TokenDeclSDType sdtdecl; - if(sdTypes.TryGetValue(name, out sdtdecl)) + if (sdTypes.TryGetValue(name, out TokenDeclSDType sdtdecl)) return sdtdecl.MakeRefToken(this); return TokenType.FromLSLType(this, name); } @@ -4612,7 +4628,7 @@ protected TokenType MakeTypeToken(string name) public override void DebString(StringBuilder sb) { // get long name broken down into segments from outermost to this - Stack declStack = new Stack(); + Stack declStack = new(); for(TokenDeclSDType decl = this; decl != null; decl = decl.outerSDType) { declStack.Push(decl); @@ -4648,11 +4664,11 @@ public override void DebString(StringBuilder sb) public class TokenDeclSDTypeClass: TokenDeclSDType { - public List implements = new List(); + public List implements = new(); public TokenDeclVar instFieldInit; // $instfieldinit function to do instance field initializations public TokenDeclVar staticFieldInit; // $staticfieldinit function to do static field initializations - public Dictionary intfIndices = new Dictionary(); // longname => this.iFaces index + public Dictionary intfIndices = new(); // longname => this.iFaces index public TokenDeclSDTypeInterface[] iFaces; // array of implemented interfaces // low-end entries copied from rootward classes public TokenDeclVar[][] iImplFunc; // iImplFunc[i][j]: @@ -4664,7 +4680,7 @@ public class TokenDeclSDTypeClass: TokenDeclSDType public int arrayOfRank; // if array, it has this number of dimensions, else zero public bool slotsAssigned; // set true when slots have been assigned... - public XMRInstArSizes instSizes = new XMRInstArSizes(); + public XMRInstArSizes instSizes = new(); // number of instance fields of various types public int numVirtFuncs; // number of virtual functions public int numInterfaces; // number of implemented interfaces @@ -4890,8 +4906,7 @@ public void FillVTables(ScriptObjCode scriptObjCode) { int i = sm.methVTI; string methName = sm.methName; - DynamicMethod dm; - if(scriptObjCode.dynamicMethods.TryGetValue(methName, out dm)) + if (scriptObjCode.dynamicMethods.TryGetValue(methName, out DynamicMethod dm)) { // method is not abstract vDynMeths[i] = dm; @@ -4991,8 +5006,8 @@ public class TokenDeclSDTypeDelegate: TokenDeclSDType private string retStr; private string[] argStrs; - private static Dictionary inlines = new Dictionary(); - private static Dictionary inlrevs = new Dictionary(); + private static Dictionary inlines = new(); + private static Dictionary inlrevs = new(); public TokenDeclSDTypeDelegate(TokenName shortName) : base(shortName) { @@ -5112,10 +5127,7 @@ public override void ReadFromFile(BinaryReader objFileReader, TextWriter asmFile { retStr = objFileReader.ReadString(); int nArgs = objFileReader.ReadInt32(); - if(asmFileWriter != null) - { - asmFileWriter.Write(" delegate " + retStr + " " + longName.val + "("); - } + asmFileWriter?.Write(" delegate " + retStr + " " + longName.val + "("); argStrs = new string[nArgs]; for(int i = 0; i < nArgs; i++) { @@ -5127,10 +5139,7 @@ public override void ReadFromFile(BinaryReader objFileReader, TextWriter asmFile asmFileWriter.Write(argStrs[i]); } } - if(asmFileWriter != null) - { - asmFileWriter.WriteLine(");"); - } + asmFileWriter?.WriteLine(");"); } /** @@ -5138,21 +5147,15 @@ public override void ReadFromFile(BinaryReader objFileReader, TextWriter asmFile */ private void FillInStuff() { - int nArgs; - // This happens when the node was restored via ReadFromFile(). // It leaves the types in retStr/argStrs for resolution after // all definitions have been read from the object file in case // there are forward references. - if(retType == null) - { - retType = MakeTypeToken(retStr); - } + retType ??= MakeTypeToken(retStr); if(argTypes == null) { - nArgs = argStrs.Length; - argTypes = new TokenType[nArgs]; - for(int i = 0; i < nArgs; i++) + argTypes = new TokenType[argStrs.Length]; + for(int i = 0; i < argStrs.Length; i++) { argTypes[i] = MakeTypeToken(argStrs[i]); } @@ -5162,11 +5165,10 @@ private void FillInStuff() // Might as well build the signature strings too from token types. retSysType = retType.ToSysType(); - nArgs = argTypes.Length; - StringBuilder sb = new StringBuilder(); - argSysTypes = new Type[nArgs]; + StringBuilder sb = new(); sb.Append('('); - for(int i = 0; i < nArgs; i++) + argSysTypes = new Type[argTypes.Length]; + for(int i = 0; i < argTypes.Length; i++) { if(i > 0) sb.Append(','); @@ -5191,29 +5193,29 @@ private void FillInStuff() */ public static TokenDeclSDTypeDelegate CreateInline(TokenType retType, TokenType[] argTypes) { - TokenDeclSDTypeDelegate decldel; - - // Name it after the whole signature string. - StringBuilder sb = new StringBuilder("$inline"); + // Name it after the whole signature string. + StringBuilder sb = new("$inline"); sb.Append(retType.ToString()); - sb.Append("("); + sb.Append('('); bool first = true; foreach(TokenType at in argTypes) { if(!first) - sb.Append(","); + sb.Append(','); sb.Append(at.ToString()); first = false; } - sb.Append(")"); + sb.Append(')'); string inlname = sb.ToString(); - if(!inlines.TryGetValue(inlname, out decldel)) + if(!inlines.TryGetValue(inlname, out TokenDeclSDTypeDelegate decldel)) { // Create the corresponding declaration and link to it - TokenName name = new TokenName(null, inlname); - decldel = new TokenDeclSDTypeDelegate(name); - decldel.retType = retType; - decldel.argTypes = argTypes; + TokenName name = new(null, inlname); + decldel = new TokenDeclSDTypeDelegate(name) + { + retType = retType, + argTypes = argTypes + }; inlines.Add(inlname, decldel); inlrevs.Add(decldel.GetSysType(), inlname); } @@ -5222,28 +5224,26 @@ public static TokenDeclSDTypeDelegate CreateInline(TokenType retType, TokenType[ public static string TryGetInlineName(Type sysType) { - string name; - if(!inlrevs.TryGetValue(sysType, out name)) - return null; - return name; + if(inlrevs.TryGetValue(sysType, out string name)) + return name; + return null; } public static Type TryGetInlineSysType(string name) { - TokenDeclSDTypeDelegate decl; - if(!inlines.TryGetValue(name, out decl)) - return null; - return decl.GetSysType(); + if (inlines.TryGetValue(name, out TokenDeclSDTypeDelegate decl)) + return decl.GetSysType(); + return null; } } public class TokenDeclSDTypeInterface: TokenDeclSDType { - public VarDict methsNProps = new VarDict(false); + public VarDict methsNProps = new(false); // any class that implements this interface // must implement all of these methods & properties - public List implements = new List(); + public List implements = new(); // any class that implements this interface // must also implement all of the methods & properties // of all of these interfaces @@ -5358,14 +5358,14 @@ public override TokenType MakeRefToken(Token t) { // if our body is a single type token, that is what we return // otherwise return null saying maybe our body needs some substitutions - if(!(this.nextToken is TokenType)) + if(nextToken is not TokenType) return null; - if(this.nextToken.nextToken != this.endToken) + if(nextToken.nextToken != this.endToken) { - this.nextToken.nextToken.ErrorMsg("extra tokens for typedef"); + nextToken.nextToken.ErrorMsg("extra tokens for typedef"); return null; } - return (TokenType)this.nextToken.CopyToken(t); + return (TokenType)nextToken.CopyToken(t); } public override Type GetSysType() @@ -5482,11 +5482,10 @@ public TokenTypeSDTypeDelegate(Token t, TokenType retType, TokenType[] argTypes, int nArgs = argTypes.Length; foreach(TokenDeclSDType decl in tokenScript.sdSrcTypesValues) { - if(decl is TokenDeclSDTypeDelegate) + if(decl is TokenDeclSDTypeDelegate decldelg) { - decldel = (TokenDeclSDTypeDelegate)decl; - TokenType rt = decldel.GetRetType(); - TokenType[] ats = decldel.GetArgTypes(); + TokenType rt = decldelg.GetRetType(); + TokenType[] ats = decldelg.GetArgTypes(); if((rt.ToString() == retType.ToString()) && (ats.Length == nArgs)) { for(int i = 0; i < nArgs; i++) @@ -5494,7 +5493,7 @@ public TokenTypeSDTypeDelegate(Token t, TokenType retType, TokenType[] argTypes, if(ats[i].ToString() != argTypes[i].ToString()) goto nomatch; } - this.decl = decldel; + this.decl = decldelg; return; } } @@ -5503,19 +5502,19 @@ public TokenTypeSDTypeDelegate(Token t, TokenType retType, TokenType[] argTypes, } // No such luck, create a new anonymous declaration. - StringBuilder sb = new StringBuilder("$anondel$"); + StringBuilder sb = new("$anondel$"); sb.Append(retType.ToString()); - sb.Append("("); + sb.Append('('); bool first = true; foreach(TokenType at in argTypes) { if(!first) - sb.Append(","); + sb.Append(','); sb.Append(at.ToString()); first = false; } - sb.Append(")"); - TokenName name = new TokenName(t, sb.ToString()); + sb.Append(')'); + TokenName name = new(t, sb.ToString()); decldel = new TokenDeclSDTypeDelegate(name); decldel.SetRetArgTypes(retType, argTypes); tokenScript.sdSrcTypesAdd(name.val, decldel); @@ -5607,16 +5606,18 @@ public override void DebString(StringBuilder sb) */ public class TokenArgDecl: Token { - public VarDict varDict = new VarDict(false); + public VarDict varDict = new (false); public TokenArgDecl(Token original) : base(original) { } public bool AddArg(TokenType type, TokenName name) { - TokenDeclVar var = new TokenDeclVar(name, null, null); - var.name = name; - var.type = type; - var.vTableIndex = varDict.Count; + TokenDeclVar var = new (name, null, null) + { + name = name, + type = type, + vTableIndex = varDict.Count + }; return varDict.AddEntry(var); } @@ -5666,10 +5667,7 @@ public TokenDeclVar[] vars private string argSig = null; public string GetArgSig() { - if(argSig == null) - { - argSig = ScriptCodeGen.ArgSigString(types); - } + argSig ??= ScriptCodeGen.ArgSigString(types); return argSig; } } @@ -5748,16 +5746,16 @@ public class TokenDeclVar: TokenStmt public TokenType retType; // vars: null; funcs: TokenTypeVoid if void public TokenArgDecl argDecl; // vars: null; funcs: argument list prototypes public TokenStmtBlock body; // vars: null; funcs: statements (null iff abstract) - public Dictionary labels = new Dictionary(); + public Dictionary labels = new(); // all labels defined in the function - public LinkedList localVars = new LinkedList(); + public LinkedList localVars = new(); // all local variables declared by this function // - doesn't include argument variables public TokenIntfImpl implements; // if script-defined type method, what interface method(s) this func implements public TokenRValCall baseCtorCall; // if script-defined type constructor, call to base constructor, if any public Triviality triviality = Triviality.unknown; // vars: unknown (not used for any thing); funcs: unknown/trivial/complex - public LinkedList unknownTrivialityCalls = new LinkedList(); + public LinkedList unknownTrivialityCalls = new(); // reduction puts all calls here // compilation sorts it all out @@ -5772,10 +5770,7 @@ public class TokenDeclVar: TokenStmt */ public TokenDeclVar(Token original, TokenDeclVar func, TokenScript ts) : base(original) { - if(func != null) - { - func.localVars.AddLast(this); - } + func?.localVars.AddLast(this); tokenScript = ts; } @@ -5816,10 +5811,9 @@ public string fullName return name.val; return funcNameSig.val; } - string ln = sdtClass.longName.val; if(retType == null) - return ln + "." + name.val; - return ln + "." + funcNameSig.val; + return sdtClass.longName.val + "." + name.val; + return sdtClass.longName.val + "." + funcNameSig.val; } } @@ -5878,13 +5872,11 @@ public string GetSimpleName() */ public string GetObjCodeName() { - string objCodeName = ""; if(sdtClass != null) { - objCodeName += sdtClass.longName.val + "."; + return sdtClass.longName.val + "." + funcNameSig.val; } - objCodeName += funcNameSig.val; - return objCodeName; + return funcNameSig.val; } /** @@ -5910,9 +5902,9 @@ public TokenTypeSDTypeDelegate GetDelType() _type = new TokenTypeSDTypeDelegate(this, retType, argDecl.types, tokenScript); } } - if(!(_type is TokenTypeSDTypeDelegate)) - return null; - return (TokenTypeSDTypeDelegate)_type; + if(_type is TokenTypeSDTypeDelegate TokenTypeSDTypeDelegate_type) + return TokenTypeSDTypeDelegate_type; + return null; } /** @@ -6002,7 +5994,7 @@ public override void DebString(StringBuilder sb) } else { - if(!(retType is TokenTypeVoid)) + if(retType is not TokenTypeVoid) { sb.Append(retType.ToString()); sb.Append(' '); @@ -6037,7 +6029,7 @@ public override void DebString(StringBuilder sb) // so we get the initial value assignments done in same order as specified in script public void DebStringInitFields(StringBuilder sb) { - if((retType == null) || !(retType is TokenTypeVoid)) + if(retType is not TokenTypeVoid) throw new Exception("bad return type " + retType.GetType().Name); if(argDecl.vars.Length != 0) throw new Exception("has " + argDecl.vars.Length + " arg(s)"); @@ -6049,47 +6041,44 @@ public void DebStringInitFields(StringBuilder sb) // And the opcode should be a simple assignment operator. TokenRValOpBin rvob = (TokenRValOpBin)rval; - if(!(rvob.opcode is TokenKwAssign)) + if(rvob.opcode is not TokenKwAssign) throw new Exception("bad op type " + rvob.opcode.GetType().Name); // Get field or variable being assigned to. - TokenDeclVar var = null; + TokenDeclVar tdvar = null; TokenRVal left = rvob.rValLeft; - if(left is TokenLValIField) + if(left is TokenLValIField ifield) { - TokenLValIField ifield = (TokenLValIField)left; TokenRValThis zhis = (TokenRValThis)ifield.baseRVal; TokenDeclSDTypeClass sdt = zhis.sdtClass; - var = sdt.members.FindExact(ifield.fieldName.val, null); + tdvar = sdt.members.FindExact(ifield.fieldName.val, null); } - if(left is TokenLValName) + if(left is TokenLValName global) { - TokenLValName global = (TokenLValName)left; - var = global.stack.FindExact(global.name.val, null); + tdvar = global.stack.FindExact(global.name.val, null); } - if(left is TokenLValSField) + if(left is TokenLValSField sfield) { - TokenLValSField sfield = (TokenLValSField)left; TokenTypeSDTypeClass sdtc = (TokenTypeSDTypeClass)sfield.baseType; TokenDeclSDTypeClass decl = sdtc.decl; - var = decl.members.FindExact(sfield.fieldName.val, null); + tdvar = decl.members.FindExact(sfield.fieldName.val, null); } - if(var == null) + if(tdvar == null) throw new Exception("unknown var type " + left.GetType().Name); // Output flags, type name and bare variable name. // This should look like a declaration in the 'sb' // as it is not enclosed in a function. - var.DebStringSDTFlags(sb); - var.type.DebString(sb); + tdvar.DebStringSDTFlags(sb); + tdvar.type.DebString(sb); sb.Append(' '); - sb.Append(var.name.val); + sb.Append(tdvar.name.val); // Maybe it has a non-default initialization value. - if((var.init != null) && !(var.init is TokenRValInitDef)) + if((tdvar.init != null) && tdvar.init is not TokenRValInitDef) { sb.Append(" = "); - var.init.DebString(sb); + tdvar.init.DebString(sb); } // End of declaration statement. @@ -6160,22 +6149,22 @@ public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) TokenType baseType = baseRVal.GetRValType(scg, null); // Maybe referencing element of a fixed-dimension array. - if((baseType is TokenTypeSDTypeClass) && (((TokenTypeSDTypeClass)baseType).decl.arrayOfType != null)) + if((baseType is TokenTypeSDTypeClass bbtype) && bbtype.decl.arrayOfType != null) { - return ((TokenTypeSDTypeClass)baseType).decl.arrayOfType; + return bbtype.decl.arrayOfType; } // Maybe referencing $idxprop property of script-defined class or interface. - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass bc) { - TokenDeclSDTypeClass sdtDecl = ((TokenTypeSDTypeClass)baseType).decl; + TokenDeclSDTypeClass sdtDecl = bc.decl; TokenDeclVar idxProp = scg.FindSingleMember(sdtDecl.members, new TokenName(this, "$idxprop"), null); if(idxProp != null) return idxProp.type; } - if(baseType is TokenTypeSDTypeInterface) + if(baseType is TokenTypeSDTypeInterface bi) { - TokenDeclSDTypeInterface sdtDecl = ((TokenTypeSDTypeInterface)baseType).decl; + TokenDeclSDTypeInterface sdtDecl = bi.decl; TokenDeclVar idxProp = sdtDecl.FindIFaceMember(scg, new TokenName(this, "$idxprop"), null, out sdtDecl); if(idxProp != null) return idxProp.type; @@ -6260,18 +6249,18 @@ public TokenLValIField(Token original) : base(original) { } public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) { TokenType baseType = baseRVal.GetRValType(scg, null); - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); - if(var != null) - return var.type; + TokenDeclVar tvar = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); + if(tvar != null) + return tvar.type; } - if(baseType is TokenTypeSDTypeInterface) + if(baseType is TokenTypeSDTypeInterface TokenTypeSDTypeInterfacebaseType) { - TokenDeclSDTypeInterface baseIntfDecl = ((TokenTypeSDTypeInterface)baseType).decl; - TokenDeclVar var = baseIntfDecl.FindIFaceMember(scg, fieldName, argsig, out baseIntfDecl); - if(var != null) - return var.type; + TokenDeclSDTypeInterface baseIntfDecl = (TokenTypeSDTypeInterfacebaseType).decl; + TokenDeclVar tvar = baseIntfDecl.FindIFaceMember(scg, fieldName, argsig, out baseIntfDecl); + if(tvar != null) + return tvar.type; } if(baseType is TokenTypeArray) { @@ -6297,10 +6286,10 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) // The case of accessing a property, however, depends on the property implementation, // as there could be looping inside the property code. TokenType baseType = baseRVal.GetRValType(scg, null); - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); - return (var != null) && var.IsVarTrivial(scg); + TokenDeclVar tvar = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); + return (tvar != null) && tvar.IsVarTrivial(scg); } // Accessing the members of anything else (arrays, rotations, vectors) is always trivial. @@ -6321,10 +6310,10 @@ public override bool IsCallTrivial(ScriptCodeGen scg, TokenType[] argsig) // Calling a method of a class depends on the method. TokenType baseType = baseRVal.GetRValType(scg, null); - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); - return (var != null) && var.IsFuncTrivial(scg); + TokenDeclVar tvar = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); + return (tvar != null) && tvar.IsFuncTrivial(scg); } // Calling via a pointer to an interface instance is never trivial. @@ -6422,9 +6411,9 @@ public TokenLValSField(Token original) : base(original) { } public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) { - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); + TokenDeclVar var = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); if(var != null) return var.type; } @@ -6439,10 +6428,10 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) // argsig simply serves as selecting which of possibly overloaded methods to select. // The case of accessing a property, however, depends on the property implementation, // as there could be looping inside the property code. - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); - return (var != null) && var.IsVarTrivial(scg); + TokenDeclVar tvar = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); + return (tvar != null) && tvar.IsVarTrivial(scg); } // Accessing the fields/methods/properties of anything else (arrays, rotations, vectors) is always trivial. @@ -6458,10 +6447,10 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) public override bool IsCallTrivial(ScriptCodeGen scg, TokenType[] argsig) { // Calling a static method of a class depends on the method. - if(baseType is TokenTypeSDTypeClass) + if(baseType is TokenTypeSDTypeClass TokenTypeSDTypeClassbaseType) { - TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); - return (var != null) && var.IsFuncTrivial(scg); + TokenDeclVar tvar = scg.FindThisMember(TokenTypeSDTypeClassbaseType, fieldName, argsig); + return (tvar != null) && tvar.IsFuncTrivial(scg); } // Calling a static method of anything else (arrays, rotations, vectors) is always trivial. @@ -6635,7 +6624,7 @@ public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) // Get the type of the method itself. This should get us a delegate type. TokenType delType = meth.GetRValType(scg, myArgSig); - if(!(delType is TokenTypeSDTypeDelegate)) + if(delType is not TokenTypeSDTypeDelegate) { scg.ErrorMsg(meth, "must be function or method"); return new TokenTypeVoid(meth); @@ -6688,7 +6677,7 @@ public override void DebString(StringBuilder sb) t.DebString(sb); first = false; } - sb.Append(")"); + sb.Append(')'); } } @@ -6713,11 +6702,10 @@ public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) { - argsig = null; - if(castTo is TokenTypeSDTypeDelegate) - { - argsig = ((TokenTypeSDTypeDelegate)castTo).decl.GetArgTypes(); - } + if(castTo is TokenTypeSDTypeDelegate tokencastto) + argsig = tokencastto.decl.GetArgTypes(); + else + argsig = null; return rVal.IsRValTrivial(scg, argsig); } @@ -6727,67 +6715,67 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) public override TokenRVal TryComputeConstant(TCCLookup lookup, ref bool didOne) { rVal = rVal.TryComputeConstant(lookup, ref didOne); - if(rVal is TokenRValConst) + if(rVal is TokenRValConst TokenRValConstrVal) { try { - object val = ((TokenRValConst)rVal).val; + object val = TokenRValConstrVal.val; object nval = null; if(castTo is TokenTypeChar) { if(val is char) return rVal; - if(val is int) - nval = (char)(int)val; + if(val is int intval) + nval = (char)intval; } else if (castTo is TokenTypeFloat) { if(val is double) return rVal; - if(val is int) - nval = (double)(int)val; - if(val is string) - nval = new LSL_Float((string)val).value; + if(val is int intval) + nval = (double)intval; + if(val is string sval) + nval = new LSL_Float(sval).value; } else if (castTo is TokenTypeInt) { if(val is int) return rVal; - if(val is char) - nval = (int)(char)val; - if(val is double) - nval = (int)(double)val; - if(val is string) - nval = new LSL_Integer((string)val).value; + if(val is char charval) + nval = (int)charval; + if(val is double dval) + nval = (int)dval; + if(val is string sval) + nval = new LSL_Integer(sval).value; } else if (castTo is TokenTypeRot) { if(val is LSL_Rotation) return rVal; - if(val is string) - nval = new LSL_Rotation((string)val); + if(val is string sval) + nval = new LSL_Rotation(sval); } else if ((castTo is TokenTypeKey) || (castTo is TokenTypeStr)) { if(val is string) nval = val; // in case of key/string conversion - if(val is char) - nval = TypeCast.CharToString((char)val); - if(val is double) - nval = TypeCast.FloatToString((double)val); - if(val is int) - nval = TypeCast.IntegerToString((int)val); - if(val is LSL_Rotation) - nval = TypeCast.RotationToString((LSL_Rotation)val); - if(val is LSL_Vector) - nval = TypeCast.VectorToString((LSL_Vector)val); + if(val is char cval) + nval = TypeCast.CharToString(cval); + if(val is double dval) + nval = TypeCast.FloatToString(dval); + if(val is int ival) + nval = TypeCast.IntegerToString(ival); + if(val is LSL_Rotation lslrot) + nval = TypeCast.RotationToString(lslrot); + if(val is LSL_Vector lslvec) + nval = TypeCast.VectorToString(lslvec); } else if (castTo is TokenTypeVec) { if(val is LSL_Vector) return rVal; - if(val is string) - nval = new LSL_Vector((string)val); + if(val is string sval) + nval = new LSL_Vector(sval); } if(nval != null) @@ -6852,11 +6840,10 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) public override TokenRVal TryComputeConstant(TCCLookup lookup, ref bool didOne) { TokenRVal rValCond = condExpr.TryComputeConstant(lookup, ref didOne); - if(rValCond is TokenRValConst) + if(rValCond is TokenRValConst TokenRValConstrValCond) { didOne = true; - bool isTrue = ((TokenRValConst)rValCond).IsConstBoolTrue(); - return (isTrue ? trueExpr : falseExpr).TryComputeConstant(lookup, ref didOne); + return (TokenRValConstrValCond.IsConstBoolTrue() ? trueExpr : falseExpr).TryComputeConstant(lookup, ref didOne); } return this; } @@ -6886,7 +6873,7 @@ public TokenRValConst(Token original, object value) : base(original) { val = value; - TokenType tt = null; + TokenType tt; if(val is char) { type = TokenRValConstType.CHAR; @@ -6912,7 +6899,7 @@ public TokenRValConst(Token original, object value) : base(original) throw new Exception("invalid constant type " + val.GetType()); } - tokType = (original is TokenType) ? (TokenType)original : tt; + tokType = (original is TokenType type1) ? type1 : tt; if(tokType is TokenTypeKey) { type = TokenRValConstType.KEY; @@ -6992,19 +6979,19 @@ public bool IsConstBoolTrue() public override void DebString(StringBuilder sb) { - if(val is char) + if(val is char charval) { sb.Append('\''); - EscapeQuotes(sb, new string(new char[] { (char)val })); + EscapeQuotes(sb, new string(new char[] { charval })); sb.Append('\''); } - else if(val is int) + else if(val is int intval) { - sb.Append((int)val); + sb.Append(intval); } - else if(val is double) + else if(val is double dval) { - string str = ((double)val).ToString(); + string str = dval.ToString(); sb.Append(str); if((str.IndexOf('.') < 0) && (str.IndexOf('E') < 0) && @@ -7013,10 +7000,10 @@ public override void DebString(StringBuilder sb) sb.Append(".0"); } } - else if(val is string) + else if(val is string sval) { sb.Append('"'); - EscapeQuotes(sb, (string)val); + EscapeQuotes(sb, sval); sb.Append('"'); } else @@ -7074,8 +7061,10 @@ public class TokenRValInitDef: TokenRVal public static TokenRValInitDef Construct(TokenDeclVar tokenDeclVar) { - TokenRValInitDef zhis = new TokenRValInitDef(tokenDeclVar); - zhis.type = tokenDeclVar.type; + TokenRValInitDef zhis = new(tokenDeclVar) + { + type = tokenDeclVar.type + }; return zhis; } private TokenRValInitDef(Token original) : base(original) { } @@ -7193,14 +7182,14 @@ private bool ListIsTrivial(ScriptCodeGen scg, TokenList valList) { foreach(Token val in valList.tl) { - if(val is TokenRVal) + if(val is TokenRVal TokenRValval) { - if(!((TokenRVal)val).IsRValTrivial(scg, null)) + if(!TokenRValval.IsRValTrivial(scg, null)) return false; } - if(val is TokenList) + if(val is TokenList TokenListval) { - if(!ListIsTrivial(scg, (TokenList)val)) + if(!ListIsTrivial(scg, TokenListval)) return false; } } @@ -7217,7 +7206,7 @@ public override void DebString(StringBuilder sb) } public class TokenList: Token { - public List tl = new List(); + public List tl = new(); public TokenList(Token original) : base(original) { } public override void DebString(StringBuilder sb) @@ -7289,8 +7278,7 @@ public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) // Everything else depends on both operands. string key = lType + opstr + rType; - BinOpStr binOpStr; - if(BinOpStr.defined.TryGetValue(key, out binOpStr)) + if(BinOpStr.defined.TryGetValue(key, out BinOpStr binOpStr)) { return TokenType.FromSysType(opcode, binOpStr.outtype); } @@ -7311,17 +7299,16 @@ public override TokenRVal TryComputeConstant(TCCLookup lookup, ref bool didOne) { rValLeft = rValLeft.TryComputeConstant(lookup, ref didOne); rValRight = rValRight.TryComputeConstant(lookup, ref didOne); - if((rValLeft is TokenRValConst) && (rValRight is TokenRValConst)) + if((rValLeft is TokenRValConst TRValConstrValLeft) && (rValRight is TokenRValConst TRValConstrValRight)) { -// try + //try { - object val = opcode.binOpConst(((TokenRValConst)rValLeft).val, - ((TokenRValConst)rValRight).val); + object val = opcode.binOpConst(TRValConstrValLeft.val, TRValConstrValRight.val); TokenRVal rValConst = new TokenRValConst(opcode, val); didOne = true; return rValConst; } -// catch + //catch { } } @@ -7371,11 +7358,11 @@ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) public override TokenRVal TryComputeConstant(TCCLookup lookup, ref bool didOne) { rVal = rVal.TryComputeConstant(lookup, ref didOne); - if(rVal is TokenRValConst) + if(rVal is TokenRValConst TokenRValConstrVal) { try { - object val = opcode.unOpConst(((TokenRValConst)rVal).val); + object val = opcode.unOpConst(TokenRValConstrVal.val); TokenRVal rValConst = new TokenRValConst(opcode, val); didOne = true; return rValConst; @@ -7520,7 +7507,7 @@ public override void DebString(StringBuilder sb) */ public class TokenRValUndef: TokenRVal { - Token original; + readonly Token original; public TokenRValUndef(Token original) : base(original) { @@ -7586,12 +7573,12 @@ public class TokenScript: Token { public int expiryDays = Int32.MaxValue; public TokenDeclState defaultState; - public Dictionary states = new Dictionary(); - public VarDict variablesStack = new VarDict(false); // initial one is used for global functions and variables + public Dictionary states = new(); + public VarDict variablesStack = new (false); // initial one is used for global functions and variables public TokenDeclVar globalVarInit; // $globalvarinit function // - performs explicit global var and static field inits - private Dictionary sdSrcTypes = new Dictionary(); + private Dictionary sdSrcTypes = new(); private bool sdSrcTypesSealed = false; public TokenScript(Token original) : base(original) { } @@ -7883,11 +7870,9 @@ public override void DebString(StringBuilder sb) initStmt.DebString(sb); else sb.Append(';'); - if(testRVal != null) - testRVal.DebString(sb); + testRVal?.DebString(sb); sb.Append(';'); - if(incrRVal != null) - incrRVal.DebString(sb); + incrRVal?.DebString(sb); sb.Append(") "); bodyStmt.DebString(sb); } @@ -7909,11 +7894,9 @@ public TokenStmtForEach(Token original) : base(original) { } public override void DebString(StringBuilder sb) { sb.Append("foreach ("); - if(keyLVal != null) - keyLVal.DebString(sb); + keyLVal?.DebString(sb); sb.Append(','); - if(valLVal != null) - valLVal.DebString(sb); + valLVal?.DebString(sb); sb.Append(" in "); arrayRVal.DebString(sb); sb.Append(')'); @@ -7934,7 +7917,7 @@ public override void DebString(StringBuilder sb) { sb.Append("if "); testRVal.DebString(sb); - sb.Append(" "); + sb.Append(' '); trueStmt.DebString(sb); if(elseStmt != null) { @@ -8099,7 +8082,7 @@ public class TokenStmtTry: TokenStmt public TokenDeclVar catchVar; // null iff catchStmt is null public TokenStmtBlock catchStmt; // can be null public TokenStmtBlock finallyStmt; // can be null - public Dictionary iLeaves = new Dictionary(); + public Dictionary iLeaves = new(); public TokenStmtTry(Token original) : base(original) { } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs index 7b270d66fe0..334b84344e9 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs @@ -26,7 +26,6 @@ */ using OpenSim.Region.ScriptEngine.Shared.ScriptBase; -using OpenSim.Region.ScriptEngine.Yengine; using System; using System.Collections.Generic; using System.Reflection; @@ -108,65 +107,64 @@ public class TypeCast */ private static Dictionary CreateLegalTypeCasts() { - Dictionary ltc = new Dictionary(); - - // IMPLICIT type casts (a space is in middle of the key) - // EXPLICIT type casts (an * is in middle of the key) - // In general, only mark explicit if it might throw an exception - ltc.Add("array object", TypeCastArray2Object); - ltc.Add("bool float", TypeCastBool2Float); - ltc.Add("bool integer", TypeCastBool2Integer); - ltc.Add("bool list", TypeCastBool2List); - ltc.Add("bool object", TypeCastBool2Object); - ltc.Add("bool string", TypeCastBool2String); - ltc.Add("char integer", TypeCastChar2Integer); - ltc.Add("char list", TypeCastChar2List); - ltc.Add("char object", TypeCastChar2Object); - ltc.Add("char string", TypeCastChar2String); - ltc.Add("exception list", TypeCastExc2List); - ltc.Add("exception object", TypeCastExc2Object); - ltc.Add("exception string", TypeCastExc2String); - ltc.Add("float bool", TypeCastFloat2Bool); - ltc.Add("float*integer", TypeCastFloat2Integer); - ltc.Add("float list", TypeCastFloat2List); - ltc.Add("float object", TypeCastFloat2Object); - ltc.Add("float string", TypeCastFloat2String); - ltc.Add("integer bool", TypeCastInteger2Bool); - ltc.Add("integer char", TypeCastInteger2Char); - ltc.Add("integer float", TypeCastInteger2Float); - ltc.Add("integer list", TypeCastInteger2List); - ltc.Add("integer object", TypeCastInteger2Object); - ltc.Add("integer string", TypeCastInteger2String); - ltc.Add("list bool", TypeCastList2Bool); - ltc.Add("list object", TypeCastList2Object); - ltc.Add("list string", TypeCastList2String); - ltc.Add("object*array", TypeCastObject2Array); - ltc.Add("object*bool", TypeCastObject2Bool); - ltc.Add("object*char", TypeCastObject2Char); - ltc.Add("object*exception", TypeCastObject2Exc); - ltc.Add("object*float", TypeCastObject2Float); - ltc.Add("object*integer", TypeCastObject2Integer); - ltc.Add("object*list", TypeCastObject2List); - ltc.Add("object*rotation", TypeCastObject2Rotation); - ltc.Add("object string", TypeCastObject2String); - ltc.Add("object*vector", TypeCastObject2Vector); - ltc.Add("rotation bool", TypeCastRotation2Bool); - ltc.Add("rotation list", TypeCastRotation2List); - ltc.Add("rotation object", TypeCastRotation2Object); - ltc.Add("rotation string", TypeCastRotation2String); - ltc.Add("string bool", TypeCastString2Bool); - ltc.Add("string*float", TypeCastString2Float); - ltc.Add("string*integer", TypeCastString2Integer); - ltc.Add("string list", TypeCastString2List); - ltc.Add("string object", TypeCastString2Object); - ltc.Add("string*rotation", TypeCastString2Rotation); - ltc.Add("string*vector", TypeCastString2Vector); - ltc.Add("vector bool", TypeCastVector2Bool); - ltc.Add("vector list", TypeCastVector2List); - ltc.Add("vector object", TypeCastVector2Object); - ltc.Add("vector string", TypeCastVector2String); - - return ltc; + return new Dictionary + { + // IMPLICIT type casts (a space is in middle of the key) + // EXPLICIT type casts (an * is in middle of the key) + // In general, only mark explicit if it might throw an exception + { "array object", TypeCastArray2Object }, + { "bool float", TypeCastBool2Float }, + { "bool integer", TypeCastBool2Integer }, + { "bool list", TypeCastBool2List }, + { "bool object", TypeCastBool2Object }, + { "bool string", TypeCastBool2String }, + { "char integer", TypeCastChar2Integer }, + { "char list", TypeCastChar2List }, + { "char object", TypeCastChar2Object }, + { "char string", TypeCastChar2String }, + { "exception list", TypeCastExc2List }, + { "exception object", TypeCastExc2Object }, + { "exception string", TypeCastExc2String }, + { "float bool", TypeCastFloat2Bool }, + { "float*integer", TypeCastFloat2Integer }, + { "float list", TypeCastFloat2List }, + { "float object", TypeCastFloat2Object }, + { "float string", TypeCastFloat2String }, + { "integer bool", TypeCastInteger2Bool }, + { "integer char", TypeCastInteger2Char }, + { "integer float", TypeCastInteger2Float }, + { "integer list", TypeCastInteger2List }, + { "integer object", TypeCastInteger2Object }, + { "integer string", TypeCastInteger2String }, + { "list bool", TypeCastList2Bool }, + { "list object", TypeCastList2Object }, + { "list string", TypeCastList2String }, + { "object*array", TypeCastObject2Array }, + { "object*bool", TypeCastObject2Bool }, + { "object*char", TypeCastObject2Char }, + { "object*exception", TypeCastObject2Exc }, + { "object*float", TypeCastObject2Float }, + { "object*integer", TypeCastObject2Integer }, + { "object*list", TypeCastObject2List }, + { "object*rotation", TypeCastObject2Rotation }, + { "object string", TypeCastObject2String }, + { "object*vector", TypeCastObject2Vector }, + { "rotation bool", TypeCastRotation2Bool }, + { "rotation list", TypeCastRotation2List }, + { "rotation object", TypeCastRotation2Object }, + { "rotation string", TypeCastRotation2String }, + { "string bool", TypeCastString2Bool }, + { "string*float", TypeCastString2Float }, + { "string*integer", TypeCastString2Integer }, + { "string list", TypeCastString2List }, + { "string object", TypeCastString2Object }, + { "string*rotation", TypeCastString2Rotation }, + { "string*vector", TypeCastString2Vector }, + { "vector bool", TypeCastVector2Bool }, + { "vector list", TypeCastVector2List }, + { "vector object", TypeCastVector2Object }, + { "vector string", TypeCastVector2String } + }; } /** @@ -178,12 +176,14 @@ private static Dictionary CreateLegalTypeCasts() */ public static bool IsAssignableFrom(TokenType dstType, TokenType srcType) { - // Do a 'dry run' of the casting operation, discarding any emits and not printing any errors. - // But if the casting tries to print error(s), return false. - // Otherwise assume the cast is allowed and return true. - SCGIAF scg = new SCGIAF(); - scg.ok = true; - scg._ilGen = migiaf; + // Do a 'dry run' of the casting operation, discarding any emits and not printing any errors. + // But if the casting tries to print error(s), return false. + // Otherwise assume the cast is allowed and return true. + SCGIAF scg = new() + { + ok = true, + _ilGen = migiaf + }; CastTopOfStack(scg, null, srcType, dstType, false); return scg.ok; } @@ -332,25 +332,25 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o } // Script-defined classes can be cast up and down the tree. - if((oldType is TokenTypeSDTypeClass) && (newType is TokenTypeSDTypeClass)) + if((oldType is TokenTypeSDTypeClass oldT) && (newType is TokenTypeSDTypeClass newT)) { - TokenDeclSDTypeClass oldSDTC = ((TokenTypeSDTypeClass)oldType).decl; - TokenDeclSDTypeClass newSDTC = ((TokenTypeSDTypeClass)newType).decl; + TokenDeclSDTypeClass oldSDTC = oldT.decl; + TokenDeclSDTypeClass newSDTC2 = newT.decl; // implicit cast allowed from leaf toward root - for(TokenDeclSDTypeClass sdtc = oldSDTC; sdtc != null; sdtc = sdtc.extends) + for(TokenDeclSDTypeClass sdtc = oldSDTC; sdtc is not null; sdtc = sdtc.extends) { - if(sdtc == newSDTC) + if(sdtc == newSDTC2) return; } // explicit cast allowed from root toward leaf - for(TokenDeclSDTypeClass sdtc = newSDTC; sdtc != null; sdtc = sdtc.extends) + for(TokenDeclSDTypeClass sdtc = newSDTC2; sdtc is not null; sdtc = sdtc.extends) { if(sdtc == oldSDTC) { ExplCheck(scg, errorAt, explicitAllowed, oldString, newString); - scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4, newSDTC.sdTypeIndex); + scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4, newSDTC2.sdTypeIndex); scg.ilGen.Emit(errorAt, OpCodes.Call, sdTypeClassCastClass2ClassMethodInfo); return; } @@ -363,10 +363,10 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o // One script-defined interface type cannot be cast to another script-defined interface type, // unless the old interface declares that it implements the new interface. That proves that // the underlying object, no matter what type, implements the new interface. - if((oldType is TokenTypeSDTypeInterface) && (newType is TokenTypeSDTypeInterface)) + if((oldType is TokenTypeSDTypeInterface oldT2) && (newType is TokenTypeSDTypeInterface newT2)) { - TokenDeclSDTypeInterface oldDecl = ((TokenTypeSDTypeInterface)oldType).decl; - TokenDeclSDTypeInterface newDecl = ((TokenTypeSDTypeInterface)newType).decl; + TokenDeclSDTypeInterface oldDecl = oldT2.decl; + TokenDeclSDTypeInterface newDecl = newT2.decl; if(!oldDecl.Implements(newDecl)) goto illcast; scg.ilGen.Emit(errorAt, OpCodes.Ldstr, newType.ToString()); @@ -377,9 +377,9 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o // A script-defined class type can be implicitly cast to a script-defined interface type that it // implements. The result is an array of delegates that give the class's implementation of the // various methods defined by the interface. - if((oldType is TokenTypeSDTypeClass) && (newType is TokenTypeSDTypeInterface)) + if((oldType is TokenTypeSDTypeClass oldtc) && (newType is TokenTypeSDTypeInterface)) { - TokenDeclSDTypeClass oldSDTC = ((TokenTypeSDTypeClass)oldType).decl; + TokenDeclSDTypeClass oldSDTC = oldtc.decl; int intfIndex; if(!oldSDTC.intfIndices.TryGetValue(newType.ToString(), out intfIndex)) goto illcast; @@ -394,11 +394,8 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o // object and making sure it casts to the correct script-defined class type. // // But then only if the class type implements the interface type. - if((oldType is TokenTypeSDTypeInterface) && (newType is TokenTypeSDTypeClass)) + if((oldType is TokenTypeSDTypeInterface oldSDTI) && (newType is TokenTypeSDTypeClass newSDTC)) { - TokenTypeSDTypeInterface oldSDTI = (TokenTypeSDTypeInterface)oldType; - TokenTypeSDTypeClass newSDTC = (TokenTypeSDTypeClass)newType; - if(!newSDTC.decl.CanCastToIntf(oldSDTI.decl)) goto illcast; @@ -448,10 +445,10 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o // Script-defined classes can be explicitly cast from objects and other script-defined classes. // Note that we must manually check that it is the correct SDTypeClass however because as far as // mono is concerned, all SDTypeClass's are the same. - if((oldType is TokenTypeObject) && (newType is TokenTypeSDTypeClass)) + if((oldType is TokenTypeObject) && (newType is TokenTypeSDTypeClass newT3)) { ExplCheck(scg, errorAt, explicitAllowed, oldString, newString); - scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4, ((TokenTypeSDTypeClass)newType).decl.sdTypeIndex); + scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4, newT3.decl.sdTypeIndex); scg.ilGen.Emit(errorAt, OpCodes.Call, sdTypeClassCastClass2ClassMethodInfo); return; } @@ -487,7 +484,7 @@ public static void CastTopOfStack(IScriptCodeGen scg, Token errorAt, TokenType o illcast: scg.ErrorMsg(errorAt, "illegal to cast from " + oldString + " to " + newString); - if(!(oldType is TokenTypeVoid)) + if(oldType is not TokenTypeVoid) scg.ilGen.Emit(errorAt, OpCodes.Pop); scg.PushDefaultValue(newType); } @@ -833,7 +830,7 @@ public static string ListToString(LSL_List x) } public static string ObjectToString(object x) { - return (x == null) ? null : x.ToString(); + return x?.ToString(); } public static string RotationToString(LSL_Rotation x) { @@ -878,27 +875,34 @@ public static LSL_List StringToList(string s) public static double ObjectToFloat(object x) { - if(x is LSL_String) - return double.Parse(((LSL_String)x).m_string); - if(x is string) - return double.Parse((string)x); - if(x is LSL_Float) - return (double)(LSL_Float)x; - if(x is LSL_Integer) - return (double)(int)(LSL_Integer)x; - if(x is int) - return (double)(int)x; + if(x is LSL_String lsx) + return double.Parse(lsx.m_string); + if(x is string sx) + return double.Parse(sx); + if(x is LSL_Float lfx) + return lfx.value; + if(x is LSL_Integer lix) + return lix.value; + if(x is int ix) + return ix; return (double)x; } public static int ObjectToInteger(object x) { - if(x is LSL_String) - return int.Parse(((LSL_String)x).m_string); - if(x is string) - return int.Parse((string)x); - if(x is LSL_Integer) - return (int)(LSL_Integer)x; + if (x is int ix) + return ix; + if (x is LSL_Integer lix) + return lix.value; + if (x is LSL_String lsx) + return int.Parse(lsx.m_string); + if(x is string sx) + return int.Parse(sx); + if (x is LSL_Float lfx) + return (int)lfx.value; + if (x is double dx) + return (int)dx; + return (int)x; } @@ -909,19 +913,19 @@ public static LSL_List ObjectToList(object x) public static LSL_Rotation ObjectToRotation(object x) { - if(x is LSL_String) - return new LSL_Rotation(((LSL_String)x).m_string); - if(x is string) - return new LSL_Rotation((string)x); + if(x is LSL_String lsx) + return new LSL_Rotation(lsx.m_string); + if(x is string sx) + return new LSL_Rotation(sx); return (LSL_Rotation)x; } public static LSL_Vector ObjectToVector(object x) { - if(x is LSL_String) - return new LSL_Vector(((LSL_String)x).m_string); - if(x is string) - return new LSL_Vector((string)x); + if(x is LSL_String lsx) + return new LSL_Vector(lsx); + if(x is string sx) + return new LSL_Vector(sx); return (LSL_Vector)x; } @@ -937,44 +941,38 @@ public static string ExceptionToString(Exception x, XMRInstAbstract inst) */ public static double EHArgUnwrapFloat(object x) { - if(x is LSL_Float) - return (double)(LSL_Float)x; + if(x is LSL_Float lfx) + return lfx.value; return (double)x; } public static int EHArgUnwrapInteger(object x) { - if(x is LSL_Integer) - return (int)(LSL_Integer)x; + if(x is LSL_Integer lix) + return lix.value; return (int)x; } public static LSL_Rotation EHArgUnwrapRotation(object x) { - if(x is OpenMetaverse.Quaternion) - { - OpenMetaverse.Quaternion q = (OpenMetaverse.Quaternion)x; - return new LSL_Rotation(q.X, q.Y, q.Z, q.W); - } + if(x is OpenMetaverse.Quaternion oqx) + return new LSL_Rotation(oqx); return (LSL_Rotation)x; } public static string EHArgUnwrapString(object x) { - if(x is LSL_Key) - return (string)(LSL_Key)x; - if(x is LSL_String) - return (string)(LSL_String)x; + if(x is LSL_Key lkx) + return lkx.m_string; + if(x is LSL_String sx) + return sx.m_string; return (string)x; } public static LSL_Vector EHArgUnwrapVector(object x) { - if(x is OpenMetaverse.Vector3) - { - OpenMetaverse.Vector3 v = (OpenMetaverse.Vector3)x; - return new LSL_Vector(v.X, v.Y, v.Z); - } + if(x is OpenMetaverse.Vector3 ovx) + return new LSL_Vector(ovx); return (LSL_Vector)x; } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs index 662a09fc600..4e00c8f1189 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs @@ -106,7 +106,7 @@ private struct TDVEntry private bool isFrozen = false; private bool locals; - private Dictionary> master = new Dictionary>(); + private Dictionary> master = new(); private int count = 0; private VarDict frozenLocals = null; @@ -131,16 +131,15 @@ public bool AddEntry(TokenDeclVar var) } // Make sure we have a sub-dictionary based on the bare name (ie, no signature) - Dictionary typedic; - if(!master.TryGetValue(var.name.val, out typedic)) + if(!master.TryGetValue(var.name.val, out Dictionary typedic)) { typedic = new Dictionary(); master.Add(var.name.val, typedic); } - // See if there is an entry in the sub-dictionary that matches the argument signature. - // Note that fields have null argument lists. - // Methods always have a non-null argument list, even if only 0 entries long. + // See if there is an entry in the sub-dictionary that matches the argument signature. + // Note that fields have null argument lists. + // Methods always have a non-null argument list, even if only 0 entries long. ArgTypes types; types.argTypes = (var.argDecl == null) ? null : KeyTypesToStringTypes(var.argDecl.types); if(typedic.ContainsKey(types)) diff --git a/OpenSim/Region/ScriptEngine/YEngine/OpenSim.Region.ScriptEngine.YEngine.csproj b/OpenSim/Region/ScriptEngine/YEngine/OpenSim.Region.ScriptEngine.YEngine.csproj index b897edadfc0..357c34e1d5d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/OpenSim.Region.ScriptEngine.YEngine.csproj +++ b/OpenSim/Region/ScriptEngine/YEngine/OpenSim.Region.ScriptEngine.YEngine.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.ScriptEngine.YEngine http://opensimulator.org OpenSim diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs index ed4747b8ec7..9f23a670630 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs @@ -41,6 +41,9 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using SharedEventParams = OpenSim.Region.ScriptEngine.Shared.EventParams; +using SharedScriptBaseClass = OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass; + namespace OpenSim.Region.ScriptEngine.Yengine { public partial class Yengine @@ -253,8 +256,7 @@ private void XmrTestPev(string[] args, int indx) return; i++; } - ScriptEngine.Shared.EventParams eps = - new ScriptEngine.Shared.EventParams(eventname, paramvalues, zeroDetectParams); + SharedEventParams eps = new SharedEventParams(eventname, paramvalues, zeroDetectParams); // Scan instance list to find those that match selection criteria. if(!Monitor.TryEnter(m_InstancesDict, 100)) @@ -367,7 +369,7 @@ private object ParseParamValue(ref Token token) } if(token is TokenName) { - FieldInfo field = typeof(ScriptEngine.Shared.ScriptBase.ScriptBaseClass).GetField(((TokenName)token).val); + FieldInfo field = typeof(SharedScriptBaseClass).GetField(((TokenName)token).val); if((field != null) && field.IsPublic && (field.IsLiteral || (field.IsStatic && field.IsInitOnly))) { return field.GetValue(null); diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs index 59b40d52261..a504c90cd8e 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREngine.cs @@ -32,10 +32,7 @@ using Mono.Addins; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Monitoring; -using OpenSim.Region.ClientStack.Linden; -using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.ScriptEngine.Interfaces; @@ -48,6 +45,7 @@ using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Timers; @@ -61,20 +59,21 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; -[assembly: Addin("YEngine", OpenSim.VersionInfo.AssemblyVersionNumber)] -[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.AssemblyVersionNumber)] +using SceneScriptEvents = OpenSim.Region.Framework.Scenes.scriptEvents; + +[assembly: Addin("YEngine", OpenSim.VersionInfo.VersionNumber)] +[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] namespace OpenSim.Region.ScriptEngine.Yengine { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "YEngine")] - public partial class Yengine: INonSharedRegionModule, IScriptEngine, - IScriptModule + [Mono.Addins.Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "YEngine")] + public partial class Yengine: INonSharedRegionModule, IScriptEngine, IScriptModule { - public static readonly DetectParams[] zeroDetectParams = new DetectParams[0]; - private static ArrayList noScriptErrors = new ArrayList(); - public static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static readonly string[] scriptReferencedAssemblies = new string[0]; + public static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public static readonly DetectParams[] zeroDetectParams = Array.Empty(); + private static ArrayList noScriptErrors = new(); + private static readonly string[] scriptReferencedAssemblies = Array.Empty(); private bool m_LateInit; private bool m_TraceCalls; @@ -88,10 +87,10 @@ public partial class Yengine: INonSharedRegionModule, IScriptEngine, private string m_ScriptBasePath; private bool m_Enabled = false; public bool m_StartProcessing = false; - private Dictionary m_ScriptErrors = new Dictionary(); - private Dictionary> m_ObjectItemList = new Dictionary>(); - private Dictionary m_ObjectInstArray = new Dictionary(); - public Dictionary m_XMRInstanceApiCtxFieldInfos = new Dictionary(); + private Dictionary m_ScriptErrors = new(); + private Dictionary> m_ObjectItemList = new(); + private Dictionary m_ObjectInstArray = new(); + public Dictionary m_XMRInstanceApiCtxFieldInfos = new(); public int m_StackSize; private int m_HeapSize; private Thread m_SleepThread = null; @@ -102,7 +101,7 @@ public partial class Yengine: INonSharedRegionModule, IScriptEngine, private System.Timers.Timer m_MaintenanceTimer; public int numThreadScriptWorkers; - private object m_FrameUpdateLock = new object(); + private object m_FrameUpdateLock = new(); private event ThreadStart m_FrameUpdateList = null; // Various instance lists: @@ -112,12 +111,11 @@ public partial class Yengine: INonSharedRegionModule, IScriptEngine, // m_YieldQueue = instances that are ready to run right now // m_SleepQueue = instances that have m_SleepUntil valid // sorted by ascending m_SleepUntil - private Dictionary m_InstancesDict = - new Dictionary(); - public Queue m_ThunkQueue = new Queue(); - public XMRInstQueue m_StartQueue = new XMRInstQueue(); - public XMRInstQueue m_YieldQueue = new XMRInstQueue(); - public XMRInstQueue m_SleepQueue = new XMRInstQueue(); + private Dictionary m_InstancesDict = new(); + public Queue m_ThunkQueue = new(); + public XMRInstQueue m_StartQueue = new(); + public XMRInstQueue m_YieldQueue = new(); + public XMRInstQueue m_SleepQueue = new(); private string m_LockedDict = "nobody"; private ThreadPriority m_workersPrio; public Yengine() @@ -126,6 +124,7 @@ public Yengine() public string Name { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return "YEngine"; @@ -134,6 +133,7 @@ public string Name public Type ReplaceableInterface { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return null; @@ -142,6 +142,7 @@ public Type ReplaceableInterface public string ScriptEnginePath { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_ScriptBasePath; @@ -150,6 +151,7 @@ public string ScriptEnginePath public string ScriptClassName { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return "YEngineScript"; @@ -158,6 +160,7 @@ public string ScriptClassName public string ScriptBaseClassName { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return typeof(XMRInstance).FullName; @@ -166,6 +169,7 @@ public string ScriptBaseClassName public ParameterInfo[] ScriptBaseClassParameters { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return typeof(XMRInstance).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); @@ -174,6 +178,7 @@ public ParameterInfo[] ScriptBaseClassParameters public string[] ScriptReferencedAssemblies { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return scriptReferencedAssemblies; @@ -219,25 +224,11 @@ public void Initialise(IConfigSource config) bool err = false; for(int i = 0; i < (int)ScriptEventCode.Size; i++) { - string mycode = "undefined"; - string oscode = "undefined"; - try - { - mycode = ((ScriptEventCode)i).ToString(); - Convert.ToInt64(mycode); - mycode = "undefined"; - } - catch { } - try - { - oscode = ((Framework.Scenes.scriptEvents)(1ul << i)).ToString(); - Convert.ToInt64(oscode); - oscode = "undefined"; - } - catch { } + string mycode = Enum.GetName(typeof(ScriptEventCode), i); + string oscode = Enum.GetName(typeof(SceneScriptEvents), 1UL << i); if(mycode != oscode) { - m_log.ErrorFormat("[YEngine]: {0} mycode={1}, oscode={2}", i, mycode, oscode); + m_log.ErrorFormat($"[YEngine]: {i} mycode={mycode}, oscode={oscode}"); err = true; } } @@ -334,8 +325,8 @@ public void AddRegion(Scene scene) private void OneTimeLateInitialization() { // Build list of defined APIs and their 'this' types and define a field in XMRInstanceSuperType. - ApiManager am = new ApiManager(); - Dictionary apiCtxTypes = new Dictionary(); + ApiManager am = new(); + Dictionary apiCtxTypes = new(); foreach(string api in am.GetApis()) { m_log.Debug("[YEngine]: adding api " + api); @@ -345,8 +336,8 @@ private void OneTimeLateInitialization() apiCtxType = typeof(XMRLSL_Api); apiCtxTypes[api] = apiCtxType; } - - if(ScriptCodeGen.xmrInstSuperType == null) // Only create type once! + bool doSuper = ScriptCodeGen.xmrInstSuperType == null; + if (doSuper) // Only create type once! { // Start creating type XMRInstanceSuperType that contains a field // m_ApiManager_ that points to the per-instance context @@ -359,9 +350,12 @@ private void OneTimeLateInitialization() // public OSSL_Api m_ApiManager_OSSL; // 'this' value for all os...() functions // .... // } - AssemblyName assemblyName = new AssemblyName(); - assemblyName.Name = "XMRInstanceSuperAssembly"; - AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); + AssemblyName assemblyName = new() + { + Name = "XMRInstanceSuperAssembly" + }; + //AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); + AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndCollect); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("XMRInstanceSuperModule"); TypeBuilder typeBuilder = moduleBuilder.DefineType("XMRInstanceSuperType", TypeAttributes.Public | TypeAttributes.Class); typeBuilder.SetParent(typeof(XMRInstance)); @@ -414,7 +408,7 @@ private void OneTimeLateInitialization() MethodInfo mi = m.Method; try { - CommsCallCodeGen cccg = new CommsCallCodeGen(mi, comms, m_XMRInstanceApiCtxFieldInfos["MOD"]); + CommsCallCodeGen cccg = new(mi, comms, m_XMRInstanceApiCtxFieldInfos["MOD"]); Verbose("[YEngine]: added comms function " + cccg.fullName); } catch(Exception e) @@ -424,6 +418,9 @@ private void OneTimeLateInitialization() } } + //only do this once since constants are static + if(doSuper) + { // Add constants to list of built-in constants. Dictionary consts = comms.GetConstants(); foreach(KeyValuePair kvp in consts) @@ -440,6 +437,7 @@ private void OneTimeLateInitialization() } } } + } else { Verbose("[YEngine]: comms not enabled"); @@ -486,9 +484,7 @@ public CommsCallCodeGen(MethodInfo mi, IScriptModuleComms comms, FieldInfo apict : base(null, false, NameArgSig(mi), RetType(mi)) { methName = mi.Name; - string modInvokerName = comms.LookupModInvocation(methName); - if(modInvokerName == null) - throw new Exception("cannot find comms method " + methName); + string modInvokerName = comms.LookupModInvocation(methName) ?? throw new Exception("cannot find comms method " + methName); modInvokerMeth = typeof(MOD_Api).GetMethod(modInvokerName, modInvokerArgTypes); xmrInstModApiCtxField = apictxfi; } @@ -496,7 +492,7 @@ public CommsCallCodeGen(MethodInfo mi, IScriptModuleComms comms, FieldInfo apict // script-visible name(argtype,...) signature string private static string NameArgSig(MethodInfo mi) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.Append(mi.Name); sb.Append('('); ParameterInfo[] mps = mi.GetParameters(); @@ -599,7 +595,7 @@ public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp resu // push to stack converting to the LSL-wrapped type // then convert to object by boxing if necessary - Type boxit = null; + Type boxit; if(argtype is TokenTypeLSLFloat) { args[i].PushVal(scg, errorAt); @@ -676,9 +672,7 @@ public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp resu // The 3rd arg to Pop() is the type on the stack, // ie, what modInvoker?() actually returns. // The Pop() method will wrap/unwrap as needed. - Type retSysType = modInvokerMeth.ReturnType; - if(retSysType == null) - retSysType = typeof(void); + Type retSysType = modInvokerMeth.ReturnType ?? typeof(void); TokenType retTokType = TokenType.FromSysType(errorAt, retSysType); result.Pop(scg, errorAt, retTokType); } @@ -713,8 +707,8 @@ public void RemoveRegion(Scene scene) lock(m_SleepQueue) Monitor.PulseAll(m_SleepQueue); - if(!m_SleepThread.Join(250)) - m_SleepThread.Abort(); + //if(!m_SleepThread.Join(250)) + // m_SleepThread.Abort(); m_SleepThread = null; } @@ -862,6 +856,7 @@ private void HandleConsoleCmds(string module, string[] args) // Not required when not using IScriptInstance // + [MethodImpl(MethodImplOptions.AggressiveInlining)] public IScriptWorkItem QueueEventHandler(object parms) { return null; @@ -869,6 +864,7 @@ public IScriptWorkItem QueueEventHandler(object parms) public Scene World { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_Scene; @@ -877,6 +873,7 @@ public Scene World public IScriptModule ScriptModule { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return this; @@ -895,29 +892,27 @@ public void SaveAllState() // Events targeted at a specific script // ... like listen() for an llListen() call - // + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool PostScriptEvent(UUID itemID, EventParams parms) { - XMRInstance instance = GetInstance(itemID); - if (instance == null) - return false; - + if (TryGetInstance(itemID, out XMRInstance instance)) + { TraceCalls("[YEngine]: YEngine.PostScriptEvent({0},{1})", itemID.ToString(), parms.EventName); - - instance.PostEvent(parms); - return true; + return instance.PostEvent(parms); + } + return false; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void CancelScriptEvent(UUID itemID, string eventName) { - XMRInstance instance = GetInstance(itemID); - if (instance == null) - return; - + if (TryGetInstance(itemID, out XMRInstance instance)) + { TraceCalls("[YEngine]: YEngine.CancelScriptEvent({0},{1})", itemID.ToString(), eventName); - instance.CancelEvent(eventName); } + } // Events targeted at all scripts in the given prim. // localID = which prim @@ -952,21 +947,45 @@ public bool PostObjectEvent(uint localID, EventParams parms) return PostPrimEvent(part, parms); } - private bool PostPrimEvent(SceneObjectPart part, EventParams parms) + public bool PostObjectLinksetDataEvent(uint localID, int action, ReadOnlySpan name, ReadOnlySpan value) { - UUID partUUID = part.UUID; + if (m_Exiting) + return false; + + if (m_HeapSize < name.Length + value.Length) + return false; + SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); + if (part is null || part.ParentGroup is null) + return false; + + EventParams parms = new("linkset_data", new object[] { + new LSL_Integer(action), + new LSL_String(name.ToString()), + value.Length == 0 ? LSL_String.Empty : new LSL_String(value.ToString()) + }, + Array.Empty());; + + bool posted = false; + foreach (SceneObjectPart primpart in part.ParentGroup.Parts) + posted |= PostPrimEvent(primpart, parms); + + return posted; + } + + private bool PostPrimEvent(SceneObjectPart part, EventParams parms) + { // Get list of script instances running in the object. XMRInstance[] objInstArray; lock(m_InstancesDict) { - if(!m_ObjectInstArray.TryGetValue(partUUID, out objInstArray)) + if(!m_ObjectInstArray.TryGetValue(part.UUID, out objInstArray)) return false; if (objInstArray == null) { - objInstArray = RebuildObjectInstArray(partUUID); - m_ObjectInstArray[partUUID] = objInstArray; + objInstArray = RebuildObjectInstArray(part.UUID); + m_ObjectInstArray[part.UUID] = objInstArray; } } @@ -974,45 +993,47 @@ private bool PostPrimEvent(SceneObjectPart part, EventParams parms) if(objInstArray.Length <= 0) return false; + bool posted = false; foreach (XMRInstance inst in objInstArray) - inst.PostEvent(parms); + posted |= inst.PostEvent(parms); - return true; + return posted; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public DetectParams GetDetectParams(UUID itemID, int number) { - XMRInstance instance = GetInstance(itemID); - if(instance == null) - return null; + if (TryGetInstance(itemID, out XMRInstance instance)) return instance.GetDetectParams(number); + return null; } public void SetMinEventDelay(UUID itemID, double delay) { - XMRInstance instance = GetInstance(itemID); - if (instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) instance.MinEventDelay = delay; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetStartParameter(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if (instance == null) - return 0; + if (TryGetInstance(itemID, out XMRInstance instance)) return instance.StartParam; + return 0; } // This is the "set running" method - // + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetScriptState(UUID itemID, bool state, bool self) { SetScriptState(itemID, state); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetScriptState(UUID itemID, bool state) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { instance.Running = state; if(instance.m_Item != null) @@ -1021,34 +1042,34 @@ public void SetScriptState(UUID itemID, bool state) } // + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool GetScriptState(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance == null) - return false; + if (TryGetInstance(itemID, out XMRInstance instance)) return instance.Running; + return false; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetState(UUID itemID, string newState) { TraceCalls("[YEngine]: YEngine.SetState({0},{1})", itemID.ToString(), newState); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ApiResetScript(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) instance.ApiReset(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ResetScript(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { IUrlModule urlModule = m_Scene.RequestModuleInterface(); - if(urlModule != null) - urlModule.ScriptRemoved(itemID); + urlModule?.ScriptRemoved(itemID); instance.Reset(); } @@ -1056,6 +1077,7 @@ public void ResetScript(UUID itemID) public IConfig Config { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_Config; @@ -1064,6 +1086,7 @@ public IConfig Config public IConfigSource ConfigSource { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return m_ConfigSource; @@ -1072,21 +1095,22 @@ public IConfigSource ConfigSource public string ScriptEngineName { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return "YEngine"; } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public IScriptApi GetApi(UUID itemID, string name) { - FieldInfo fi; - if(!m_XMRInstanceApiCtxFieldInfos.TryGetValue(name, out fi)) - return null; - XMRInstance inst = GetInstance(itemID); - if(inst == null) + if(m_XMRInstanceApiCtxFieldInfos.TryGetValue(name, out FieldInfo fi)) + { + if (TryGetInstance(itemID, out XMRInstance instance)) + return (IScriptApi)fi.GetValue(instance); + } return null; - return (IScriptApi)fi.GetValue(inst); } /** @@ -1105,7 +1129,7 @@ public string GetXMLState(UUID itemID) if(!instance.m_HasRun) return String.Empty; - XmlDocument doc = new XmlDocument(); + XmlDocument doc = new(); /* * Set up tag. @@ -1140,7 +1164,7 @@ public string GetXMLState(UUID itemID) // the script is instantiated. public bool SetXMLState(UUID itemID, string xml) { - XmlDocument doc = new XmlDocument(); + XmlDocument doc = new(); try { @@ -1189,13 +1213,14 @@ public bool SetXMLState(UUID itemID, string xml) string statePath = XMRInstance.GetStateFileName(m_ScriptBasePath, itemID); using (FileStream ss = File.Create(statePath)) { - using (StreamWriter sw = new StreamWriter(ss)) + using (StreamWriter sw = new(ss)) sw.Write(scriptStateN.OuterXml); } return true; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool PostScriptEvent(UUID itemID, string name, Object[] p) { if(!m_Enabled) @@ -1206,6 +1231,7 @@ public bool PostScriptEvent(UUID itemID, string name, Object[] p) return PostScriptEvent(itemID, new EventParams(name, p, zeroDetectParams)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool PostObjectEvent(UUID itemID, string name, Object[] p) { if(!m_Enabled) @@ -1213,18 +1239,16 @@ public bool PostObjectEvent(UUID itemID, string name, Object[] p) TraceCalls("[YEngine]: YEngine.PostObjectEvent({0},{1})", itemID.ToString(), name); - SceneObjectPart part = m_Scene.GetSceneObjectPart(itemID); - if(part == null) - return false; - + if(m_Scene.TryGetSceneObjectPart(itemID, out SceneObjectPart part)) return PostObjectEvent(part.LocalId, new EventParams(name, p, zeroDetectParams)); + return false; } // about the 3523rd entrypoint for a script to put itself to sleep + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SleepScript(UUID itemID, int delay) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) instance.Sleep(delay); } @@ -1262,17 +1286,17 @@ public void OnRezScript(uint localID, UUID itemID, string script, int lineEnd = script.IndexOf('\n'); if(lineEnd > 5) { - string firstline = script.Substring(2, lineEnd - 2).Trim(); + string firstline = script[2..lineEnd].Trim(); int colon = firstline.IndexOf(':'); if(colon >= 3) { - engineName = firstline.Substring(0, colon).TrimEnd(); + engineName = firstline[..colon].TrimEnd(); if(string.IsNullOrEmpty(engineName)) engineName = defEngine; } if (colon > 0 && colon < firstline.Length - 2) { - langsrt = firstline.Substring(colon + 1).Trim(); + langsrt = firstline[(colon + 1)..].Trim(); langsrt = langsrt.ToLower(); } } @@ -1335,8 +1359,8 @@ public void OnRezScript(uint localID, UUID itemID, string script, // Insert on internal list of all scripts being handled by this engine instance // that are part of the object. - List itemIDList; - if(!m_ObjectItemList.TryGetValue(instance.m_PartUUID, out itemIDList)) + + if(!m_ObjectItemList.TryGetValue(instance.m_PartUUID, out List itemIDList)) { itemIDList = new List(); m_ObjectItemList[instance.m_PartUUID] = itemIDList; @@ -1363,7 +1387,7 @@ public void OnRezScript(uint localID, UUID itemID, string script, private void LoadThreadWork(XMRInstance instance) { // Compile and load the script in memory. - ArrayList errors = new ArrayList(); + ArrayList errors = new(); Exception initerr = null; try { @@ -1373,7 +1397,7 @@ private void LoadThreadWork(XMRInstance instance) { initerr = e1; } - if(initerr != null && !instance.m_ForceRecomp && initerr is CVVMismatchException) + if(initerr is not null && !instance.m_ForceRecomp && initerr is CVVMismatchException) { UUID itemID = instance.m_ItemID; Verbose("[YEngine]: {0}/{2} first load failed ({1}), retrying after recompile", @@ -1391,7 +1415,7 @@ private void LoadThreadWork(XMRInstance instance) initerr = e2; } } - if(initerr != null) + if(initerr is not null) { UUID itemID = instance.m_ItemID; Verbose("[YEngine]: Error starting script {0}/{2}: {1}", @@ -1484,8 +1508,7 @@ public void OnRemoveScript(uint localID, UUID itemID) // mostly so no more events can queue to it. m_InstancesDict.Remove(itemID); - List itemIDList; - if(m_ObjectItemList.TryGetValue(instance.m_PartUUID, out itemIDList)) + if(m_ObjectItemList.TryGetValue(instance.m_PartUUID, out List itemIDList)) { itemIDList.Remove(itemID); if(itemIDList.Count == 0) @@ -1512,16 +1535,17 @@ public void OnRemoveScript(uint localID, UUID itemID) instance.Dispose(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void OnScriptReset(uint localID, UUID itemID) { TraceCalls("[YEngine]: YEngine.OnScriptReset({0},{1})", localID.ToString(), itemID.ToString()); ResetScript(itemID); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void OnStartScript(uint localID, UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { instance.Running = true; if (instance.m_Item != null) @@ -1529,10 +1553,10 @@ public void OnStartScript(uint localID, UUID itemID) } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void OnStopScript(uint localID, UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { instance.Running = false; if (instance.m_Item != null) @@ -1540,44 +1564,38 @@ public void OnStopScript(uint localID, UUID itemID) } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { TraceCalls("[YEngine]: YEngine.OnGetScriptRunning({0},{1})", objectID.ToString(), itemID.ToString()); bool curRunnning = instance.Running; instance.m_Item.ScriptRunning = curRunnning; - IEventQueue eq = World.RequestModuleInterface(); - if(eq == null) - { controllingClient.SendScriptRunningReply(objectID, itemID, curRunnning); } - else - { - eq.ScriptRunningEvent(objectID, itemID, curRunnning, controllingClient.AgentId); - } - } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool HasScript(UUID itemID, out bool running) { - XMRInstance instance = GetInstance(itemID); - if(instance == null) + if (TryGetInstance(itemID, out XMRInstance instance)) { running = true; return false; } - running = instance.Running; - return true; + running = true; + return false; } /** * @brief Called once per frame update to see if scripts have * any such work to do. */ + + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void OnFrame() { if(m_FrameUpdateList != null) @@ -1606,6 +1624,8 @@ public void AddOnFrameUpdate(ThreadStart thunk) * @brief Gets called early as part of shutdown, * right after "Persisting changed objects" message. */ + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void OnShutdown() { TraceCalls("[YEngine]: YEngine.OnShutdown()"); @@ -1620,6 +1640,8 @@ public void OnShutdown() * we don't get two threads trying to queue the same * instance to the m_StartQueue at the same time. */ + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void QueueToStart(XMRInstance inst) { if (inst.m_IState != XMRInstState.ONSTARTQ) @@ -1631,6 +1653,7 @@ public void QueueToStart(XMRInstance inst) WakeUpOne(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void QueueToYield(XMRInstance inst) { if (inst.m_IState != XMRInstState.ONYIELDQ) @@ -1642,6 +1665,7 @@ public void QueueToYield(XMRInstance inst) WakeUpOne(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RemoveFromSleep(XMRInstance inst) { lock (m_SleepQueue) @@ -1826,17 +1850,16 @@ private void RunSleepThread() } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Suspend(UUID itemID, int ms) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) instance.Sleep(ms); } public void Die(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { TraceCalls("[YEngine]: YEngine.Die({0})", itemID.ToString()); instance.Die(); @@ -1851,6 +1874,8 @@ public void Die(UUID itemID) * @returns null: not one of our scripts (maybe XEngine etc) * else: points to the script instance */ + + [MethodImpl(MethodImplOptions.AggressiveInlining)] public XMRInstance GetInstance(UUID itemID) { XMRInstance instance; @@ -1862,6 +1887,20 @@ public XMRInstance GetInstance(UUID itemID) return instance; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool TryGetInstance(UUID itemID, out XMRInstance instance) + { + lock (m_InstancesDict) + return m_InstancesDict.TryGetValue(itemID, out instance); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool ConstainsInstance(UUID itemID) + { + lock (m_InstancesDict) + return m_InstancesDict.ContainsKey(itemID); + } + // Called occasionally to write script state to .state file so the // script will restart from its last known state if the region crashes // and gets restarted. @@ -1907,17 +1946,17 @@ public ArrayList GetScriptErrors(UUID itemID) */ public Dictionary GetObjectScriptsExecutionTimes() { - Dictionary topScripts = new Dictionary(); + Dictionary topScripts = new(); lock(m_InstancesDict) { foreach(XMRInstance instance in m_InstancesDict.Values) { uint rootLocalID = instance.m_Part.ParentGroup.LocalId; - float oldTotal; - if(!topScripts.TryGetValue(rootLocalID, out oldTotal)) - oldTotal = 0; - + if(topScripts.TryGetValue(rootLocalID, out float oldTotal)) topScripts[rootLocalID] = (float)instance.m_CPUTime + oldTotal; + else + topScripts[rootLocalID] = (float)instance.m_CPUTime; + } } return topScripts; @@ -1929,7 +1968,7 @@ public Dictionary GetObjectScriptsExecutionTimes() public ICollection GetTopObjectStats(float mintime, int minmemory, out float totaltime, out float totalmemory) { - Dictionary topScripts = new Dictionary(); + Dictionary topScripts = new(); totalmemory = 0; totaltime = 0; lock (m_InstancesDict) @@ -1943,19 +1982,19 @@ public ICollection GetTopObjectStats(float mintime, int minm totalmemory += mem; if (time > mintime || mem > minmemory) { - ScriptTopStatsData sd; - if (topScripts.TryGetValue(rootLocalID, out sd)) + if (topScripts.TryGetValue(rootLocalID, out ScriptTopStatsData sd)) { sd.time += time; sd.memory += mem; } else { - sd = new ScriptTopStatsData(); - sd.localID = rootLocalID; - sd.time = time; - sd.memory = mem; - topScripts[rootLocalID] = sd; + topScripts[rootLocalID] = new ScriptTopStatsData + { + localID = rootLocalID, + time = time, + memory = mem + }; } } } @@ -1977,8 +2016,7 @@ public float GetScriptExecutionTime(List itemIDs) float time = 0; foreach(UUID itemID in itemIDs) { - XMRInstance instance = GetInstance(itemID); - if((instance != null) && instance.Running) + if (TryGetInstance(itemID, out XMRInstance instance) && instance.Running) time += (float)instance.m_CPUTime; } return time; @@ -1992,8 +2030,7 @@ public int GetScriptsMemory(List itemIDs) int memory = 0; foreach (UUID itemID in itemIDs) { - XMRInstance instance = GetInstance(itemID); - if ((instance != null) && instance.Running) + if (TryGetInstance(itemID, out XMRInstance instance) && instance.Running) memory += instance.xmrHeapUsed(); } return memory; @@ -2004,8 +2041,7 @@ public int GetScriptsMemory(List itemIDs) */ public bool SuspendScript(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { TraceCalls("[YEngine]: YEngine.SuspendScript({0})", itemID.ToString()); instance.SuspendIt(); @@ -2019,8 +2055,7 @@ public bool SuspendScript(UUID itemID) */ public bool ResumeScript(UUID itemID) { - XMRInstance instance = GetInstance(itemID); - if(instance != null) + if (TryGetInstance(itemID, out XMRInstance instance)) { TraceCalls("[YEngine]: YEngine.ResumeScript({0})", itemID.ToString()); instance.ResumeIt(); diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs index bbcdb379207..6490d53344c 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREvents.cs @@ -26,16 +26,11 @@ */ using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.ScriptEngine.Shared; -using OpenSim.Region.ScriptEngine.Interfaces; -using log4net; +//using log4net; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs index 549f6da86c2..5f6795040d2 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRHeapTracker.cs @@ -105,7 +105,7 @@ public static Type GenPush(Token errorAt, ScriptMyILGen ilGen) public void Save(LSL_List lis) { - usage = (lis == null) ? instance.UpdateLocalsHeapUse(usage, 0) : instance.UpdateLocalsHeapUse(usage, lis.Size); + usage = (lis is null) ? instance.UpdateLocalsHeapUse(usage, 0) : instance.UpdateLocalsHeapUse(usage, lis.Size); value = lis; } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs index 754c950edef..edc853fbe24 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs @@ -31,7 +31,6 @@ using System.Globalization; using System.IO; using System.Reflection.Emit; -using System.Runtime.Serialization; using System.Text; using System.Threading; @@ -89,24 +88,24 @@ public XMRInstArrays(XMRInstAbstract inst) public void Clear() { int newheapUse = 0; - if(iarArrays != null) + if(iarArrays is not null) { foreach(XMR_Array xa in iarArrays) xa.__pub_clear(); } - if(iarChars != null) + if(iarChars is not null) iarChars = new char[iarChars.Length]; - if (iarLists != null) + if (iarLists is not null) iarLists = new LSL_List[iarLists.Length]; - if (iarObjects != null) + if (iarObjects is not null) iarObjects = new object[iarObjects.Length]; - if(iarStrings != null) + if(iarStrings is not null) iarStrings = new string[iarStrings.Length]; - if (iarFloats != null) + if (iarFloats is not null) newheapUse += iarFloats.Length * HeapTrackerObject.HT_DOUB; - if (iarIntegers != null) + if (iarIntegers is not null) newheapUse += iarIntegers.Length * HeapTrackerObject.HT_INT; - if (iarRotations != null) + if (iarRotations is not null) newheapUse += iarRotations.Length * HeapTrackerObject.HT_ROT; if (iarVectors != null) newheapUse += iarVectors.Length * HeapTrackerObject.HT_VEC; @@ -201,13 +200,13 @@ public void RecvArrays(Recver recver) ClearOldArrays(); iarArrays = (XMR_Array[])recver(); - if(iarArrays == null) + if(iarArrays is null) iarArrays = noArrays; int newheapuse = arraysHeapUse; char[] chrs = (char[])recver(); - if (chrs != null) + if (chrs is not null) { newheapuse += chrs.Length * HeapTrackerObject.HT_CHAR; iarChars = chrs; @@ -216,7 +215,7 @@ public void RecvArrays(Recver recver) iarChars = noChars; double[] flts = (double[])recver(); - if (flts != null) + if (flts is not null) { newheapuse += flts.Length * HeapTrackerObject.HT_DOUB; iarFloats = flts; @@ -225,7 +224,7 @@ public void RecvArrays(Recver recver) iarFloats = noFloats; int[] ints = (int[])recver(); - if (ints != null) + if (ints is not null) { newheapuse += ints.Length * HeapTrackerObject.HT_INT; iarIntegers = ints; @@ -234,7 +233,7 @@ public void RecvArrays(Recver recver) iarIntegers = noIntegers; LSL_List[] liss = (LSL_List[])recver(); - if (liss != null) + if (liss is not null) { foreach (LSL_List lis in liss) { @@ -247,7 +246,7 @@ public void RecvArrays(Recver recver) iarLists = noLists; object[] objs = (object[])recver(); - if (objs != null) + if (objs is not null) { foreach (object obj in objs) newheapuse += HeapTrackerObject.Size(obj); @@ -257,7 +256,7 @@ public void RecvArrays(Recver recver) iarObjects = noObjects; LSL_Rotation[] rots = (LSL_Rotation[])recver(); - if (rots != null) + if (rots is not null) { newheapuse += rots.Length * HeapTrackerObject.HT_ROT; iarRotations = rots; @@ -266,7 +265,7 @@ public void RecvArrays(Recver recver) iarRotations = noRotations; string[] strs = (string[])recver(); - if (strs != null) + if (strs is not null) { foreach (string str in strs) newheapuse += HeapTrackerString.Size(str); @@ -285,11 +284,11 @@ public void RecvArrays(Recver recver) iarVectors = noVectors; iarSDTClObjs = (XMRSDTypeClObj[])recver(); - if(iarSDTClObjs == null) + if(iarSDTClObjs is null) iarSDTClObjs = noSDTClObjs; Delegate[][] dels = (Delegate[][])recver(); - if(dels != null) + if(dels is not null) { newheapuse += dels.Length * HeapTrackerObject.HT_DELE; iarSDTIntfObjs = dels; @@ -307,54 +306,54 @@ private void ClearOldArrays() int newheapuse = arraysHeapUse; iarArrays = null; - if(iarChars != null) + if(iarChars is not null) { newheapuse -= iarChars.Length * HeapTrackerObject.HT_CHAR; iarChars = null; } - if(iarFloats != null) + if(iarFloats is not null) { newheapuse -= iarFloats.Length * HeapTrackerObject.HT_DOUB; iarFloats = null; } - if(iarIntegers != null) + if(iarIntegers is not null) { newheapuse -= iarIntegers.Length * HeapTrackerObject.HT_INT; iarIntegers = null; } - if(iarLists != null) + if(iarLists is not null) { foreach(LSL_List lis in iarLists) { - if (!(lis is null)) + if ((lis is not null)) newheapuse += lis.Size; } iarLists = null; } - if(iarObjects != null) + if(iarObjects is not null) { foreach(object obj in iarObjects) newheapuse -= HeapTrackerObject.Size(obj); iarObjects = null; } - if(iarRotations != null) + if(iarRotations is not null) { newheapuse -= iarRotations.Length * HeapTrackerObject.HT_ROT; iarRotations = null; } - if(iarStrings != null) + if(iarStrings is not null) { foreach(string str in iarStrings) newheapuse -= HeapTrackerString.Size(str); iarStrings = null; } - if(iarVectors != null) + if(iarVectors is not null) { newheapuse -= iarVectors.Length * HeapTrackerObject.HT_VEC; iarVectors = null; } iarSDTClObjs = null; - if(iarSDTIntfObjs != null) + if(iarSDTIntfObjs is not null) { newheapuse -= iarSDTIntfObjs.Length * HeapTrackerObject.HT_DELE; iarSDTIntfObjs = null; @@ -557,18 +556,18 @@ public void CallSEH() // CallMode_NORMAL: run event handler from the beginning normally // CallMode_RESTORE: restore event handler stack from stackFrames - callMode = (stackFrames == null) ? XMRInstAbstract.CallMode_NORMAL : + callMode = (stackFrames is null) ? XMRInstAbstract.CallMode_NORMAL : XMRInstAbstract.CallMode_RESTORE; while(true) { - if(this.newStateCode < 0) + if(newStateCode < 0) { // Process event given by 'stateCode' and 'eventCode'. // The event handler should call CheckRun() as often as convenient. - int newState = this.stateCode; - seh = this.m_ObjCode.scriptEventHandlerTable[newState, (int)this.eventCode]; - if(seh != null) + int newState = stateCode; + seh = m_ObjCode.scriptEventHandlerTable[newState, (int)eventCode]; + if(seh is not null) { try { @@ -579,25 +578,25 @@ public void CallSEH() newState = scse.newState; } } - this.ehArgs = null; // we are done with them and no args for + ehArgs = null; // we are done with them and no args for // exit_state()/enter_state() anyway // The usual case is no state change. // Even a 'state ;' statement has no effect except to exit out. // It does not execute the state_exit() or state_entry() handlers. // See http://wiki.secondlife.com/wiki/State - if(newState == this.stateCode) + if(newState == stateCode) break; // Save new state in a more permanent location in case we // get serialized out while in the state_exit() handler. - this.newStateCode = newState; + newStateCode = newState; } // Call old state's state_exit() handler. - this.eventCode = ScriptEventCode.state_exit; - seh = this.m_ObjCode.scriptEventHandlerTable[this.stateCode, (int)ScriptEventCode.state_exit]; - if(seh != null) + eventCode = ScriptEventCode.state_exit; + seh = m_ObjCode.scriptEventHandlerTable[stateCode, (int)ScriptEventCode.state_exit]; + if(seh is not null) { try { @@ -605,24 +604,25 @@ public void CallSEH() } catch(ScriptChangeStateException scse) { - this.newStateCode = scse.newState; + newStateCode = scse.newState; } } // Switch over to the new state's state_entry() handler. - this.stateCode = this.newStateCode; - this.eventCode = ScriptEventCode.state_entry; - this.newStateCode = -1; + stateCode = newStateCode; + eventCode = ScriptEventCode.state_entry; + newStateCode = -1; // Now that the old state can't possibly start any more activity, // cancel any listening handlers, etc, of the old state. - this.StateChange(); + StateChange(); // Loop back to execute new state's state_entry() handler. } // Event no longer being processed. - this.eventCode = ScriptEventCode.None; + stackFrames = null; + eventCode = ScriptEventCode.None; } /** @@ -650,7 +650,7 @@ public void CheckRunStack() */ public void CheckRunQuick() { - // if (suspendOnCheckRunHold || suspendOnCheckRunTemp) + //if (suspendOnCheckRunHold || suspendOnCheckRunTemp) CheckRunWork(); } @@ -699,13 +699,12 @@ public object[] RestoreStackFrame(string funcName, out int callNo) public static LSL_List FixLLParcelMediaQuery(LSL_List oldlist) { object[] oldarray = oldlist.Data; - int len = oldarray.Length; - object[] newarray = new object[len]; - for(int i = 0; i < len; i++) + object[] newarray = new object[oldarray.Length]; + for(int i = 0; i < oldarray.Length; i++) { object obj = oldarray[i]; - if(obj is LSL_Integer) - obj = (int)(LSL_Integer)obj; + if(obj is LSL_Integer io) + obj = io.value; newarray[i] = obj; } return new LSL_List(newarray); @@ -718,19 +717,18 @@ public static LSL_List FixLLParcelMediaQuery(LSL_List oldlist) public static LSL_List FixLLParcelMediaCommandList(LSL_List oldlist) { object[] oldarray = oldlist.Data; - int len = oldarray.Length; - object[] newarray = new object[len]; + object[] newarray = new object[oldarray.Length]; int verbatim = 0; - for(int i = 0; i < len; i++) + for(int i = 0; i < oldarray.Length; i++) { object obj = oldarray[i]; if(--verbatim < 0) { - if(obj is LSL_Integer) - obj = (int)(LSL_Integer)obj; - if(obj is int) + if(obj is LSL_Integer lio) + obj = lio.value; + if(obj is int io) { - switch((int)obj) + switch(io) { case ScriptBaseClass.PARCEL_MEDIA_COMMAND_AUTO_ALIGN: // leave next integer as LSL_Integer @@ -808,20 +806,19 @@ public string xmrTypeName(object o) // If that is the case, convert it to the object of the script-defined // class that is implementing the interface. This should let the next // step get the script-defined type name of the object. - if(o is Delegate[]) - o = ((Delegate[])o)[0].Target; + if(o is Delegate[] dao) + o = dao[0].Target; // If script-defined class instance, get the script-defined // type name. - if(o is XMRSDTypeClObj) - return ((XMRSDTypeClObj)o).sdtcClass.longName.val; + if(o is XMRSDTypeClObj XMRSDTypeClObjo) + return XMRSDTypeClObjo.sdtcClass.longName.val; // If it's a delegate, maybe we can look up its script-defined type name. Type ot = o.GetType(); if(o is Delegate) { - String os; - if(m_ObjCode.sdDelTypes.TryGetValue(ot, out os)) + if(m_ObjCode.sdDelTypes.TryGetValue(ot, out string os)) return os; } @@ -839,9 +836,9 @@ public string xmrTypeName(object o) public void xmrEventCallHandler(LSL_List ev) { object[] data = ev.Data; - int evc = (int)(ev.GetLSLIntegerItem(0).value & 0xFFFFFFFF); + int evc = ev.GetIntegerItem(0); ScriptEventHandler seh = m_ObjCode.scriptEventHandlerTable[stateCode, evc]; - if(seh != null) + if(seh is not null) { int nargs = data.Length - 1; object[] args = new object[nargs]; @@ -850,13 +847,13 @@ public void xmrEventCallHandler(LSL_List ev) object[] saveEHArgs = this.ehArgs; ScriptEventCode saveEventCode = this.eventCode; - this.ehArgs = args; - this.eventCode = (ScriptEventCode)evc; + ehArgs = args; + eventCode = (ScriptEventCode)evc; seh(this); - this.ehArgs = saveEHArgs; - this.eventCode = saveEventCode; + ehArgs = saveEHArgs; + eventCode = saveEventCode; } } @@ -968,9 +965,9 @@ public static object XMRSDTypeCatchTryCastToSDType(object thrown, XMRInstAbstrac TokenDeclSDType sdType = inst.m_ObjCode.sdObjTypesIndx[sdtypeindex]; // If it is a script-defined interface object, convert to the original XMRSDTypeClObj. - if(thrown is Delegate[]) + if(thrown is Delegate[] dt) { - thrown = ((Delegate[])thrown)[0].Target; + thrown = dt[0].Target; } // If it is a script-defined delegate object, make sure it is an instance of the expected type. @@ -982,12 +979,12 @@ public static object XMRSDTypeCatchTryCastToSDType(object thrown, XMRInstAbstrac } // If it is a script-defined class object, make sure it is an instance of the expected class. - if(thrown is XMRSDTypeClObj) + if(thrown is XMRSDTypeClObj XMRSDTypeClObjthrown) { // Step from the object's actual class rootward. // If we find the requested class along the way, the cast is valid. // If we run off the end of the root, the cast is not valid. - for(TokenDeclSDTypeClass ac = ((XMRSDTypeClObj)thrown).sdtcClass; ac != null; ac = ac.extends) + for(TokenDeclSDTypeClass ac = XMRSDTypeClObjthrown.sdtcClass; ac is not null; ac = ac.extends) { if(ac == sdType) return thrown; @@ -1129,14 +1126,14 @@ public static LSL_List xmrArray2List(object srcar, int start, int count) object src = srcarray.GetValue(i + start); if(src == null) throw new NullReferenceException("null element " + i); - if(src is double) + if(src is double dsrc) { - output[i] = new LSL_Float((double)src); + output[i] = new LSL_Float(dsrc); continue; } - if(src is int) + if(src is int isrc) { - output[i] = new LSL_Integer((int)src); + output[i] = new LSL_Integer(isrc); continue; } if(src is LSL_Rotation) @@ -1149,9 +1146,9 @@ public static LSL_List xmrArray2List(object srcar, int start, int count) output[i] = src; continue; } - if(src is string) + if(src is string ssrc) { - output[i] = new LSL_String((string)src); + output[i] = new LSL_String(ssrc); continue; } throw new InvalidCastException("invalid element " + i + " type " + src.GetType().Name); @@ -1186,12 +1183,12 @@ public static void xmrList2Array(LSL_List srclist, int srcstart, object dstobj, for(int i = 0; i < count; i++) { object obj = srcarr[i + srcstart]; - if(obj is LSL_Float) - obj = ((LSL_Float)obj).value; - else if(obj is LSL_Integer) - obj = ((LSL_Integer)obj).value; - else if(obj is LSL_String) - obj = ((LSL_String)obj).m_string; + if(obj is LSL_Float lfo) + obj = lfo.value; + else if(obj is LSL_Integer lio) + obj = lio.value; + else if(obj is LSL_String lso) + obj = lso.m_string; dstarr.SetValue(obj, i + dststart); } } @@ -1490,32 +1487,32 @@ public void MigrateOut(BinaryWriter mow) { try { - this.migrateOutWriter = mow; - this.migrateOutObjects = new Dictionary(); - this.migrateOutLists = new Dictionary(); - this.SendObjValue(this.ehArgs); - mow.Write(this.doGblInit); - mow.Write(this.stateCode); - mow.Write((int)this.eventCode); - this.glblVars.SendArrays(this.SendObjValue); - if(this.newStateCode >= 0) + migrateOutWriter = mow; + migrateOutObjects = new Dictionary(); + migrateOutLists = new Dictionary(); + SendObjValue(ehArgs); + mow.Write(doGblInit); + mow.Write(stateCode); + mow.Write((int)eventCode); + glblVars.SendArrays(SendObjValue); + if(newStateCode >= 0) { mow.Write("**newStateCode**"); - mow.Write(this.newStateCode); + mow.Write(newStateCode); } - for(XMRStackFrame thisSF = this.stackFrames; thisSF != null; thisSF = thisSF.nextSF) + for(XMRStackFrame thisSF = stackFrames; thisSF is not null; thisSF = thisSF.nextSF) { mow.Write(thisSF.funcName); mow.Write(thisSF.callNo); - this.SendObjValue(thisSF.objArray); + SendObjValue(thisSF.objArray); } mow.Write(""); } finally { - this.migrateOutWriter = null; - this.migrateOutObjects = null; - this.migrateOutLists = null; + migrateOutWriter = null; + migrateOutObjects = null; + migrateOutLists = null; } } @@ -1528,10 +1525,10 @@ public void MigrateOut(BinaryWriter mow) private Dictionary migrateOutLists; public void SendObjValue(object graph) { - BinaryWriter mow = this.migrateOutWriter; + BinaryWriter mow = migrateOutWriter; // Value types (including nulls) are always output directly. - if(graph == null) + if(graph is null) { mow.Write((byte)Ser.NULL); return; @@ -1542,47 +1539,45 @@ public void SendObjValue(object graph) mow.Write((int)graph); return; } - if(graph is LSL_Float) + if(graph is LSL_Float lfg) { mow.Write((byte)Ser.LSLFLOAT); - mow.Write((double)((LSL_Float)graph).value); + mow.Write(lfg.value); return; } - if(graph is LSL_Integer) + if(graph is LSL_Integer lig) { mow.Write((byte)Ser.LSLINT); - mow.Write((int)((LSL_Integer)graph).value); + mow.Write(lig.value); return; } - if(graph is LSL_Key) + if(graph is LSL_Key lkg) { mow.Write((byte)Ser.LSLKEY); - LSL_Key key = (LSL_Key)graph; - SendObjValue(key.m_string); // m_string can be null + SendObjValue(lkg.m_string); // m_string can be null return; } - if(graph is LSL_Rotation) + if(graph is LSL_Rotation lrg) { mow.Write((byte)Ser.LSLROT); - mow.Write((double)((LSL_Rotation)graph).x); - mow.Write((double)((LSL_Rotation)graph).y); - mow.Write((double)((LSL_Rotation)graph).z); - mow.Write((double)((LSL_Rotation)graph).s); + mow.Write(lrg.x); + mow.Write(lrg.y); + mow.Write(lrg.z); + mow.Write(lrg.s); return; } - if(graph is LSL_String) + if(graph is LSL_String lsg) { mow.Write((byte)Ser.LSLSTR); - LSL_String str = (LSL_String)graph; - SendObjValue(str.m_string); // m_string can be null + SendObjValue(lsg.m_string); // m_string can be null return; } - if(graph is LSL_Vector) + if(graph is LSL_Vector lvg) { mow.Write((byte)Ser.LSLVEC); - mow.Write((double)((LSL_Vector)graph).x); - mow.Write((double)((LSL_Vector)graph).y); - mow.Write((double)((LSL_Vector)graph).z); + mow.Write(lvg.x); + mow.Write(lvg.y); + mow.Write(lvg.z); return; } if(graph is bool) @@ -1591,28 +1586,28 @@ public void SendObjValue(object graph) mow.Write((bool)graph); return; } - if(graph is double) + if(graph is double dg) { mow.Write((byte)Ser.SYSDOUB); mow.Write((double)graph); return; } - if(graph is float) + if(graph is float fg) { mow.Write((byte)Ser.SYSFLOAT); - mow.Write((float)graph); + mow.Write(fg); return; } - if(graph is int) + if(graph is int ig) { mow.Write((byte)Ser.SYSINT); mow.Write((int)graph); return; } - if(graph is char) + if(graph is char cg) { mow.Write((byte)Ser.SYSCHAR); - mow.Write((char)graph); + mow.Write(cg); return; } @@ -1626,17 +1621,16 @@ public void SendObjValue(object graph) // Convert lists to object type. // This is compatible with old migration data and also // two vars pointing to same list won't duplicate it. - if(graph is LSL_List) + if(graph is LSL_List llg) { - object[] data = ((LSL_List)graph).Data; - ObjLslList oll; - if(!this.migrateOutLists.TryGetValue(data, out oll)) + object[] data = llg.Data; + if(!migrateOutLists.TryGetValue(data, out ObjLslList ollg)) { - oll = new ObjLslList(); - oll.objarray = data; - this.migrateOutLists[data] = oll; + ollg = new ObjLslList(); + ollg.objarray = data; + migrateOutLists[data] = ollg; } - graph = oll; + graph = ollg; } // If this same exact object was already serialized, @@ -1645,8 +1639,7 @@ public void SendObjValue(object graph) // new object with the same values. Also this prevents // self-referencing objects (like arrays) from causing // an infinite loop. - int ident; - if(this.migrateOutObjects.TryGetValue(graph, out ident)) + if(migrateOutObjects.TryGetValue(graph, out int ident)) { mow.Write((byte)Ser.DUPREF); mow.Write(ident); @@ -1655,51 +1648,47 @@ public void SendObjValue(object graph) // Object not seen before, save its address with an unique // ident number that the receiver can easily regenerate. - ident = this.migrateOutObjects.Count; - this.migrateOutObjects.Add(graph, ident); + ident = migrateOutObjects.Count; + migrateOutObjects.Add(graph, ident); // Now output the object's value(s). // If the object self-references, the object is alreay entered // in the dictionary and so the self-reference will just emit // a DUPREF tag instead of trying to output the whole object // again. - if(graph is ObjLslList) + if(graph is ObjLslList oll) { mow.Write((byte)Ser.LSLLIST); - ObjLslList oll = (ObjLslList)graph; SendObjValue(oll.objarray); } - else if(graph is XMR_Array) + else if(graph is XMR_Array xg) { mow.Write((byte)Ser.XMRARRAY); - ((XMR_Array)graph).SendArrayObj(this.SendObjValue); + xg.SendArrayObj(SendObjValue); } - else if(graph is Array) + else if(graph is Array array) { - Array array = (Array)graph; mow.Write((byte)Ser.SYSARRAY); mow.Write(SysType2String(array.GetType().GetElementType())); - mow.Write((int)array.Length); + mow.Write(array.Length); for(int i = 0; i < array.Length; i++) - this.SendObjValue(array.GetValue(i)); + SendObjValue(array.GetValue(i)); } - else if(graph is string) + else if(graph is string sg) { mow.Write((byte)Ser.SYSSTR); - mow.Write((string)graph); + mow.Write(sg); } - else if(graph is Delegate) + else if(graph is Delegate del) { - Delegate del = (Delegate)graph; mow.Write((byte)Ser.DELEGATE); mow.Write(del.Method.Name); Type delType = del.GetType(); foreach(KeyValuePair kvp in m_ObjCode.sdObjTypesName) { TokenDeclSDType sdt = kvp.Value; - if(sdt is TokenDeclSDTypeDelegate) + if(sdt is TokenDeclSDTypeDelegate sdtd) { - TokenDeclSDTypeDelegate sdtd = (TokenDeclSDTypeDelegate)sdt; if(sdtd.GetSysType() == delType) { mow.Write(kvp.Key); @@ -1711,12 +1700,12 @@ public void SendObjValue(object graph) found: SendObjValue(del.Target); } - else if(graph is XMRSDTypeClObj) + else if(graph is XMRSDTypeClObj XMRSDTypeClObjgraph) { mow.Write((byte)Ser.SDTCLOBJ); - ((XMRSDTypeClObj)graph).Capture(this.SendObjValue); + XMRSDTypeClObjgraph.Capture(this.SendObjValue); } - else if(graph is ScriptThrownException) + else if(graph is ScriptThrownException ScriptThrownExceptiongraph) { MemoryStream memoryStream = new MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter = @@ -1726,7 +1715,7 @@ public void SendObjValue(object graph) mow.Write((byte)Ser.THROWNEX); mow.Write((int)rawBytes.Length); mow.Write(rawBytes); - SendObjValue(((ScriptThrownException)graph).thrown); + SendObjValue(ScriptThrownExceptiongraph.thrown); } else { @@ -1736,7 +1725,7 @@ public void SendObjValue(object graph) bformatter.Serialize(memoryStream, graph); byte[] rawBytes = memoryStream.ToArray(); mow.Write((byte)Ser.SYSERIAL); - mow.Write((int)rawBytes.Length); + mow.Write(rawBytes.Length); mow.Write(rawBytes); } } @@ -1749,13 +1738,13 @@ private static string SysType2String(Type type) if(type.IsArray && (type.GetArrayRank() == 1)) { string str = KnownSysType2String(type.GetElementType()); - if(str != null) + if(str is not null) return str + "[]"; } else { string str = KnownSysType2String(type); - if(str != null) + if(str is not null) return str; } return type.ToString(); @@ -1831,29 +1820,29 @@ public void MigrateIn(BinaryReader mir) { try { - this.migrateInReader = mir; - this.migrateInObjects = new Dictionary(); - this.ehArgs = (object[])this.RecvObjValue(); - this.doGblInit = mir.ReadBoolean(); - this.stateCode = mir.ReadInt32(); - this.eventCode = (ScriptEventCode)mir.ReadInt32(); - this.newStateCode = -1; - this.glblVars.RecvArrays(this.RecvObjValue); + migrateInReader = mir; + migrateInObjects = new Dictionary(); + ehArgs = (object[])RecvObjValue(); + doGblInit = mir.ReadBoolean(); + stateCode = mir.ReadInt32(); + eventCode = (ScriptEventCode)mir.ReadInt32(); + newStateCode = -1; + glblVars.RecvArrays(RecvObjValue); XMRStackFrame lastSF = null; string funcName; while((funcName = mir.ReadString()) != "") { if(funcName == "**newStateCode**") { - this.newStateCode = mir.ReadInt32(); + newStateCode = mir.ReadInt32(); continue; } XMRStackFrame thisSF = new XMRStackFrame(); thisSF.funcName = funcName; thisSF.callNo = mir.ReadInt32(); - thisSF.objArray = (object[])this.RecvObjValue(); + thisSF.objArray = (object[])RecvObjValue(); if(lastSF == null) - this.stackFrames = thisSF; + stackFrames = thisSF; else lastSF.nextSF = thisSF; lastSF = thisSF; @@ -1861,8 +1850,8 @@ public void MigrateIn(BinaryReader mir) } finally { - this.migrateInReader = null; - this.migrateInObjects = null; + migrateInReader = null; + migrateInObjects = null; } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs index bdb9f32b5d0..992783f2fde 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs @@ -413,12 +413,12 @@ public override LSL_List xmrEventDequeue(double timeout, int returnMask1, int re for(int i = 0; i < plen;) { object ob = evt.Params[i]; - if(ob is int) - ob = (LSL_Integer)(int)ob; - else if(ob is double) - ob = (LSL_Float)(double)ob; - else if(ob is string) - ob = (LSL_String)(string)ob; + if(ob is int iob) + ob = (LSL_Integer)iob; + else if(ob is double dob) + ob = (LSL_Float)dob; + else if(ob is string sob) + ob = (LSL_String)sob; plist[++i] = ob; } m_DetectParams = evt.DetectParams; diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCapture.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCapture.cs index 1abaca4a3d3..d2c86ecac33 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCapture.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCapture.cs @@ -85,7 +85,7 @@ public XmlElement GetExecutionState(XmlDocument doc) lock(m_RunLock) { //m_RunOnePhase = "GetExecutionState enter"; - CheckRunLockInvariants(true); + //CheckRunLockInvariants(true); // Get copy of script globals and stack in relocateable form. Byte[] snapshotBytes; @@ -100,23 +100,20 @@ public XmlElement GetExecutionState(XmlDocument doc) snapshotN.AppendChild(doc.CreateTextNode(snapshotString)); scriptStateN.AppendChild(snapshotN); //m_RunOnePhase = "GetExecutionState B"; - CheckRunLockInvariants(true); // "Running" says whether or not we are accepting new events. XmlElement runningN = doc.CreateElement("", "Running", ""); runningN.AppendChild(doc.CreateTextNode(m_Running.ToString())); scriptStateN.AppendChild(runningN); //m_RunOnePhase = "GetExecutionState C"; - CheckRunLockInvariants(true); // "DoGblInit" says whether or not default:state_entry() will init global vars. XmlElement doGblInitN = doc.CreateElement("", "DoGblInit", ""); doGblInitN.AppendChild(doc.CreateTextNode(doGblInit.ToString())); scriptStateN.AppendChild(doGblInitN); //m_RunOnePhase = "GetExecutionState D"; - CheckRunLockInvariants(true); - if(m_XMRLSLApi != null) + if(m_XMRLSLApi is not null) { double scriptTime = Util.GetTimeStampMS() - m_XMRLSLApi.getLSLTimer(); XmlElement scriptTimeN = doc.CreateElement("", "scrpTime", ""); @@ -130,7 +127,6 @@ public XmlElement GetExecutionState(XmlDocument doc) minEventDelayN.AppendChild(doc.CreateTextNode(m_minEventDelay.ToString())); scriptStateN.AppendChild(minEventDelayN); //m_RunOnePhase = "GetExecutionState D"; - CheckRunLockInvariants(true); } // More misc data. @@ -145,19 +141,17 @@ public XmlElement GetExecutionState(XmlDocument doc) maskA.Value = m_Item.PermsMask.ToString(); permissionsN.Attributes.Append(maskA); //m_RunOnePhase = "GetExecutionState E"; - CheckRunLockInvariants(true); // "DetectParams" are returned by llDetected...() script functions // for the currently active event, if any. var detectParams = m_DetectParams; - if (detectParams != null) + if (detectParams is not null) { XmlElement detParArrayN = doc.CreateElement("", "DetectArray", ""); AppendXMLDetectArray(doc, detParArrayN, detectParams); scriptStateN.AppendChild(detParArrayN); } //m_RunOnePhase = "GetExecutionState F"; - CheckRunLockInvariants(true); // Save any events we have in the queue. // @@ -181,23 +175,19 @@ public XmlElement GetExecutionState(XmlDocument doc) } scriptStateN.AppendChild(queuedEventsN); //m_RunOnePhase = "GetExecutionState G"; - CheckRunLockInvariants(true); // "Plugins" indicate enabled timers and listens, etc. - Object[] pluginData = - AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); + Object[] pluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); XmlNode plugins = doc.CreateElement("", "Plugins", ""); AppendXMLObjectArray(doc, plugins, pluginData, "plugin"); scriptStateN.AppendChild(plugins); //m_RunOnePhase = "GetExecutionState H"; - CheckRunLockInvariants(true); // Let script run again. suspendOnCheckRunHold = false; //m_RunOnePhase = "GetExecutionState leave"; - CheckRunLockInvariants(true); } // scriptStateN represents the contents of the .state file so @@ -222,7 +212,7 @@ private void MigrateOutEventHandler(Stream stream) // Does not change script state. stream.WriteByte(migrationVersion); stream.WriteByte((byte)16); - this.MigrateOut(new BinaryWriter(stream)); + MigrateOut(new BinaryWriter(stream)); } /** diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs index d88ef02a40c..0b749a36ee1 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs @@ -30,7 +30,6 @@ using System.Reflection; using System.Collections; using System.Collections.Generic; -using System.Runtime.Remoting.Lifetime; using System.Security.Policy; using System.IO; using System.Xml; @@ -667,68 +666,65 @@ private void processXstate(XmlDocument doc) XmlNodeList varL = part.ChildNodes; foreach (XmlNode var in varL) { - string varName; - object o = ReadXTypedValue(var, out varName); - Type otype = o.GetType(); - if (otype == typeof(LSL_Integer)) + object o = ReadXTypedValue(var, out string varName); + if (o is LSL_Integer lio) { if (intNames.TryGetValue(varName, out indx)) - ints[indx] = ((LSL_Integer)o); + ints[indx] = lio; continue; } - if (otype == typeof(LSL_Float)) + if (o is LSL_Float lfo) { if (doubleNames.TryGetValue(varName, out indx)) - doubles[indx] = ((LSL_Float)o); + doubles[indx] = lfo; continue; } - if (otype == typeof(LSL_String)) + if (o is LSL_String lso) { if (stringNames.TryGetValue(varName, out indx)) { - strings[indx] = ((LSL_String)o); - heapsz += ((LSL_String)o).Length; + strings[indx] = lso; + heapsz += lso.Length; } continue; } - if (otype == typeof(LSL_Rotation)) + if (o is LSL_Rotation lro) { if (rotationNames.TryGetValue(varName, out indx)) - rotations[indx] = ((LSL_Rotation)o); + rotations[indx] = lro; continue; } - if (otype == typeof(LSL_Vector)) + if (o is LSL_Vector lvo) { if (vectorNames.TryGetValue(varName, out indx)) - vectors[indx] = ((LSL_Vector)o); + vectors[indx] = lvo; continue; } - if (otype == typeof(LSL_Key)) + if (o is LSL_Key lko) { if (stringNames.TryGetValue(varName, out indx)) { - strings[indx] = ((LSL_Key)o); - heapsz += ((LSL_String)o).Length; + strings[indx] = lko; + heapsz += lko.Length; } continue; } - if (otype == typeof(UUID)) + if (o is UUID uo) { if (stringNames.TryGetValue(varName, out indx)) { - LSL_String id = ((UUID)o).ToString(); - strings[indx] = (id); + LSL_String id = uo.ToString(); + strings[indx] = id; heapsz += id.Length; } continue; } - if (otype == typeof(LSL_List)) + if (o is LSL_List llo) { if (listNames.TryGetValue(varName, out indx)) { - LSL_List lo = (LSL_List)o; - lists[indx] = (lo); - heapsz += lo.Size; + lists[indx] = (llo); + heapsz += llo.Size; } continue; } @@ -899,8 +895,6 @@ private void processXstate(XmlDocument doc) glblVars.iarObjects = XMRInstArrays.noObjects; glblVars.iarSDTClObjs = XMRInstArrays.noSDTClObjs; glblVars.iarSDTIntfObjs = XMRInstArrays.noSDTIntfObjs; - - CheckRunLockInvariants(true); } lock (m_QueueLock) @@ -961,9 +955,7 @@ private static object ReadXTypedValue(XmlNode tag) if (itemType == "OpenMetaverse.UUID") { - UUID val = new UUID(); - UUID.TryParse(tag.InnerText, out val); - + UUID.TryParse(tag.InnerText, out UUID val); return val; } @@ -1152,7 +1144,7 @@ private void MigrateInEventHandler(Stream stream) this.MigrateIn(br); //m_RunOnePhase = "MigrateInEventHandler finished"; - CheckRunLockInvariants(true); + //CheckRunLockInvariants(true); } } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs index 5588527cbee..d4f44e0952e 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs @@ -96,9 +96,7 @@ private void DecObjCodeRefCount() { lock(m_CompileLock) { - ScriptObjCode objCode; - - if(m_CompiledScriptObjCode.TryGetValue(m_ScriptObjCodeKey, out objCode) && + if(m_CompiledScriptObjCode.TryGetValue(m_ScriptObjCodeKey, out ScriptObjCode objCode) && (objCode == m_ObjCode) && (--objCode.refCount == 0)) { @@ -147,7 +145,7 @@ public string RunTestLs(bool flagFull) { if(flagFull) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.AppendLine(m_DescName); sb.AppendLine(" m_LocalID = " + m_LocalID); sb.AppendLine(" m_ItemID = " + m_ItemID + " (.state file)"); @@ -247,8 +245,8 @@ public static string GetScriptFileName(string scriptBasePath, string filename) // Get new path, ie, files split up based on first 2 chars of name. // string subdir = filename.Substring (0, 2); // filename = filename.Substring (2); - string subdir = filename.Substring(0, 1); - filename = filename.Substring(1); + string subdir = filename[..1]; + filename = filename[1..]; scriptBasePath = Path.Combine(scriptBasePath, subdir); Directory.CreateDirectory(scriptBasePath); string newPath = Path.Combine(scriptBasePath, filename); @@ -426,10 +424,8 @@ public static OpenMetaverse.Vector3 LSLVec2OMVec(LSL_Vector lslVec) */ public static int ListInt(object element) { - if(element is LSL_Integer) - { - return (int)(LSL_Integer)element; - } + if (element is LSL_Integer linteger) + return linteger.value; return (int)element; } @@ -438,10 +434,8 @@ public static int ListInt(object element) */ public static string ListStr(object element) { - if(element is LSL_String) - { - return (string)(LSL_String)element; - } + if(element is LSL_String ls) + return ls.m_string; return (string)element; } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs index 3dd75734818..88969e8fecc 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs @@ -52,13 +52,13 @@ public partial class XMRInstance * @brief This can be called in any thread (including the script thread itself) * to queue event to script for processing. */ - public void PostEvent(EventParams evt) + public bool PostEvent(EventParams evt) { if (!m_eventCodeMap.TryGetValue(evt.EventName, out ScriptEventCode evc)) - return; + return false; if (!m_HaveEventHandlers[(int)evc]) // don't bother if we don't have such a handler in any state - return; + return false; // Put event on end of event queue. bool startIt = false; @@ -76,11 +76,11 @@ public void PostEvent(EventParams evt) { if(evc == ScriptEventCode.state_entry && m_EventQueue.Count == 0) { - LinkedListNode llns = new LinkedListNode(evt); + LinkedListNode llns = new(evt); m_EventQueue.AddFirst(llns); } } - return; + return true; } } @@ -101,7 +101,7 @@ public void PostEvent(EventParams evt) { double now = Util.GetTimeStamp(); if (now < m_nextEventTime) - return; + return false; m_nextEventTime = now + m_minEventDelay; break; } @@ -110,12 +110,12 @@ public void PostEvent(EventParams evt) const int canignore = ~(CHANGED_SCALE | CHANGED_POSITION); int change = (int)evt.Params[0]; if(change == 0) // what? - return; + return false; if((change & canignore) == 0) { double now = Util.GetTimeStamp(); if (now < m_nextEventTime) - return; + return false; m_nextEventTime = now + m_minEventDelay; } break; @@ -128,18 +128,18 @@ public void PostEvent(EventParams evt) if(evc == ScriptEventCode.timer) { if (m_EventCounts[(int)evc] >= 1) - return; + return false; m_EventCounts[(int)evc]++; m_EventQueue.AddLast(new LinkedListNode(evt)); } else { if (m_EventCounts[(int)evc] >= MAXEVENTQUEUE) - return; + return false; m_EventCounts[(int)evc]++; - LinkedListNode lln = new LinkedListNode(evt); + LinkedListNode lln = new(evt); switch (evc) { // These need to go first. The only time we manually @@ -159,14 +159,14 @@ public void PostEvent(EventParams evt) if (evt.Params[0].ToString().Equals(UUID.ZeroString)) { LinkedListNode lln2 = null; - for(lln2 = m_EventQueue.First; lln2 != null; lln2 = lln2.Next) + for(lln2 = m_EventQueue.First; lln2 is not null; lln2 = lln2.Next) { EventParams evt2 = lln2.Value; m_eventCodeMap.TryGetValue(evt2.EventName, out ScriptEventCode evc2); if((evc2 != ScriptEventCode.state_entry) && (evc2 != ScriptEventCode.attach)) break; } - if(lln2 == null) + if(lln2 is null) m_EventQueue.AddLast(lln); else m_EventQueue.AddBefore(lln2, lln); @@ -221,6 +221,7 @@ public void PostEvent(EventParams evt) m_SleepUntil = DateTime.MinValue; m_Engine.WakeFromSleep(this); } + return true; } public void CancelEvent(string eventName) @@ -234,7 +235,7 @@ public void CancelEvent(string eventName) return; LinkedListNode lln2 = null; - for (lln2 = m_EventQueue.First; lln2 != null; lln2 = lln2.Next) + for (lln2 = m_EventQueue.First; lln2 is not null; lln2 = lln2.Next) { EventParams evt2 = lln2.Value; if(evt2.EventName.Equals(eventName)) @@ -284,11 +285,8 @@ public XMRInstState RunOne() try { - //m_RunOnePhase = "check entry invariants"; - CheckRunLockInvariants(true); - - // Maybe it has been Disposed() - if(m_Part == null || m_Part.Inventory == null) + // Maybe it has been Disposed() + if (m_Part is null || m_Part.Inventory is null) { //m_RunOnePhase = "runone saw it disposed"; return XMRInstState.DISPOSED; @@ -312,7 +310,6 @@ public XMRInstState RunOne() m_Suspended = true; m_DetachReady.Set(); //m_RunOnePhase = "detach quantum went zero"; - CheckRunLockInvariants(true); return XMRInstState.FINISHED; } } @@ -345,12 +342,11 @@ public XMRInstState RunOne() if(m_Suspended) { //m_RunOnePhase = "m_Suspended is set"; - CheckRunLockInvariants(true); return XMRInstState.FINISHED; } //m_RunOnePhase = "dequeue event"; - if(m_EventQueue.First != null) + if(m_EventQueue.First is not null) { evt = m_EventQueue.First.Value; m_eventCodeMap.TryGetValue(evt.EventName, out evc); @@ -365,7 +361,6 @@ public XMRInstState RunOne() m_DetachReady.Set(); m_DetachQuantum = 0; //m_RunOnePhase = "nothing to do #3"; - CheckRunLockInvariants(true); return XMRInstState.FINISHED; } } @@ -376,7 +371,7 @@ public XMRInstState RunOne() // If there is no event to dequeue, don't run this script // until another event gets queued. - if(evt == null) + if(evt is null) { if(m_DetachQuantum > 0) { @@ -387,14 +382,14 @@ public XMRInstState RunOne() m_DetachQuantum = 0; } //m_RunOnePhase = "nothing to do #4"; - CheckRunLockInvariants(true); return XMRInstState.FINISHED; } } - // Dequeued an event, so start it going until it either - // finishes or it calls CheckRun(). + // Dequeued an event, so start it going until it either + // finishes or it calls CheckRun(). //m_RunOnePhase = "start event handler"; + m_DetectParams = evt.DetectParams; m_LastRanAt = now; m_InstEHEvent++; @@ -404,12 +399,11 @@ public XMRInstState RunOne() m_CPUTime += DateTime.UtcNow.Subtract(now).TotalMilliseconds; // Maybe it puqued. - if(e != null) + if(e is not null) { //m_RunOnePhase = "handling exception " + e.Message; HandleScriptException(e); //m_RunOnePhase = "return had exception " + e.Message; - CheckRunLockInvariants(true); return XMRInstState.FINISHED; } } @@ -420,7 +414,6 @@ public XMRInstState RunOne() m_DetectParams = null; //m_RunOnePhase += "; checking exit invariants and unlocking"; - CheckRunLockInvariants(false); Monitor.Exit(m_RunLock); } @@ -432,28 +425,28 @@ public XMRInstState RunOne() /** * @brief Immediately after taking m_RunLock or just before releasing it, check invariants. */ - //private ScriptEventCode lastEventCode = ScriptEventCode.None; - //private bool lastActive = false; - //private string lastRunPhase = ""; - public void CheckRunLockInvariants(bool throwIt) { - // If not executing any event handler, there shouldn't be any saved stack frames. - // If executing an event handler, there should be some saved stack frames. - bool active = (stackFrames != null); - if((active && (eventCode == ScriptEventCode.None)) || - (!active && (eventCode != ScriptEventCode.None))) + // If not executing any event handler, there shouldn't be any saved stack frames. + // If executing an event handler, there should be some saved stack frames. + if (eventCode == ScriptEventCode.None) { - m_log.Error("CheckRunLockInvariants: script=" + m_DescName); - m_log.Error("CheckRunLockInvariants: eventcode=" + eventCode.ToString() + ", active=" + active.ToString()); - //m_log.Error("CheckRunLockInvariants: m_RunOnePhase=" + m_RunOnePhase); - //m_log.Error("CheckRunLockInvariants: lastec=" + lastEventCode + ", lastAct=" + lastActive + ", lastPhase=" + lastRunPhase); - if(throwIt) - throw new Exception("CheckRunLockInvariants: eventcode=" + eventCode.ToString() + ", active=" + active.ToString()); + if (stackFrames is not null) + { + m_log.Error($"CheckRunLockInvariants: script {m_DescName}, eventcode: None, stackFrame not null"); + if (throwIt) + throw new Exception("CheckRunLockInvariants: eventcode=None, stackFrame not null"); + } + } + else + { + if (stackFrames is null) + { + m_log.Error($"CheckRunLockInvariants: script {m_DescName}, eventcode {eventCode}, stackFrame null"); + if (throwIt) + throw new Exception("CheckRunLockInvariants: eventcode=" + eventCode.ToString() + ", stackFrame null"); + } } - //lastEventCode = eventCode; - //lastActive = active; - //lastRunPhase = m_RunOnePhase; } /* @@ -483,7 +476,7 @@ private Exception StartEventHandler(ScriptEventCode newEventCode, object[] newEh throw new Exception("still processing event " + this.eventCode.ToString()); // Silly to even try if there is no handler defined for this event. - if ((newEventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[stateCode, (int)newEventCode] == null)) + if ((newEventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[stateCode, (int)newEventCode] is null)) return null; // Save eventCode so we know what event handler to run in the microthread. @@ -513,7 +506,7 @@ private void HandleScriptException(Exception e) stackFrames = null; m_DetectParams = null; - if (m_Part == null || m_Part.Inventory == null) + if (m_Part is null || m_Part.Inventory is null || m_Part.ParentGroup is null) { //we are gone and don't know it still m_SleepUntil = DateTime.MaxValue; @@ -560,16 +553,16 @@ private void HandleScriptException(Exception e) private void SendScriptErrorMessage(Exception e, ScriptEventCode ev) { - StringBuilder msg = new StringBuilder(); + StringBuilder msg = new(); bool toowner = false; msg.Append("YEngine: "); string evMessage = null; - if (e != null && !string.IsNullOrEmpty(e.Message)) + if (e is not null && !string.IsNullOrEmpty(e.Message)) { evMessage = e.Message; if (evMessage.StartsWith("(OWNER)")) { - evMessage = evMessage.Substring(7); + evMessage = evMessage[7..]; toowner = true; } if (e is OutOfHeapException) @@ -594,7 +587,7 @@ private void SendScriptErrorMessage(Exception e, ScriptEventCode ev) string msgst = msg.ToString(); if (msgst.Length > 1000) - msgst = msgst.Substring(0, 1000); + msgst = msgst[..1000]; if (toowner) { @@ -627,7 +620,7 @@ private void SendScriptErrorMessage(Exception e, ScriptEventCode ev) */ private void SendErrorMessage(Exception e) { - StringBuilder msg = new StringBuilder(); + StringBuilder msg = new(); msg.Append("[YEngine]: Exception while running "); msg.Append(m_ItemID); @@ -635,7 +628,7 @@ private void SendErrorMessage(Exception e) // Add exception message. string des = e.Message; - des = (des == null) ? "" : (": " + des); + des = (des is null) ? "" : (": " + des); msg.Append(e.GetType().Name + des + "\n"); // Tell script owner what to do. @@ -666,16 +659,15 @@ private void SendErrorMessage(Exception e) if(!msgst.EndsWith("\n")) msgst += '\n'; int j = 0; - StringBuilder imstr = new StringBuilder(); for(int i = 0; (i = msgst.IndexOf('\n', i)) >= 0; j = ++i) { - string line = msgst.Substring(j, i - j); + string line = msgst[j..i]; if(line.StartsWith("at ")) { if(line.StartsWith("at (wrapper")) continue; // at (wrapper ... int k = line.LastIndexOf(".cs:"); // ... .cs:linenumber - if(Int32.TryParse(line.Substring(k + 4), out k)) + if(Int32.TryParse(line.AsSpan(k + 4), out _)) continue; } this.llOwnerSay(line); @@ -800,8 +792,6 @@ public void Reset() // This thread transitioned the instance to RESETTING so reset it. lock(m_RunLock) { - CheckRunLockInvariants(true); - // No other thread should have transitioned it from RESETTING. if (m_IState != XMRInstState.SUSPENDED) { @@ -814,10 +804,6 @@ public void Reset() // Reset everything and queue up default's start_entry() event. ClearQueue(); ResetLocked("external Reset"); - - // Mark it idle now so it can get queued to process new stuff. - - CheckRunLockInvariants(true); } } @@ -834,10 +820,10 @@ private void ClearQueueExceptLinkMessages() } m_EventQueue.Clear(); - for(int i = m_EventCounts.Length; --i >= 0;) + for (int i = 0; i < m_EventCounts.Length; ++i) m_EventCounts[i] = 0; - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) m_EventQueue.AddLast(linkMessages[i]); m_EventCounts[(int)ScriptEventCode.link_message] = n; @@ -849,7 +835,7 @@ private void ClearQueue() lock(m_QueueLock) { m_EventQueue.Clear(); // no events queued - for(int i = m_EventCounts.Length; --i >= 0;) + for (int i = 0; i < m_EventCounts.Length; ++i) m_EventCounts[i] = 0; } } @@ -868,18 +854,16 @@ private void ResetLocked(string from) ReleaseControlsOrPermissions(true); m_Part.CollisionSound = UUID.Zero; - if (m_XMRLSLApi != null) - m_XMRLSLApi.llResetTime(); + m_XMRLSLApi?.llResetTime(); //m_RunOnePhase = "ResetLocked: removing script"; IUrlModule urlModule = m_Engine.World.RequestModuleInterface(); - if(urlModule != null) - urlModule.ScriptRemoved(m_ItemID); + urlModule?.ScriptRemoved(m_ItemID); AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); //m_RunOnePhase = "ResetLocked: clearing current event"; - this.eventCode = ScriptEventCode.None; // not processing an event + eventCode = ScriptEventCode.None; // not processing an event m_DetectParams = null; // not processing an event m_SleepUntil = DateTime.MinValue; // not doing llSleep() m_ResetCount++; // has been reset once more @@ -912,7 +896,7 @@ private void ResetLocked(string from) private void ReleaseControlsOrPermissions(bool fullPermissions) { - if(m_Part != null && m_Part.TaskInventory != null) + if(m_Part is not null && m_Part.TaskInventory is not null) { int permsMask; UUID permsGranter; @@ -936,8 +920,7 @@ private void ReleaseControlsOrPermissions(bool fullPermissions) if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); - if (presence != null) - presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); + presence?.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); } } } @@ -1012,8 +995,8 @@ public void ResumeIt() m_Suspended = false; m_DetachQuantum = 0; m_DetachReady.Set(); - if ((m_EventQueue != null) && - (m_EventQueue.First != null) && + if ((m_EventQueue is not null) && + (m_EventQueue.First is not null) && (m_IState == XMRInstState.IDLE)) { m_IState = XMRInstState.ONSTARTQ; diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRScriptUThread.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRScriptUThread.cs index 541d73936aa..f635b67055d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRScriptUThread.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRScriptUThread.cs @@ -72,6 +72,12 @@ public Exception StartEx() public Exception ResumeEx() { // Resume script from captured stack. + if (stackFrames is null) + { + m_log.Error($"ResumeEx: eventcode: None, stackFrame is null"); + throw new Exception("ResumeEx: stackFrame is null"); + } + callMode = XMRInstance.CallMode_RESTORE; suspendOnCheckRunTemp = true; try diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 8d569c14f03..79a43a4f003 100755 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -123,13 +123,13 @@ protected override void ReadConfig() if ( cert_path.Length == 0 ) { System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + //Thread.CurrentThread.Abort(); } string cert_pass = networkConfig.GetString("cert_pass", string.Empty); if ( cert_pass.Length == 0 ) { System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); - Thread.CurrentThread.Abort(); + //Thread.CurrentThread.Abort(); } MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); diff --git a/OpenSim/Server/Base/OpenSim.Server.Base.csproj b/OpenSim/Server/Base/OpenSim.Server.Base.csproj index ed1a8cb9b97..5013fcfc884 100644 --- a/OpenSim/Server/Base/OpenSim.Server.Base.csproj +++ b/OpenSim/Server/Base/OpenSim.Server.Base.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Server.Base http://opensimulator.org OpenSim @@ -10,6 +10,7 @@ + diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 1389cac8b55..0c54c3ff192 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -355,14 +355,13 @@ public static Dictionary ParseQueryString(string query) continue; if (result.ContainsKey(name)) { - if (!(result[name] is List)) + if (result[name] is not List l) continue; - List l = (List)result[name]; - if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + if (elems.Length > 1 && !string.IsNullOrWhiteSpace(elems[1])) l.Add(System.Web.HttpUtility.UrlDecode(elems[1])); else - l.Add(String.Empty); + l.Add(string.Empty); } else { @@ -399,15 +398,13 @@ public static string BuildQueryString(Dictionary data) foreach (KeyValuePair kvp in data) { - if (kvp.Value is List) + if (kvp.Value is List l) { - List l = (List)kvp.Value; - int llen = l.Count; string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key); - for(int i = 0; i < llen; ++i) + for (int i = 0; i < l.Count; ++i) { if (sb.Length != 0) - sb.Append("&"); + sb.Append('&'); sb.Append(nkey); sb.Append("[]="); sb.Append(System.Web.HttpUtility.UrlEncode(l[i])); @@ -416,15 +413,9 @@ public static string BuildQueryString(Dictionary data) else if(kvp.Value is Dictionary) { // encode complex structures as JSON - // needed for estate bans with the encoding used on xml - // encode can be here because object does contain the structure information - // but decode needs to be on estateSettings (or other user) string js; try { - // bypass libovm, we dont need even more useless high level maps - // this should only be called once.. but no problem, i hope - // (other uses may need more..) LitJson.JsonMapper.RegisterExporter((uuid, writer) => writer.Write(uuid.ToString()) ); js = LitJson.JsonMapper.ToJson(kvp.Value); } @@ -434,21 +425,21 @@ public static string BuildQueryString(Dictionary data) continue; } if (sb.Length != 0) - sb.Append("&"); + sb.Append('&'); sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); - sb.Append("="); + sb.Append('='); sb.Append(System.Web.HttpUtility.UrlEncode(js)); } else { if (sb.Length != 0) - sb.Append("&"); + sb.Append('&'); sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); pvalue = kvp.Value.ToString(); - if (!String.IsNullOrEmpty(pvalue)) + if (!string.IsNullOrEmpty(pvalue)) { - sb.Append("="); + sb.Append('='); sb.Append(System.Web.HttpUtility.UrlEncode(pvalue)); } } @@ -462,8 +453,7 @@ public static string BuildXmlResponse(Dictionary data) { XmlDocument doc = new XmlDocument(); - XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, - "", ""); + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); doc.AppendChild(xmlnode); @@ -480,26 +470,22 @@ private static void BuildXmlData(XmlElement parent, Dictionary d { foreach (KeyValuePair kvp in data) { - if (kvp.Value == null) + if (kvp.Value is null) continue; - XmlElement elem = parent.OwnerDocument.CreateElement("", - XmlConvert.EncodeLocalName(kvp.Key), ""); + XmlElement elem = parent.OwnerDocument.CreateElement("", XmlConvert.EncodeLocalName(kvp.Key), ""); - if (kvp.Value is Dictionary) + if (kvp.Value is Dictionary dic) { - XmlAttribute type = parent.OwnerDocument.CreateAttribute("", - "type", ""); + XmlAttribute type = parent.OwnerDocument.CreateAttribute("", "type", ""); type.Value = "List"; - elem.Attributes.Append(type); - BuildXmlData(elem, (Dictionary)kvp.Value); + BuildXmlData(elem, dic); } else { - elem.AppendChild(parent.OwnerDocument.CreateTextNode( - kvp.Value.ToString())); + elem.AppendChild(parent.OwnerDocument.CreateTextNode(kvp.Value.ToString())); } parent.AppendChild(elem); @@ -541,22 +527,30 @@ private static Dictionary ScanXmlResponse(XmlReader xr) return ret; } - public static Dictionary ParseXmlResponse(string data) + private static readonly XmlReaderSettings ParseXmlStringResponseXmlReaderSettings = new() { - //m_log.DebugFormat("[XXX]: received xml string: {0}", data); + IgnoreWhitespace = true, + IgnoreComments = true, + ConformanceLevel = ConformanceLevel.Fragment, + CloseInput = true, + MaxCharactersInDocument = 50_000_000 + }; + + private static readonly XmlParserContext ParseXmlResponseXmlParserContext = new(null, null, null, XmlSpace.None) + { + Encoding = Util.UTF8NoBomEncoding + }; + public static Dictionary ParseXmlResponse(string data) + { try { - XmlReaderSettings xset = new XmlReaderSettings() { IgnoreWhitespace = true, IgnoreComments = true, ConformanceLevel = ConformanceLevel.Fragment, CloseInput = true }; - XmlParserContext xpc = new XmlParserContext(null, null, null, XmlSpace.None); - xpc.Encoding = Util.UTF8NoBomEncoding; - using (XmlReader xr = XmlReader.Create(new StringReader(data), xset, xpc)) - { + using XmlReader xr = XmlReader.Create(new StringReader(data), + ParseXmlStringResponseXmlReaderSettings, ParseXmlResponseXmlParserContext); if(!xr.ReadToFollowing("ServerResponse")) return new Dictionary(); return ScanXmlResponse(xr); } - } catch (Exception e) { m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0}\n --string:\n{1}\n", e.Message, data); @@ -564,26 +558,21 @@ public static Dictionary ParseXmlResponse(string data) return new Dictionary(); } - public static Dictionary ParseXmlResponse(Stream src) + private static readonly XmlReaderSettings ParseXmlStreamResponseXmlReaderSettings = new() { - //m_log.DebugFormat("[XXX]: received xml string: {0}", data); + IgnoreWhitespace = true, + IgnoreComments = true, + ConformanceLevel = ConformanceLevel.Fragment, + CloseInput = true, + MaxCharactersInDocument = 50_000_000 + }; - try - { - XmlReaderSettings xset = new XmlReaderSettings() { IgnoreWhitespace = true, IgnoreComments = true, ConformanceLevel = ConformanceLevel.Fragment, CloseInput = true }; - XmlParserContext xpc = new XmlParserContext(null, null, null, XmlSpace.None); - xpc.Encoding = Util.UTF8NoBomEncoding; - using (XmlReader xr = XmlReader.Create(src, xset, xpc)) - { - if (!xr.ReadToFollowing("ServerResponse")) - return new Dictionary(); + public static Dictionary ParseXmlResponse(Stream src) + { + using XmlReader xr = XmlReader.Create(src, + ParseXmlStreamResponseXmlReaderSettings, ParseXmlResponseXmlParserContext); + if (xr.ReadToFollowing("ServerResponse")) return ScanXmlResponse(xr); - } - } - catch (Exception e) - { - m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0}", e.Message); - } return new Dictionary(); } diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index f6fc1b217e5..2bed8242c1c 100755 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -94,7 +94,7 @@ public ServicesServerBase(string prompt, string[] args) : base() prompt = startupConfig.GetString("prompt", prompt); // Check for a Log4Net config file on the command line - logConfig =startupConfig.GetString("logconfig", logConfig); + logConfig = startupConfig.GetString("logconfig", logConfig); } Config = ReadConfigSource(iniFile); @@ -154,14 +154,14 @@ public ServicesServerBase(string prompt, string[] args) : base() MainConsole.Instance.ReadConfig(Config); m_console = MainConsole.Instance; - if (logConfig != null) + if (!string.IsNullOrEmpty(logConfig)) { FileInfo cfg = new FileInfo(logConfig); XmlConfigurator.Configure(cfg); } else { - XmlConfigurator.Configure(); + XmlConfigurator.Configure(new FileInfo("Robust.exe.config")); } RegisterCommonAppenders(startupConfig); diff --git a/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs index a581ea2d80d..f9cf494cd41 100644 --- a/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs +++ b/OpenSim/Server/Handlers/AgentPreferences/AgentPreferencesServiceConnector.cs @@ -56,7 +56,7 @@ public AgentPreferencesServiceConnector(IConfigSource config, IHttpServer server Object[] args = new Object[] { config }; m_AgentPreferencesService = ServerUtils.LoadPlugin(service, args); - IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); server.AddStreamHandler(new AgentPreferencesServerPostHandler(m_AgentPreferencesService, auth)); } diff --git a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs deleted file mode 100644 index 4d2228a025f..00000000000 --- a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using System.Net; -using System.Text; -using System.Xml; -using System.Xml.Serialization; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Server.Handlers.Asset; -using OpenSim.Services.AssetService; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Server.Handlers.Asset.Test -{ - [TestFixture] - public class AssetServerPostHandlerTests : OpenSimTestCase - { - [Test] - public void TestGoodAssetStoreRequest() - { - TestHelpers.InMethod(); - - UUID assetId = TestHelpers.ParseTail(0x1); - - IConfigSource config = new IniConfigSource(); - config.AddConfig("AssetService"); - config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - AssetService assetService = new AssetService(config); - - AssetServerPostHandler asph = new AssetServerPostHandler(assetService); - - AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World"); - - MemoryStream buffer = new MemoryStream(); - - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; - - using (XmlWriter writer = XmlWriter.Create(buffer, settings)) - { - XmlSerializer serializer = new XmlSerializer(typeof(AssetBase)); - serializer.Serialize(writer, asset); - writer.Flush(); - } - - buffer.Position = 0; - asph.Handle(null, buffer, null, null); - - AssetBase retrievedAsset = assetService.Get(assetId.ToString()); - - Assert.That(retrievedAsset, Is.Not.Null); - } - - [Test] - public void TestBadXmlAssetStoreRequest() - { - TestHelpers.InMethod(); - - IConfigSource config = new IniConfigSource(); - config.AddConfig("AssetService"); - config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - AssetService assetService = new AssetService(config); - - AssetServerPostHandler asph = new AssetServerPostHandler(assetService); - - MemoryStream buffer = new MemoryStream(); - byte[] badData = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f }; - buffer.Write(badData, 0, badData.Length); - buffer.Position = 0; - - TestOSHttpResponse response = new TestOSHttpResponse(); - asph.Handle(null, buffer, null, response); - - Assert.That(response.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs index 014fc3fb846..84c2cf458f1 100644 --- a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs +++ b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs @@ -63,7 +63,7 @@ public EstateDataRobustConnector(IConfigSource config, IHttpServer server, strin Object[] args = new Object[] { config }; IEstateDataService e_service = ServerUtils.LoadPlugin(service, args); - IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); server.AddStreamHandler(new EstateServerGetHandler(e_service, auth)); server.AddStreamHandler(new EstateServerPostHandler(e_service, auth)); diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs index c76d342b332..31c1ef8c42e 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs @@ -65,16 +65,9 @@ public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remote if (name == null) name = string.Empty; - UUID regionID = UUID.Zero; - string externalName = string.Empty; - string imageURL = string.Empty; - ulong regionHandle = 0; - string reason = string.Empty; - int sizeX = 256; - int sizeY = 256; - m_log.DebugFormat("[HG Handler]: XMLRequest to link to {0} from {1}", (name.Length == 0) ? "default region" : name, remoteClient.Address.ToString()); - bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason, out sizeX, out sizeY); + bool success = m_GatekeeperService.LinkLocalRegion(name, out UUID regionID, out ulong regionHandle, out string externalName, + out string imageURL, out string reason, out int sizeX, out int sizeY); Hashtable hash = new Hashtable(); hash["result"] = success.ToString(); diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 598c1dbe2d0..b39c9bfd27e 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -507,8 +507,8 @@ byte[] HandleMoveItems(Dictionary request) { List idlist = (List)request["IDLIST"]; List destlist = (List)request["DESTLIST"]; - UUID principal = UUID.Zero; - UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + + UUID.TryParse(request["PRINCIPAL"].ToString(), out UUID principal); List items = new List(); int n = 0; @@ -583,14 +583,19 @@ byte[] HandleGetItem(Dictionary request) byte[] HandleGetMultipleItems(Dictionary request) { Dictionary resultSet = new Dictionary(); - UUID principal = UUID.Zero; - UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); + + if(!UUID.TryParse(request["PRINCIPAL"].ToString(), out UUID principal)) + return Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(resultSet)); + string itemIDstr = request["ITEMS"].ToString(); - int count = 0; - Int32.TryParse(request["COUNT"].ToString(), out count); + if(string.IsNullOrEmpty(itemIDstr)) + return Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(resultSet)); - UUID[] fids = new UUID[count]; string[] uuids = itemIDstr.Split(','); + if(uuids.Length == 0) + return Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(resultSet)); + + UUID[] fids = new UUID[uuids.Length]; int i = 0; foreach (string id in uuids) { @@ -603,9 +608,9 @@ byte[] HandleGetMultipleItems(Dictionary request) InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids); if (itemsList != null && itemsList.Length > 0) { - count = 0; + int count = 0; foreach (InventoryItemBase item in itemsList) - resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item); + resultSet["item_" + count++] = (item == null) ? "NULL" : EncodeItem(item); } string xmlString = ServerUtils.BuildXmlResponse(resultSet); diff --git a/OpenSim/Server/Handlers/OpenSim.Server.Handlers.Tests.csproj b/OpenSim/Server/Handlers/OpenSim.Server.Handlers.Tests.csproj index 067c9a51887..ddd86435c65 100644 --- a/OpenSim/Server/Handlers/OpenSim.Server.Handlers.Tests.csproj +++ b/OpenSim/Server/Handlers/OpenSim.Server.Handlers.Tests.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 diff --git a/OpenSim/Server/Handlers/OpenSim.Server.Handlers.csproj b/OpenSim/Server/Handlers/OpenSim.Server.Handlers.csproj index 6cfe71c1a55..c217c1e4b1a 100644 --- a/OpenSim/Server/Handlers/OpenSim.Server.Handlers.csproj +++ b/OpenSim/Server/Handlers/OpenSim.Server.Handlers.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Server.Handlers http://opensimulator.org OpenSim @@ -50,5 +50,6 @@ + \ No newline at end of file diff --git a/OpenSim/Server/Robust.csproj b/OpenSim/Server/Robust.csproj index ba41bb27664..cbbd81c73df 100644 --- a/OpenSim/Server/Robust.csproj +++ b/OpenSim/Server/Robust.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe @@ -110,5 +110,6 @@ + diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index b57580b6d8a..1e5874ecece 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs @@ -47,7 +47,7 @@ public class OpenSimServer private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); protected static HttpServerBase m_Server = null; - protected static List m_ServiceConnectors = new List(); + protected static List m_ServiceConnectors = new(); protected static PluginLoader loader; private static bool m_NoVerifyCertChain = false; @@ -82,7 +82,7 @@ private static void PrintFileToConsole(string fileName) using(StreamReader readFile = File.OpenText(fileName)) { string currentLine; - while ((currentLine = readFile.ReadLine()) != null) + while ((currentLine = readFile.ReadLine()) is not null) { m_log.InfoFormat("[!]" + currentLine); } @@ -101,7 +101,7 @@ public static int Main(string[] args) ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; - + m_Server = new HttpServerBase("R.O.B.U.S.T.", args); string registryLocation; @@ -119,6 +119,7 @@ public static int Main(string[] args) m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); + WebUtil.SetupHTTPClients(m_NoVerifyCertChain, m_NoVerifyCertHostname, null, 32); string connList = serverConfig.GetString("ServiceConnectors", string.Empty); @@ -127,7 +128,7 @@ public static int Main(string[] args) IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; if (servicesConfig != null) { - List servicesList = new List(); + List servicesList = new(); if (!string.IsNullOrEmpty(connList)) servicesList.Add(connList); @@ -141,6 +142,29 @@ public static int Main(string[] args) connList = string.Join(",", servicesList.ToArray()); } + // temporay set the platform dependent System.Drawing.Common.dll + string targetdll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), + "System.Drawing.Common.dll"); + string src = targetdll + (Util.IsWindows() ? ".win" : ".linux"); + try + { + if (!File.Exists(targetdll)) + File.Copy(src, targetdll); + else + { + FileInfo targetInfo = new(targetdll); + FileInfo srcInfo = new(src); + if (targetInfo.Length != srcInfo.Length) + File.Copy(src, targetdll, true); + } + } + catch (Exception e) + { + m_log.Error("Failed to copy System.Drawing.Common.dll for current platform" + e.Message); + throw; + } + + string[] conns = connList.Split(new char[] {',', ' ', '\n', '\r', '\t'}); foreach (string c in conns) @@ -213,8 +237,7 @@ public static int Main(string[] args) int res = m_Server.Run(); - if(m_Server != null) - m_Server.Shutdown(); + m_Server?.Shutdown(); Util.StopThreadPool(); diff --git a/OpenSim/Server/runtimeconfig.template.json b/OpenSim/Server/runtimeconfig.template.json new file mode 100644 index 00000000000..6d427663d0e --- /dev/null +++ b/OpenSim/Server/runtimeconfig.template.json @@ -0,0 +1,11 @@ +{ + "configProperties": { + "System.GC.Server": false, + "System.GC.HighMemoryPercent": 50, + "System.Drawing.EnableUnixSupport": true, + "System.Globalization.UseNls": true, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true, + "System.Runtime.TieredCompilation.QuickJit": false + } +} \ No newline at end of file diff --git a/OpenSim/Services/AssetService/OpenSim.Services.AssetService.csproj b/OpenSim/Services/AssetService/OpenSim.Services.AssetService.csproj index 1b98f1b4052..51f4a54ea86 100644 --- a/OpenSim/Services/AssetService/OpenSim.Services.AssetService.csproj +++ b/OpenSim/Services/AssetService/OpenSim.Services.AssetService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.AssetService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/AuthenticationService/OpenSim.Services.AuthenticationService.csproj b/OpenSim/Services/AuthenticationService/OpenSim.Services.AuthenticationService.csproj index 86cb6d360b1..a1811ce4d61 100644 --- a/OpenSim/Services/AuthenticationService/OpenSim.Services.AuthenticationService.csproj +++ b/OpenSim/Services/AuthenticationService/OpenSim.Services.AuthenticationService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.AuthenticationService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/AuthorizationService/OpenSim.Services.AuthorizationService.csproj b/OpenSim/Services/AuthorizationService/OpenSim.Services.AuthorizationService.csproj index cd1d2ec2bfa..025e21f68be 100644 --- a/OpenSim/Services/AuthorizationService/OpenSim.Services.AuthorizationService.csproj +++ b/OpenSim/Services/AuthorizationService/OpenSim.Services.AuthorizationService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.AuthorizationService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/AvatarService/OpenSim.Services.AvatarService.csproj b/OpenSim/Services/AvatarService/OpenSim.Services.AvatarService.csproj index cb427fdd384..942081d2096 100644 --- a/OpenSim/Services/AvatarService/OpenSim.Services.AvatarService.csproj +++ b/OpenSim/Services/AvatarService/OpenSim.Services.AvatarService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.AvatarService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/Base/OpenSim.Services.Base.csproj b/OpenSim/Services/Base/OpenSim.Services.Base.csproj index 65004ffe0eb..6d0650c4816 100644 --- a/OpenSim/Services/Base/OpenSim.Services.Base.csproj +++ b/OpenSim/Services/Base/OpenSim.Services.Base.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.Base http://opensimulator.org OpenSim diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs index 2017f50cbf4..9cbe7cb59ed 100644 --- a/OpenSim/Services/Base/ServiceBase.cs +++ b/OpenSim/Services/Base/ServiceBase.cs @@ -31,7 +31,6 @@ using System.Reflection; using log4net; using Nini.Config; -using OpenSim.Services.Interfaces; namespace OpenSim.Services.Base { @@ -73,27 +72,22 @@ public T LoadPlugin(string dllName, string className, Object[] args) where T: { Assembly pluginAssembly = Assembly.LoadFrom(dllName); -// m_log.DebugFormat("[SERVICE BASE]: Found assembly {0}", dllName); + //m_log.DebugFormat("[SERVICE BASE]: Found assembly {0}", dllName); foreach (Type pluginType in pluginAssembly.GetTypes()) { -// m_log.DebugFormat("[SERVICE BASE]: Found type {0}", pluginType); + //m_log.DebugFormat("[SERVICE BASE]: Found type {0}", pluginType); if (pluginType.IsPublic) { - if (className != String.Empty && - pluginType.ToString() != - pluginType.Namespace + "." + className) + if (!string.IsNullOrEmpty(className) && + pluginType.ToString() != pluginType.Namespace + "." + className) continue; - Type typeInterface = - pluginType.GetInterface(interfaceName); - if (typeInterface != null) + Type typeInterface = pluginType.GetInterface(interfaceName); + if (typeInterface is not null) { - T plug = (T)Activator.CreateInstance(pluginType, - args); - - return plug; + return (T)Activator.CreateInstance(pluginType, args); } } } @@ -106,10 +100,9 @@ public T LoadPlugin(string dllName, string className, Object[] args) where T: foreach (Object arg in args) strArgs.Add(arg.ToString()); - m_log.Error( - string.Format( + m_log.ErrorFormat( "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}", - interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e); + interfaceName, dllName, string.Join(", ", strArgs.ToArray()), e); return null; } diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs index 310ceae52c9..3aa6b22416c 100644 --- a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs +++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs @@ -39,6 +39,7 @@ using OpenSim.Services.Connectors; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; +using System.Net.Http; namespace OpenSim.Services.Connectors { @@ -319,25 +320,24 @@ private string MakeRequest(string verb, string uri, string formdata) reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, 30, m_Auth); return reply; } - catch (WebException e) + catch (HttpRequestException e) { - using (HttpWebResponse hwr = (HttpWebResponse)e.Response) + if (e.StatusCode is HttpStatusCode status) { - if (hwr != null) + if (status == HttpStatusCode.Unauthorized) { - if (hwr.StatusCode == HttpStatusCode.NotFound) - { - m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri)); - return reply; - } - if (hwr.StatusCode == HttpStatusCode.Unauthorized) - m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri)); + m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri)); + } + else if (status != HttpStatusCode.NotFound) + { + m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri)); + return reply; } - else - m_log.Error(string.Format( - "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}", - verb, uri, formdata, e.Message)); } + else + m_log.Error(string.Format( + "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}", + verb, uri, formdata, e.Message)); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs index 32b95cabba9..ec0c3bf8de6 100644 --- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs @@ -369,11 +369,20 @@ public GridRegion GetRegionByName(UUID scopeID, string regionName) return rinfo; } + public GridRegion GetLocalRegionByName(UUID scopeID, string regionName) + { + return null; + } public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri) { return null; } + public GridRegion GetLocalRegionByURI(UUID scopeID, RegionURI uri) + { + return null; + } + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 43da95b72bd..05355fb18dd 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -42,6 +42,7 @@ using log4net; using OpenSim.Services.Connectors.Simulation; +using System.Net.Http; namespace OpenSim.Services.Connectors.Hypergrid { @@ -94,7 +95,8 @@ public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, XmlRpcResponse response = null; try { - response = request.Send(info.ServerURI, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(info.ServerURI, hclient); } catch (Exception e) { @@ -230,7 +232,8 @@ public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID XmlRpcResponse response = null; try { - response = request.Send(gatekeeper.ServerURI, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(gatekeeper.ServerURI, hclient); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs index 1fabe3d9fe9..e6917bbffbb 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs @@ -30,6 +30,8 @@ using System.Net; using System.Reflection; using Nini.Config; +using System.Net.Http; +using OpenSim.Framework; namespace OpenSim.Services.Connectors { diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index b0cb80f291a..b7090fcae09 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -41,6 +41,7 @@ using log4net; using Nwc.XmlRpc; using Nini.Config; +using System.Net.Http; namespace OpenSim.Services.Connectors.Hypergrid { @@ -162,7 +163,8 @@ private Hashtable CallServer(string methodName, Hashtable hash) XmlRpcResponse response = null; try { - response = request.Send(m_ServerURL, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(m_ServerURL, hclient); } catch (Exception e) { @@ -180,7 +182,7 @@ private Hashtable CallServer(string methodName, Hashtable hash) throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURL)); } - return (Hashtable)response.Value; ; + return (Hashtable)response.Value; } public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) @@ -336,7 +338,8 @@ public List StatusNotification(List friends, UUID userID, bool onl XmlRpcResponse response = null; try { - response = request.Send(m_ServerURL, 6000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(m_ServerURL, hclient); } catch { @@ -408,7 +411,8 @@ public List GetOnlineFriends(UUID userID, List friends) XmlRpcResponse response = null; try { - response = request.Send(m_ServerURL, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(m_ServerURL, hclient); } catch { @@ -558,7 +562,8 @@ private bool GetBoolResponse(XmlRpcRequest request, out string reason) XmlRpcResponse response = null; try { - response = request.Send(m_ServerURL, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + response = request.Send(m_ServerURL, hclient); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs index fa50b24d16a..c836f896050 100644 --- a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs +++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs @@ -26,8 +26,6 @@ */ using System; using System.Collections; -using System.Collections.Generic; -using System.Net; using System.Reflection; using OpenMetaverse; @@ -35,14 +33,13 @@ using log4net; using OpenSim.Framework; +using System.Net.Http; namespace OpenSim.Services.Connectors.InstantMessage { public class InstantMessageServiceConnector { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// This actually does the XMLRPC Request @@ -55,28 +52,17 @@ public static bool SendInstantMessage(string url, GridInstantMessage im, string Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im, messageKey); xmlrpcdata["region_handle"] = 0; - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); + XmlRpcRequest GridReq = new("grid_instant_message", new ArrayList { xmlrpcdata }); try { - - XmlRpcResponse GridResp = GridReq.Send(url, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + XmlRpcResponse GridResp = GridReq.Send(url, hclient); Hashtable responseData = (Hashtable)GridResp.Value; if (responseData.ContainsKey("success")) { - if ((string)responseData["success"] == "TRUE") - { - //m_log.DebugFormat("[XXX] Success"); - return true; - } - else - { - //m_log.DebugFormat("[XXX] Fail"); - return false; - } + return ((string)responseData["success"] == "TRUE"); } else { @@ -84,7 +70,7 @@ public static bool SendInstantMessage(string url, GridInstantMessage im, string return false; } } - catch (WebException e) + catch (Exception e) { m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} : {1}", url, e.Message); } @@ -99,33 +85,31 @@ public static bool SendInstantMessage(string url, GridInstantMessage im, string /// Hashtable containing the XMLRPC request protected static Hashtable ConvertGridInstantMessageToXMLRPC(GridInstantMessage msg, string messageKey) { - Hashtable gim = new Hashtable(); - gim["from_agent_id"] = msg.fromAgentID.ToString(); - // Kept for compatibility - gim["from_agent_session"] = UUID.Zero.ToString(); - gim["to_agent_id"] = msg.toAgentID.ToString(); - gim["im_session_id"] = msg.imSessionID.ToString(); - gim["timestamp"] = msg.timestamp.ToString(); - gim["from_agent_name"] = msg.fromAgentName; - gim["message"] = msg.message; - byte[] dialogdata = new byte[1]; dialogdata[0] = msg.dialog; - gim["dialog"] = Convert.ToBase64String(dialogdata, Base64FormattingOptions.None); + Hashtable gim = new() + { + ["from_agent_id"] = msg.fromAgentID.ToString(), + // Kept for compatibility + ["from_agent_session"] = UUID.Zero.ToString(), + ["to_agent_id"] = msg.toAgentID.ToString(), + ["im_session_id"] = msg.imSessionID.ToString(), + ["timestamp"] = msg.timestamp.ToString(), + ["from_agent_name"] = msg.fromAgentName, + ["message"] = msg.message, + ["from_group"] = msg.fromGroup ? "TRUE" : "FALSE", + ["parent_estate_id"] = msg.ParentEstateID.ToString(), + ["position_x"] = msg.Position.X.ToString(), + ["position_y"] = msg.Position.Y.ToString(), + ["position_z"] = msg.Position.Z.ToString(), + ["region_id"] = msg.RegionID.ToString(), + + ["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None), + ["region_id"] = new UUID(msg.RegionID).ToString(), - if (msg.fromGroup) - gim["from_group"] = "TRUE"; - else - gim["from_group"] = "FALSE"; - byte[] offlinedata = new byte[1]; offlinedata[0] = msg.offline; - gim["offline"] = Convert.ToBase64String(offlinedata, Base64FormattingOptions.None); - gim["parent_estate_id"] = msg.ParentEstateID.ToString(); - gim["position_x"] = msg.Position.X.ToString(); - gim["position_y"] = msg.Position.Y.ToString(); - gim["position_z"] = msg.Position.Z.ToString(); - gim["region_id"] = msg.RegionID.ToString(); - gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None); - gim["region_id"] = new UUID(msg.RegionID).ToString(); + ["dialog"] = Convert.ToBase64String(new byte[] { msg.dialog }, Base64FormattingOptions.None), + ["offline"] = Convert.ToBase64String(new byte[] { msg.offline }, Base64FormattingOptions.None) + }; - if (messageKey != String.Empty) + if (!string.IsNullOrEmpty(messageKey)) gim["message_key"] = messageKey; return gim; diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 0fdb6c442cb..02679ed5998 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs @@ -29,30 +29,32 @@ using System; using System.Collections.Generic; using System.IO; +using System.Net; +using System.Net.Http; using System.Reflection; using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Console; +using OpenSim.Framework; using OpenSim.Framework.Monitoring; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenMetaverse; +using System.Text; +using System.Threading; namespace OpenSim.Services.Connectors { public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Number of requests made to the remote inventory service. /// public int RequestsMade { get; private set; } - private string m_ServerURI = String.Empty; + private string m_InventoryURL = string.Empty; /// /// Timeout for remote requests. @@ -60,11 +62,11 @@ public class XInventoryServicesConnector : BaseServiceConnector, IInventoryServi /// /// In this case, -1 is default timeout (100 seconds), not infinite. /// - private int m_requestTimeoutSecs = -1; - private string m_configName = "InventoryService"; + private int m_requestTimeout = -1; + private readonly string m_configName = "InventoryService"; - private const double CACHE_EXPIRATION_SECONDS = 60.0; - private static ExpiringCacheOS m_ItemCache = new ExpiringCacheOS(30000); + private const double CACHE_EXPIRATION_SECONDS = 30.0; + private static readonly ExpiringCacheOS m_ItemCache = new(15000); public XInventoryServicesConnector() { @@ -72,7 +74,11 @@ public XInventoryServicesConnector() public XInventoryServicesConnector(string serverURI) { - m_ServerURI = serverURI.TrimEnd('/'); + if (serverURI.EndsWith('/')) + m_InventoryURL = serverURI + "xinventory"; + else + m_InventoryURL = serverURI + "/xinventory"; + } public XInventoryServicesConnector(IConfigSource source, string configName) @@ -91,23 +97,24 @@ public XInventoryServicesConnector(IConfigSource source) public virtual void Initialise(IConfigSource source) { IConfig config = source.Configs[m_configName]; - if (config == null) + if (config is null) { m_log.ErrorFormat("[INVENTORY CONNECTOR]: {0} missing from OpenSim.ini", m_configName); throw new Exception("Inventory connector init error"); } - string serviceURI = config.GetString("InventoryServerURI", - String.Empty); - + string serviceURI = config.GetString("InventoryServerURI", string.Empty); if (serviceURI.Length == 0) { m_log.Error("[INVENTORY CONNECTOR]: No Server URI named in section InventoryService"); throw new Exception("Inventory connector init error"); } - m_ServerURI = serviceURI; + if (serviceURI.EndsWith('/')) + m_InventoryURL = serviceURI + "xinventory"; + else + m_InventoryURL = serviceURI + "/xinventory"; - m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs); + m_requestTimeout = 1000 * config.GetInt("RemoteRequestTimeout", -1); StatsManager.RegisterStat( new Stat( @@ -123,37 +130,27 @@ public virtual void Initialise(IConfigSource source) StatVerbosity.Debug)); } - private bool CheckReturn(Dictionary ret) + private static bool CheckReturn(Dictionary ret) { - if (ret == null) + if (ret is null || ret.Count == 0) return false; - if (ret.Count == 0) - return false; - - if (ret.ContainsKey("RESULT")) + if (ret.TryGetValue("RESULT", out object retResult)) { - if (ret["RESULT"] is string) + if (retResult is string sretResult) { - bool result; - - if (bool.TryParse((string)ret["RESULT"], out result)) + if (bool.TryParse(sretResult, out bool result)) return result; - return false; } } - return true; } public bool CreateUserInventory(UUID principalID) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "CREATEUSERINVENTORY"}, - { "PRINCIPAL", principalID.ToString() } - }); + $"METHOD=CREATEUSERINVENTORY&PRINCIPAL={principalID}"); return CheckReturn(ret); } @@ -161,17 +158,14 @@ public bool CreateUserInventory(UUID principalID) public List GetInventorySkeleton(UUID principalID) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETINVENTORYSKELETON"}, - { "PRINCIPAL", principalID.ToString() } - }); + $"METHOD=GETINVENTORYSKELETON&PRINCIPAL={principalID}"); if (!CheckReturn(ret)) return null; Dictionary folders = (Dictionary)ret["FOLDERS"]; - List fldrs = new List(); + List fldrs = new(); try { @@ -188,11 +182,7 @@ public List GetInventorySkeleton(UUID principalID) public InventoryFolderBase GetRootFolder(UUID principalID) { - Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETROOTFOLDER"}, - { "PRINCIPAL", principalID.ToString() } - }); + Dictionary ret = MakeRequest($"METHOD=GETROOTFOLDER&PRINCIPAL={principalID}"); if (!CheckReturn(ret)) return null; @@ -203,11 +193,7 @@ public InventoryFolderBase GetRootFolder(UUID principalID) public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETFOLDERFORTYPE"}, - { "PRINCIPAL", principalID.ToString() }, - { "TYPE", ((int)type).ToString() } - }); + $"METHOD=GETFOLDERFORTYPE&PRINCIPAL={principalID}&TYPE={(int)type}"); if (!CheckReturn(ret)) return null; @@ -217,34 +203,33 @@ public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type) public InventoryCollection GetFolderContent(UUID principalID, UUID folderID) { - InventoryCollection inventory = new InventoryCollection(); - inventory.Folders = new List(); - inventory.Items = new List(); - inventory.OwnerID = principalID; + InventoryCollection inventory = new() + { + Folders = new(), + Items = new(), + OwnerID = principalID + }; try { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETFOLDERCONTENT"}, - { "PRINCIPAL", principalID.ToString() }, - { "FOLDER", folderID.ToString() } - }); + $"METHOD=GETFOLDERCONTENT&PRINCIPAL={principalID}&FOLDER={folderID}"); if (!CheckReturn(ret)) return null; - Dictionary folders = ret.ContainsKey("FOLDERS") ? - (Dictionary)ret["FOLDERS"] : null; - Dictionary items = ret.ContainsKey("ITEMS") ? - (Dictionary)ret["ITEMS"] : null; - - if (folders != null) - foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i + if(ret.TryGetValue("FOLDERS", out object ofolders)) + { + var folders = (Dictionary)ofolders; + foreach (object o in folders.Values) // getting the values directly, we don't care about the keys folder_i inventory.Folders.Add(BuildFolder((Dictionary)o)); - if (items != null) - foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i + } + if(ret.TryGetValue("ITEMS", out object oitems)) + { + var items = (Dictionary)oitems; + foreach (object o in items.Values) // getting the values directly, we don't care about the keys item_i inventory.Items.Add(BuildItem((Dictionary)o)); + } } catch (Exception e) { @@ -261,74 +246,78 @@ public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, try { Dictionary resultSet = MakeRequest( - new Dictionary { - { "METHOD", "GETMULTIPLEFOLDERSCONTENT"}, - { "PRINCIPAL", principalID.ToString() }, - { "FOLDERS", String.Join(",", folderIDs) }, - { "COUNT", folderIDs.Length.ToString() } - }); + $"METHOD=GETMULTIPLEFOLDERSCONTENT&PRINCIPAL={principalID}&FOLDERS={string.Join(',', folderIDs)}&COUNT={folderIDs.Length}"); if (!CheckReturn(resultSet)) return null; int i = 0; - foreach (KeyValuePair kvp in resultSet) + foreach (UUID u in folderIDs.AsSpan()) { - InventoryCollection inventory = new InventoryCollection(); - if (kvp.Key.StartsWith("F_")) + if(resultSet.TryGetValue($"F_{u}", out object oret) && oret is Dictionary ret) { - UUID fid = UUID.Zero; - if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i]) + UUID inventoryFolderID; + if (ret.TryGetValue("FID", out object retFID)) { - inventory.Folders = new List(); - inventory.Items = new List(); - - Dictionary ret = (Dictionary)kvp.Value; - - if (ret.ContainsKey("FID")) + if (!UUID.TryParse((string)retFID, out inventoryFolderID)) { - if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID)) - m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString()); + m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", retFID.ToString()); + inventoryArr[i] = null; + continue; } - else - m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response"); + } + else + { + inventoryArr[i] = null; + m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response"); + continue; + } + if (!ret.TryGetValue("OWNER", out object retOwner) || + !UUID.TryParse((string)retOwner, out UUID inventoryOwnerID)) + { + inventoryArr[i] = null; + m_log.Warn($"[XINVENTORY SERVICES CONNECTOR]: Could not parse folder {retFID} owner id"); + continue; + } + + InventoryCollection inventory = new() + { + FolderID = inventoryFolderID, + OwnerID = inventoryOwnerID, + Folders = new List(), + Items = new List() + }; + + if (!ret.TryGetValue("VERSION", out object retVer) || + !Int32.TryParse((string)retVer, out inventory.Version)) inventory.Version = -1; - if (ret.ContainsKey("VERSION")) - Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version); - if (ret.ContainsKey("OWNER")) - UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID); - //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID); + //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID); - if (ret.TryGetValue("FOLDERS", out object ofolders) && ofolders is Dictionary) + if (ret.TryGetValue("FOLDERS", out object ofolders) && ofolders is Dictionary folders) + { + foreach (object o in folders.Values) // getting the values directly, we don't care about the keys folder_i { - var folders = ofolders as Dictionary; - foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i - { - inventory.Folders.Add(BuildFolder((Dictionary)o)); - } + inventory.Folders.Add(BuildFolder((Dictionary)o)); } + } - if (ret.TryGetValue("ITEMS", out object oitems) && oitems is Dictionary) + if (ret.TryGetValue("ITEMS", out object oitems) && oitems is Dictionary items) + { + foreach (object o in items.Values) // getting the values directly, we don't care about the keys item_i { - var items = oitems as Dictionary; - foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i - { - inventory.Items.Add(BuildItem((Dictionary)o)); - } + inventory.Items.Add(BuildItem((Dictionary)o)); } - inventoryArr[i] = inventory; - } - else - { - m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}", - folderIDs[i], fid); - m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: {0} {1}", String.Join(",", folderIDs), String.Join(",", resultSet.Keys)); } - - i += 1; + inventoryArr[i] = inventory; + } + else + { + inventoryArr[i] = null; + //m_log.Warn($"[XINVENTORY SERVICES CONNECTOR]: Folder {folderIDs[i]} not on reply");, } + i++; } } catch (Exception e) @@ -342,18 +331,14 @@ public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, public List GetFolderItems(UUID principalID, UUID folderID) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETFOLDERITEMS"}, - { "PRINCIPAL", principalID.ToString() }, - { "FOLDER", folderID.ToString() } - }); + $"METHOD=GETFOLDERITEMS&PRINCIPAL={principalID}&FOLDER={folderID}"); if (!CheckReturn(ret)) return null; Dictionary items = (Dictionary)ret["ITEMS"]; - List fitems = new List(); - foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i + List fitems = new(items.Count); + foreach (object o in items.Values) // getting the values directly, we don't care about the keys item_i fitems.Add(BuildItem((Dictionary)o)); return fitems; @@ -378,15 +363,7 @@ public bool AddFolder(InventoryFolderBase folder) public bool UpdateFolder(InventoryFolderBase folder) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "UPDATEFOLDER"}, - { "ParentID", folder.ParentID.ToString() }, - { "Type", folder.Type.ToString() }, - { "Version", folder.Version.ToString() }, - { "Name", folder.Name.ToString() }, - { "Owner", folder.Owner.ToString() }, - { "ID", folder.ID.ToString() } - }); + $"METHOD=UPDATEFOLDER&ParentID={folder.ParentID}&Type={folder.Type}&Version={folder.Version}&Name={folder.Name}&Owner={folder.Owner}&ID={folder.ID}"); return CheckReturn(ret); } @@ -394,19 +371,13 @@ public bool UpdateFolder(InventoryFolderBase folder) public bool MoveFolder(InventoryFolderBase folder) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "MOVEFOLDER"}, - { "ParentID", folder.ParentID.ToString() }, - { "ID", folder.ID.ToString() }, - { "PRINCIPAL", folder.Owner.ToString() } - }); - + $"METHOD=MOVEFOLDER&ParentID={folder.ParentID}&ID={folder.ID}&PRINCIPAL={folder.Owner}"); return CheckReturn(ret); } public bool DeleteFolders(UUID principalID, List folderIDs) { - List slist = new List(); + List slist = new(); foreach (UUID f in folderIDs) slist.Add(f.ToString()); @@ -424,22 +395,15 @@ public bool DeleteFolders(UUID principalID, List folderIDs) public bool PurgeFolder(InventoryFolderBase folder) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "PURGEFOLDER"}, - { "ID", folder.ID.ToString() } - }); - + $"METHOD=PURGEFOLDER&ID={folder.ID}"); return CheckReturn(ret); } public bool AddItem(InventoryItemBase item) { - if (item.Description == null) - item.Description = String.Empty; - if (item.CreatorData == null) - item.CreatorData = String.Empty; - if (item.CreatorId == null) - item.CreatorId = String.Empty; + item.Description ??= string.Empty; + item.CreatorData ??= string.Empty; + item.CreatorId ??= string.Empty; Dictionary ret = MakeRequest( new Dictionary { { "METHOD", "ADDITEM"}, @@ -471,21 +435,20 @@ public bool AddItem(InventoryItemBase item) public bool UpdateItem(InventoryItemBase item) { - if (item.CreatorData == null) - item.CreatorData = String.Empty; + item.CreatorData ??= string.Empty; Dictionary ret = MakeRequest( new Dictionary { { "METHOD", "UPDATEITEM"}, { "AssetID", item.AssetID.ToString() }, { "AssetType", item.AssetType.ToString() }, - { "Name", item.Name.ToString() }, + { "Name", item.Name }, { "Owner", item.Owner.ToString() }, { "ID", item.ID.ToString() }, { "InvType", item.InvType.ToString() }, { "Folder", item.Folder.ToString() }, - { "CreatorId", item.CreatorId.ToString() }, - { "CreatorData", item.CreatorData.ToString() }, - { "Description", item.Description.ToString() }, + { "CreatorId", item.CreatorId }, + { "CreatorData", item.CreatorData }, + { "Description", item.Description }, { "NextPermissions", item.NextPermissions.ToString() }, { "CurrentPermissions", item.CurrentPermissions.ToString() }, { "BasePermissions", item.BasePermissions.ToString() }, @@ -510,8 +473,8 @@ public bool UpdateItem(InventoryItemBase item) public bool MoveItems(UUID principalID, List items) { - List idlist = new List(); - List destlist = new List(); + List idlist = new(); + List destlist = new(); foreach (InventoryItemBase item in items) { @@ -533,7 +496,7 @@ public bool MoveItems(UUID principalID, List items) public bool DeleteItems(UUID principalID, List itemIDs) { - List slist = new List(); + List slist = new(); foreach (UUID f in itemIDs) { @@ -553,21 +516,12 @@ public bool DeleteItems(UUID principalID, List itemIDs) public InventoryItemBase GetItem(UUID principalID, UUID itemID) { - InventoryItemBase retrieved = null; - if (m_ItemCache.TryGetValue(itemID, out retrieved)) - { + if (m_ItemCache.TryGetValue(itemID, out InventoryItemBase retrieved)) return retrieved; - } try { - Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETITEM"}, - { "ID", itemID.ToString() }, - { "PRINCIPAL", principalID.ToString() } - }); - + Dictionary ret = MakeRequest($"METHOD=GETITEM&ID={itemID}&PRINCIPAL={principalID}"); if (!CheckReturn(ret)) return null; @@ -588,49 +542,50 @@ public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] ite //m_log.DebugFormat("[XXX]: In GetMultipleItems {0}", String.Join(",", itemIDs)); InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length]; + // Try to get them from the cache - List pending = new List(); - InventoryItemBase item = null; + InventoryItemBase item; int i = 0; + int pending = 0; - foreach (UUID id in itemIDs) + StringBuilder sb = new(4096); + sb.Append($"METHOD=GETMULTIPLEITEMS&PRINCIPAL={principalID}&ITEMS="); + foreach (UUID id in itemIDs.AsSpan()) { if (m_ItemCache.TryGetValue(id, out item)) itemArr[i++] = item; else - pending.Add(id); + { + sb.Append(id.ToString()); + sb.Append(','); + pending++; + } } - - if (pending.Count == 0) // we're done, everything was in the cache + if(pending == 0) + { return itemArr; + } + + sb.Remove(sb.Length - 1, 1); + sb.Append($"&COUNT={pending}"); try { - Dictionary resultSet = MakeRequest( - new Dictionary { - { "METHOD", "GETMULTIPLEITEMS"}, - { "PRINCIPAL", principalID.ToString() }, - { "ITEMS", String.Join(",", pending.ToArray()) }, - { "COUNT", pending.Count.ToString() } - }); + Dictionary resultSet = MakeRequest(sb.ToString()); if (!CheckReturn(resultSet)) { - if (i == 0) - return null; - else - return itemArr; + return i == 0 ? null : itemArr; } // carry over index i where we left above foreach (KeyValuePair kvp in resultSet) { - InventoryCollection inventory = new InventoryCollection(); if (kvp.Key.StartsWith("item_")) { - if (kvp.Value is Dictionary) + if (kvp.Value is Dictionary dic) { - item = BuildItem((Dictionary)kvp.Value); + item = BuildItem(dic); m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS); itemArr[i++] = item; } @@ -652,11 +607,7 @@ public InventoryFolderBase GetFolder(UUID principalID, UUID folderID) try { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETFOLDER"}, - { "ID", folderID.ToString() }, - { "PRINCIPAL", principalID.ToString() } - }); + $"METHOD=GETFOLDER&ID={folderID}&PRINCIPAL={principalID}"); if (!CheckReturn(ret)) return null; @@ -674,17 +625,17 @@ public InventoryFolderBase GetFolder(UUID principalID, UUID folderID) public List GetActiveGestures(UUID principalID) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETACTIVEGESTURES"}, - { "PRINCIPAL", principalID.ToString() } - }); + $"METHOD=GETACTIVEGESTURES&PRINCIPAL={principalID}"); if (!CheckReturn(ret)) return null; - List items = new List(); + if (ret["ITEMS"] is not Dictionary itemsDict) + return null; + + List items = new(itemsDict.Count); - foreach (Object o in ((Dictionary)ret["ITEMS"]).Values) + foreach (object o in itemsDict.Values) items.Add(BuildItem((Dictionary)o)); return items; @@ -693,23 +644,17 @@ public List GetActiveGestures(UUID principalID) public int GetAssetPermissions(UUID principalID, UUID assetID) { Dictionary ret = MakeRequest( - new Dictionary { - { "METHOD", "GETASSETPERMISSIONS"}, - { "PRINCIPAL", principalID.ToString() }, - { "ASSET", assetID.ToString() } - }); + $"METHOD=GETASSETPERMISSIONS&PRINCIPAL={principalID}&ASSET={assetID}"); // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int - if (ret == null) + if (ret is null) return 0; - if (ret.ContainsKey("RESULT")) + if (ret.TryGetValue("RESULT", out object retRes)) { - if (ret["RESULT"] is string) + if (retRes is string res) { - int intResult; - - if (int.TryParse ((string)ret["RESULT"], out intResult)) + if (int.TryParse (res, out int intResult)) return intResult; } } @@ -724,80 +669,154 @@ public bool HasInventoryForUser(UUID principalID) // Helpers // - private Dictionary MakeRequest(Dictionary sendData) + private Dictionary MakeRequest(Dictionary sendData) { RequestsMade++; + Dictionary replyData = MakePostDicRequest(ServerUtils.BuildQueryString(sendData)); - string reply = String.Empty; - - reply = SynchronousRestFormsRequester.MakePostRequest( - m_ServerURI + "/xinventory", - ServerUtils.BuildQueryString(sendData), m_Auth, m_requestTimeoutSecs); - - if(string.IsNullOrWhiteSpace(reply)) - return new Dictionary(); + return replyData; + } - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + private Dictionary MakeRequest(string query) + { + RequestsMade++; + Dictionary replyData = MakePostDicRequest(query); return replyData; } - private InventoryFolderBase BuildFolder(Dictionary data) + private static InventoryFolderBase BuildFolder(Dictionary data) { - InventoryFolderBase folder = new InventoryFolderBase(); - try { - folder.ParentID = new UUID(data["ParentID"].ToString()); - folder.Type = short.Parse(data["Type"].ToString()); - folder.Version = ushort.Parse(data["Version"].ToString()); - folder.Name = data["Name"].ToString(); - folder.Owner = new UUID(data["Owner"].ToString()); - folder.ID = new UUID(data["ID"].ToString()); + InventoryFolderBase folder = new() + { + ParentID = new UUID((string)data["ParentID"]), + Type = short.Parse((string)data["Type"]), + Version = ushort.Parse((string)data["Version"]), + Name = (string)data["Name"], + Owner = new UUID((string)data["Owner"]), + ID = new UUID((string)data["ID"]) + }; + return folder; } catch (Exception e) { - m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception building folder: " + e.Message); + m_log.Error($"[XINVENTORY SERVICES CONNECTOR]: Exception building folder: {e.Message}"); } - return folder; + return new InventoryFolderBase(); } - private InventoryItemBase BuildItem(Dictionary data) + private static InventoryItemBase BuildItem(Dictionary data) + { + try + { + InventoryItemBase item = new() + { + AssetID = new UUID((string)data["AssetID"]), + AssetType = int.Parse((string)data["AssetType"]), + Name = (string)data["Name"], + Owner = new UUID((string)data["Owner"]), + ID = new UUID((string)data["ID"]), + InvType = int.Parse((string)data["InvType"]), + Folder = new UUID((string)data["Folder"]), + CreatorId = (string)data["CreatorId"], + NextPermissions = uint.Parse((string)data["NextPermissions"]), + CurrentPermissions = uint.Parse((string)data["CurrentPermissions"]), + BasePermissions = uint.Parse((string)data["BasePermissions"]), + EveryOnePermissions = uint.Parse((string)data["EveryOnePermissions"]), + GroupPermissions = uint.Parse((string)data["GroupPermissions"]), + GroupID = new UUID((string)data["GroupID"]), + GroupOwned = bool.Parse((string)data["GroupOwned"]), + SalePrice = int.Parse((string)data["SalePrice"]), + SaleType = byte.Parse((string)data["SaleType"]), + Flags = uint.Parse((string)data["Flags"]), + CreationDate = int.Parse((string)data["CreationDate"]), + Description = (string)data["Description"] + }; + if (data.TryGetValue("CreatorData", out object oCreatorData)) + item.CreatorData = (string)oCreatorData; + return item; + } + catch (Exception e) + { + m_log.Error($"[XINVENTORY CONNECTOR]: Exception building item: {e.Message}"); + } + return new InventoryItemBase(); + } + public Dictionary MakePostDicRequest(string obj) { - InventoryItemBase item = new InventoryItemBase(); + if (WebUtil.DebugLevel >= 3) + m_log.Debug($"[XInventory]: HTTP OUT SynchronousRestForms POST to {m_InventoryURL}"); + if (string.IsNullOrEmpty(obj)) + { + m_log.Warn($"[XInventory]: empty post data"); + return new Dictionary(); + } + Dictionary respDic = null; + int ticks = Util.EnvironmentTickCount(); + int sendlen = 0; + int rcvlen = 0; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - item.AssetID = new UUID(data["AssetID"].ToString()); - item.AssetType = int.Parse(data["AssetType"].ToString()); - item.Name = data["Name"].ToString(); - item.Owner = new UUID(data["Owner"].ToString()); - item.ID = new UUID(data["ID"].ToString()); - item.InvType = int.Parse(data["InvType"].ToString()); - item.Folder = new UUID(data["Folder"].ToString()); - item.CreatorId = data["CreatorId"].ToString(); - if (data.ContainsKey("CreatorData")) - item.CreatorData = data["CreatorData"].ToString(); - item.Description = data["Description"].ToString(); - item.NextPermissions = uint.Parse(data["NextPermissions"].ToString()); - item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString()); - item.BasePermissions = uint.Parse(data["BasePermissions"].ToString()); - item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString()); - item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString()); - item.GroupID = new UUID(data["GroupID"].ToString()); - item.GroupOwned = bool.Parse(data["GroupOwned"].ToString()); - item.SalePrice = int.Parse(data["SalePrice"].ToString()); - item.SaleType = byte.Parse(data["SaleType"].ToString()); - item.Flags = uint.Parse(data["Flags"].ToString()); - item.CreationDate = int.Parse(data["CreationDate"].ToString()); + client = WebUtil.GetNewGlobalHttpClient(m_requestTimeout); + + request = new(HttpMethod.Post, m_InventoryURL); + + m_Auth?.AddAuthorization(request.Headers); + + //if (keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + request.Headers.ConnectionClose = false; + } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); + + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; + + byte[] data = Util.UTF8NBGetbytes(obj); + sendlen = data.Length; + + request.Content = new ByteArrayContent(data); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", sendlen.ToString()); + + responseMessage = client.Send(request, HttpCompletionOption.ResponseHeadersRead); + responseMessage.EnsureSuccessStatusCode(); + + if ((responseMessage.Content.Headers.ContentLength is long contentLength) && contentLength != 0) + { + rcvlen = (int)contentLength; + respDic = ServerUtils.ParseXmlResponse(responseMessage.Content.ReadAsStream()); + } } catch (Exception e) { - m_log.Error("[XINVENTORY CONNECTOR]: Exception building item: ", e); + m_log.Info($"[XInventory]: Error receiving response from {m_InventoryURL}: {e.Message}"); + throw; + } + finally + { + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + } + + ticks = Util.EnvironmentTickCountSubtract(ticks); + if (ticks > WebUtil.LongCallTime) + { + m_log.Info($"[XInventory]: POST {m_InventoryURL} took {ticks}ms {sendlen}/{rcvlen}bytes"); } - return item; + return respDic ?? new Dictionary(); } } } diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs index a1122a25956..977176f6e89 100644 --- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using Nwc.XmlRpc; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using System.Net.Http; namespace OpenSim.Services.Connectors { @@ -92,7 +93,8 @@ public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, ui paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); - XmlRpcResponse response = request.Send(info.ServerURI, 10000); + using HttpClient hclient = WebUtil.GetNewGlobalHttpClient(10000); + XmlRpcResponse response = request.Send(info.ServerURI, hclient); if (response.IsFault) { m_log.ErrorFormat("[LAND CONNECTOR]: remote call returned an error: {0}", response.FaultString); diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index f61679e9882..1079e101ddd 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -224,7 +224,7 @@ public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string re { // This just dumps a warning for any operation that takes more than 100 ms int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); - m_log.DebugFormat("[MAP IMAGE CONNECTOR]: AddMapTile time {0}ms", tickdiff); + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: AddMapTile {1} Bytes in {0}ms", tickdiff, jpgData.Length); } return false; } diff --git a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs index 337fc06c23c..2a2fca1286d 100644 --- a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs +++ b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs @@ -78,7 +78,7 @@ public virtual void Initialise(IConfigSource source) m_log.Error("[MUTELIST CONNECTOR]: No Server URI named in section GridUserService"); throw new Exception("MuteList connector init error"); } - m_ServerURI = serviceURI + "/mutelist";; + m_ServerURI = serviceURI + "/mutelist"; base.Initialise(source, "MuteListService"); } diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs index 86a28479d62..30411111db2 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs @@ -41,6 +41,8 @@ using OpenMetaverse.StructuredData; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using System.Net.Http; +using System.Threading; namespace OpenSim.Services.Connectors { @@ -87,12 +89,12 @@ public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) string uri = region.ServerURI + "region/" + thisRegion.RegionID + "/"; //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); - byte[] buffer = null; + byte[] buffer; try { OSDMap args = thisRegion.PackRegionInfoData(); args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString()); - buffer = Util.UTF8NoBomEncoding.GetBytes(OSDParser.SerializeJsonString(args)); + buffer = OSDParser.SerializeJsonToBytes(args); } catch (Exception e) { @@ -101,66 +103,53 @@ public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) return false; } - if(buffer == null || buffer.Length == 0) + if(buffer is null || buffer.Length == 0) return false; - HttpWebRequest helloNeighbourRequest; + HttpResponseMessage responseMessage = null; + HttpRequestMessage request = null; + HttpClient client = null; try { - helloNeighbourRequest = (HttpWebRequest)WebRequest.Create(uri); - } - catch (Exception e) - { - m_log.WarnFormat( - "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception: {3} ", - uri, thisRegion.RegionName, region.RegionName, e.Message); - - return false; - } + client = WebUtil.GetNewGlobalHttpClient(10000); + request = new(HttpMethod.Post, uri); + request.Headers.ExpectContinue = false; + request.Headers.TransferEncodingChunked = false; + //if (keepalive) + { + request.Headers.TryAddWithoutValidation("Keep-Alive", "timeout=30, max=10"); + request.Headers.TryAddWithoutValidation("Connection", "Keep-Alive"); + } + //else + // request.Headers.TryAddWithoutValidation("Connection", "close"); - helloNeighbourRequest.Method = "POST"; - helloNeighbourRequest.ContentType = "application/json"; - helloNeighbourRequest.Timeout = 10000; + request.Content = new ByteArrayContent(buffer); + request.Content.Headers.TryAddWithoutValidation("Content-Type", "application/json"); + request.Content.Headers.TryAddWithoutValidation("Content-Length", buffer.Length.ToString()); - try - { - helloNeighbourRequest.ContentLength = buffer.Length; - using (var os = helloNeighbourRequest.GetRequestStream()) - os.Write(buffer, 0, buffer.Length); - buffer = null; //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); - } - // catch (Exception e) - catch - { - //m_log.WarnFormat( - // "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", - // thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); - return false; - } - // Let's wait for the response - //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); + responseMessage = client.Send(request, HttpCompletionOption.ResponseContentRead); + responseMessage.EnsureSuccessStatusCode(); - try - { - using (WebResponse webResponse = helloNeighbourRequest.GetResponse()) - { - using (StreamReader sr = new StreamReader(webResponse.GetResponseStream())) - { - sr.ReadToEnd(); // just try to read - //string reply = sr.ReadToEnd(); - //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); - } - } + //using StreamReader sr = new(responseMessage.Content.ReadAsStream()); + //sr.ReadToEnd(); // just try to read + //string reply = sr.ReadToEnd(); + //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); return true; } catch (Exception e) { m_log.WarnFormat( - "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception: {2} ", + "[NEIGHBOUR SERVICES CONNECTOR]: Exception on DoHelloNeighbourCall from {0} back to {1}. Exception: {2} ", region.RegionName, thisRegion.RegionName, e.Message); } + finally + { + request?.Dispose(); + responseMessage?.Dispose(); + client?.Dispose(); + } return false; } } diff --git a/OpenSim/Services/Connectors/OpenSim.Services.Connectors.csproj b/OpenSim/Services/Connectors/OpenSim.Services.Connectors.csproj index 5d14717fce6..121d2258e7a 100644 --- a/OpenSim/Services/Connectors/OpenSim.Services.Connectors.csproj +++ b/OpenSim/Services/Connectors/OpenSim.Services.Connectors.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.Connectors http://opensimulator.org OpenSim @@ -9,6 +9,7 @@ + @@ -28,9 +29,6 @@ ..\..\..\bin\OpenMetaverseTypes.dll False - - False - False @@ -51,4 +49,4 @@ - \ No newline at end of file + diff --git a/OpenSim/Services/EstateService/OpenSim.Services.EstateService.csproj b/OpenSim/Services/EstateService/OpenSim.Services.EstateService.csproj index e9bb0ccf235..d3789335b13 100644 --- a/OpenSim/Services/EstateService/OpenSim.Services.EstateService.csproj +++ b/OpenSim/Services/EstateService/OpenSim.Services.EstateService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.EstateService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/FSAssetService/OpenSim.Services.FSAssetService.csproj b/OpenSim/Services/FSAssetService/OpenSim.Services.FSAssetService.csproj index fffc018268b..b3a8fbddce1 100644 --- a/OpenSim/Services/FSAssetService/OpenSim.Services.FSAssetService.csproj +++ b/OpenSim/Services/FSAssetService/OpenSim.Services.FSAssetService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.FSAssetService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/FreeswitchService/OpenSim.Services.FreeswitchService.csproj b/OpenSim/Services/FreeswitchService/OpenSim.Services.FreeswitchService.csproj index 16e340d0e48..05de4338c09 100644 --- a/OpenSim/Services/FreeswitchService/OpenSim.Services.FreeswitchService.csproj +++ b/OpenSim/Services/FreeswitchService/OpenSim.Services.FreeswitchService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.FreeswitchService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/Friends/OpenSim.Services.FriendsService.csproj b/OpenSim/Services/Friends/OpenSim.Services.FriendsService.csproj index b11fb9347f0..f4c42ddf7da 100644 --- a/OpenSim/Services/Friends/OpenSim.Services.FriendsService.csproj +++ b/OpenSim/Services/Friends/OpenSim.Services.FriendsService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.FriendsService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 41da5ab912c..194858bd3e6 100755 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -546,7 +546,7 @@ public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri) if (localGrid) { - if(uri.HasRegionName) + if (uri.HasRegionName) { RegionData rdata = m_Database.GetSpecific(uri.RegionName, scopeID); if (rdata != null) @@ -583,6 +583,40 @@ public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri) return r; } + public GridRegion GetLocalRegionByName(UUID scopeID, string name) + { + var nameURI = new RegionURI(name); + return GetLocalRegionByURI(scopeID, nameURI); + } + + public GridRegion GetLocalRegionByURI(UUID scopeID, RegionURI uri) + { + if (!uri.IsValid) + return null; + + if (uri.HasHost) + { + if (!uri.ResolveDNS()) + return null; + if(!m_HypergridLinker.IsLocalGrid(uri.HostUrl)) + return null; + } + + if (uri.HasRegionName) + { + RegionData rdata = m_Database.GetSpecific(uri.RegionName, scopeID); + if (rdata != null) + return RegionData2RegionInfo(rdata); + } + else + { + List defregs = GetDefaultRegions(scopeID); + if (defregs != null) + return defregs[0]; + } + return null; + } + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 458d5ecaf62..d9f5a22e20d 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -142,7 +142,7 @@ public HypergridLinker(IConfigSource config, GridService gridService, IRegionDat public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) { string reason = string.Empty; - uint xloc = Util.RegionToWorldLoc((uint)random.Next(0, Int16.MaxValue)); + uint xloc = Util.RegionToWorldLoc((uint)Random.Shared.Next(0, Int16.MaxValue)); return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason); } @@ -157,13 +157,13 @@ public GridRegion LinkRegion(UUID scopeID, RegionURI rurl) return null; } - int xloc = random.Next(0, short.MaxValue) << 8; + int xloc = Random.Shared.Next(0, short.MaxValue) << 8; if(TryCreateLinkImpl(scopeID, xloc, 0, rurl, UUID.Zero, out GridRegion regInfo)) return regInfo; return null; } - private static IPEndPoint dummyIP = new IPEndPoint(0,0); + private static readonly IPEndPoint dummyIP = new IPEndPoint(0,0); private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, RegionURI rurl, UUID ownerID, out GridRegion regInfo) { m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", @@ -243,8 +243,6 @@ private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, RegionURI rurl, return true; } - private static Random random = new Random(); - // From the command line link-region (obsolete) and the map private GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) { @@ -295,7 +293,7 @@ private bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegion private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) { m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", - ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), + (serverURI ?? externalHostName + ":" + externalPort), remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); reason = string.Empty; diff --git a/OpenSim/Services/GridService/OpenSim.Services.GridService.csproj b/OpenSim/Services/GridService/OpenSim.Services.GridService.csproj index b4b0e80fea6..8c18729fb13 100644 --- a/OpenSim/Services/GridService/OpenSim.Services.GridService.csproj +++ b/OpenSim/Services/GridService/OpenSim.Services.GridService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.GridService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 4003df909f4..e5dbd6107be 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -46,9 +46,7 @@ namespace OpenSim.Services.HypergridService { public class GatekeeperService : IGatekeeperService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static bool m_Initialized = false; @@ -65,8 +63,8 @@ public class GatekeeperService : IGatekeeperService private static string m_DeniedMacs = string.Empty; private static string m_DeniedID0s = string.Empty; private static bool m_ForeignAgentsAllowed = true; - private static List m_ForeignsAllowedExceptions = new List(); - private static List m_ForeignsDisallowedExceptions = new List(); + private static readonly List m_ForeignsAllowedExceptions = new(); + private static readonly List m_ForeignsDisallowedExceptions = new(); private static UUID m_ScopeID; private static bool m_AllowTeleportsToAnyRegion; @@ -86,7 +84,7 @@ public GatekeeperService(IConfigSource config, ISimulationService simService) m_Initialized = true; IConfig serverConfig = config.Configs["GatekeeperService"]; - if (serverConfig == null) + if (serverConfig is null) throw new Exception(String.Format("No section GatekeeperService in config file")); string accountService = serverConfig.GetString("UserAccountService", string.Empty); @@ -125,11 +123,10 @@ public GatekeeperService(IConfigSource config, ISimulationService simService) string[] alias = gatekeeperURIAlias.Split(','); for (int i = 0; i < alias.Length; ++i) { - OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false); + OSHHTPHost tmp = new(alias[i].Trim(), false); if (tmp.IsValidHost) { - if (m_gateKeeperAlias == null) - m_gateKeeperAlias = new HashSet(); + m_gateKeeperAlias ??= new HashSet(); m_gateKeeperAlias.Add(tmp); } } @@ -148,9 +145,9 @@ public GatekeeperService(IConfigSource config, ISimulationService simService) if (!string.IsNullOrEmpty(bansService)) m_BansService = ServerUtils.LoadPlugin(bansService, args); - if (simService != null) + if (simService is not null) m_SimulationService = simService; - else if (!string.IsNullOrEmpty(simulationService)) + else if (simulationService != string.Empty) m_SimulationService = ServerUtils.LoadPlugin(simulationService, args); string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "GatekeeperService" }; @@ -190,17 +187,17 @@ public GatekeeperService(IConfigSource config, ISimulationService simService) LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions); - if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) + if (m_GridService is null || m_PresenceService is null || m_SimulationService is null) throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); IConfig presenceConfig = config.Configs["PresenceService"]; - if (presenceConfig != null) + if (presenceConfig is not null) { m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); } IConfig messagingConfig = config.Configs["Messaging"]; - if (messagingConfig != null) + if (messagingConfig is not null) m_messageKey = messagingConfig.GetString("MessageKey", String.Empty); m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); } @@ -225,7 +222,7 @@ protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, L } } - public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY) + public bool LinkLocalRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY) { regionID = UUID.Zero; regionHandle = 0; @@ -234,13 +231,13 @@ public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHan externalName = m_gatekeeperURL + ((regionName != string.Empty) ? " " + regionName : ""); imageURL = string.Empty; reason = string.Empty; - GridRegion region = null; + GridRegion region; //m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName.Length == 0)? "default region" : regionName); if (!m_AllowTeleportsToAnyRegion || regionName.Length == 0) { List defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID); - if (defs != null && defs.Count > 0) + if (defs is not null && defs.Count > 0) { region = defs[0]; m_DefaultGatewayRegion = region; @@ -254,8 +251,8 @@ public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHan } else { - region = m_GridService.GetRegionByName(m_ScopeID, regionName); - if (region == null) + region = m_GridService.GetLocalRegionByName(m_ScopeID, regionName); + if (region is null) { reason = "Region not found"; return false; @@ -287,7 +284,7 @@ public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHo m_DefaultGatewayRegion.RegionID, m_DefaultGatewayRegion.ServerURI, agentID, - agentHomeURI == null ? "" : " @ " + agentHomeURI); + agentHomeURI is null ? "" : " @ " + agentHomeURI); message = "Teleporting to the default region."; return m_DefaultGatewayRegion; @@ -299,7 +296,7 @@ public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHo { m_log.DebugFormat( "[GATEKEEPER SERVICE]: Could not find region with ID {0} as requested by user {1}{2}. Returning null.", - regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI); + regionID, agentID, (agentHomeURI is null) ? "" : " @ " + agentHomeURI); message = "The teleport destination could not be found."; return null; @@ -311,7 +308,7 @@ public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHo region.RegionID, region.ServerURI, agentID, - agentHomeURI == null ? "" : " @ " + agentHomeURI); + agentHomeURI is null ? "" : " @ " + agentHomeURI); return region; } @@ -337,7 +334,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // // Check client // - if (m_AllowedClientsRegex != null) + if (m_AllowedClientsRegex is not null) { lock(m_AllowedClientsRegex) { @@ -352,7 +349,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion } } - if (m_DeniedClientsRegex != null) + if (m_DeniedClientsRegex is not null) { lock(m_DeniedClientsRegex) { @@ -370,7 +367,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion if (!String.IsNullOrWhiteSpace(m_DeniedMacs)) { //m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs); - if (m_DeniedMacs.Contains(curMac)) + if (m_DeniedMacs.Contains(curMac, StringComparison.InvariantCultureIgnoreCase)) { reason = "Login failed: client with Mac " + curMac + " is denied"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client with mac {0} is denied", curMac); @@ -381,7 +378,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion if (!string.IsNullOrWhiteSpace(m_DeniedID0s)) { //m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs); - if (m_DeniedID0s.Contains(aCircuit.Id0)) + if (m_DeniedID0s.Contains(aCircuit.Id0, StringComparison.InvariantCultureIgnoreCase)) { reason = "Login failed: client with id0 " + aCircuit.Id0 + " is denied"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client with mac {0} is denied", aCircuit.Id0); @@ -404,14 +401,14 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // Check for impersonations // UserAccount account = null; - if (m_UserAccountService != null) + if (m_UserAccountService is not null) { // Check to see if we have a local user with that UUID account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); - if (account != null) + if (account is not null) { // Make sure this is the user coming home, and not a foreign user with same UUID as a local user - if (m_UserAgentService != null) + if (m_UserAgentService is not null) { if (!m_UserAgentService.IsAgentComingHome(aCircuit.SessionID, m_gatekeeperURL)) { @@ -429,7 +426,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // // Foreign agents allowed? Exceptions? // - if (account == null) + if (account is null) { bool allowed = m_ForeignAgentsAllowed; @@ -452,8 +449,8 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // Is the user banned? // This uses a Ban service that's more powerful than the configs // - string uui = (account != null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit)); - if (m_BansService != null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL)) + string uui = (account is not null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit)); + if (m_BansService is not null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL)) { reason = "You are banned from this world"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: user {0} is banned", uui); @@ -461,32 +458,33 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion } UUID agentID = aCircuit.AgentID; - if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e")) + if(agentID.Equals(Constants.servicesGodAgentID)) { // really? reason = "Invalid account ID"; return false; } - if(m_GridUserService != null) + if(m_GridUserService is not null) { - string PrincipalIDstr = agentID.ToString(); - GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr); - - if(!m_allowDuplicatePresences) + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(uui); + if (guinfo is not null) { - if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero) + if (!m_allowDuplicatePresences) { - if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo)) + if (guinfo.Online && !guinfo.LastRegionID.IsZero()) { - if(account != null) - m_log.InfoFormat( - "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in", - account.FirstName, account.LastName); - reason = "You appear to be already logged in on the destination grid " + - "Please wait a a minute or two and retry. " + - "If this takes longer than a few minutes please contact the grid owner."; - return false; + if (SendAgentGodKillToRegion(UUID.Zero, agentID, uui, guinfo)) + { + if (account is not null) + m_log.InfoFormat( + "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in", + account.FirstName, account.LastName); + reason = "You appear to be already logged in on the destination grid " + + "Please wait a a minute or two and retry. " + + "If this takes longer than a few minutes please contact the grid owner."; + return false; + } } } } @@ -499,7 +497,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // Login the presence, if it's not there yet (by the login service) // PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID); - if (presence != null) // it has been placed there by the login service + if (presence is not null) // it has been placed there by the login service isFirstLogin = true; else @@ -518,7 +516,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // Get the region // destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID); - if (destination == null) + if (destination is null) { reason = "Destination region not found"; return false; @@ -530,18 +528,18 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion // // Adjust the visible name // - if (account != null) + if (account is not null) { aCircuit.firstname = account.FirstName; aCircuit.lastname = account.LastName; } - if (account == null) + if (account is null) { if (!aCircuit.lastname.StartsWith("@")) aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; try { - Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); + Uri uri = new(aCircuit.ServiceURLs["HomeURI"].ToString()); aCircuit.lastname = "@" + uri.Authority; } catch @@ -561,7 +559,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0}, Teleport Flags: {1}", aCircuit.Name, loginFlag); - EntityTransferContext ctx = new EntityTransferContext(); + EntityTransferContext ctx = new(); if (!m_SimulationService.QueryAccess( destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), @@ -574,7 +572,7 @@ public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion { m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name); - if(!isFirstLogin && m_GridUserService != null && account == null) + if(!isFirstLogin && m_GridUserService is not null && account is null) { // Also login foreigners with GridUser service string userId = aCircuit.AgentID.ToString(); @@ -612,7 +610,7 @@ protected bool Authenticate(AgentCircuitData aCircuit) if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); - OSHHTPHost userHomeHost = new OSHHTPHost(userURL, true); + OSHHTPHost userHomeHost = new(userURL, true); if(!userHomeHost.IsResolvedHost) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); @@ -647,7 +645,7 @@ protected bool CheckAddress(string serviceToken) if (parts.Length < 2) return false; - OSHHTPHost reqGrid = new OSHHTPHost(parts[0], false); + OSHHTPHost reqGrid = new(parts[0], false); if(!reqGrid.IsValidHost) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Visitor provided malformed gird address {0}", parts[0]); @@ -680,20 +678,20 @@ private bool IsException(AgentCircuitData aCircuit, List exceptions) if (!userURL.EndsWith("/")) userURL += "/"; - foreach(string s in exceptions) + foreach (string s in exceptions) { - if(userURL.Equals(s)) + if (userURL.Equals(s)) return true; } } return false; } - private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo) + private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID, string uui, GridUserInfo guinfo) { UUID regionID = guinfo.LastRegionID; GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); - if(regInfo == null) + if(regInfo is null) return false; string regURL = regInfo.ServerURI; @@ -716,7 +714,7 @@ private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo msg.binaryBucket = new byte[1] {0}; InstantMessageServiceConnector.SendInstantMessage(regURL,msg, m_messageKey); - m_GridUserService.LoggedOut(agentID.ToString(), + m_GridUserService.LoggedOut(uui, UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); return true; diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs index 6e2a926fc11..06440586e85 100644 --- a/OpenSim/Services/HypergridService/HGFriendsService.cs +++ b/OpenSim/Services/HypergridService/HGFriendsService.cs @@ -233,16 +233,15 @@ public List StatusNotification(List friends, UUID foreignUserID, b // First, let's double check that the reported friends are, indeed, friends of that user // And let's check that the secret matches List usersToBeNotified = new List(); + string foreignUserIDToString = foreignUserID.ToString(); foreach (string uui in friends) { - UUID localUserID; - string secret = string.Empty, tmp = string.Empty; - if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret)) + if (Util.ParseUniversalUserIdentifier(uui, out UUID localUserID, out _, out _, out _, out string secret)) { FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); foreach (FriendInfo finfo in friendInfos) { - if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret)) + if (finfo.Friend.StartsWith(foreignUserIDToString) && finfo.Friend.EndsWith(secret)) { // great! usersToBeNotified.Add(localUserID.ToString()); diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index b65f31fc115..b043174e698 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -144,8 +144,8 @@ public HGInstantMessageService(IConfigSource config, IInstantMessageSimConnector public bool IncomingInstantMessage(GridInstantMessage im) { -// m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); -// UUID toAgentID = new UUID(im.toAgentID); + //m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); + //UUID toAgentID = new UUID(im.toAgentID); bool success = false; if (m_IMSimConnector != null) @@ -166,7 +166,7 @@ public bool IncomingInstantMessage(GridInstantMessage im) public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) { -// m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url); + //m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url); return TrySendInstantMessage(im, url, true, foreigner); } diff --git a/OpenSim/Services/HypergridService/OpenSim.Services.HypergridService.csproj b/OpenSim/Services/HypergridService/OpenSim.Services.HypergridService.csproj index 46376580c80..7c3767dd983 100644 --- a/OpenSim/Services/HypergridService/OpenSim.Services.HypergridService.csproj +++ b/OpenSim/Services/HypergridService/OpenSim.Services.HypergridService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.HypergridService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index f0f30182b83..e66ce3e6c31 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -53,9 +53,7 @@ namespace OpenSim.Services.HypergridService /// public class UserAgentService : UserAgentServiceBase, IUserAgentService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // This will need to go into a DB table //static Dictionary m_Database = new Dictionary(); @@ -80,9 +78,9 @@ public class UserAgentService : UserAgentServiceBase, IUserAgentService protected static bool m_BypassClientVerification; - private static Dictionary m_ForeignTripsAllowed = new Dictionary(); - private static Dictionary> m_TripsAllowedExceptions = new Dictionary>(); - private static Dictionary> m_TripsDisallowedExceptions = new Dictionary>(); + private static readonly Dictionary m_ForeignTripsAllowed = new(); + private static readonly Dictionary> m_TripsAllowedExceptions = new(); + private static readonly Dictionary> m_TripsDisallowedExceptions = new(); public UserAgentService(IConfigSource config) : this(config, null) { @@ -93,7 +91,7 @@ public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnec { // Let's set this always, because we don't know the sequence // of instantiations - if (friendsConnector != null) + if (friendsConnector is not null) m_FriendsLocalSimConnector = friendsConnector; if (!m_Initialized) @@ -105,7 +103,7 @@ public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnec m_FriendsSimConnector = new FriendsSimConnector(); IConfig serverConfig = config.Configs["UserAgentService"]; - if (serverConfig == null) + if (serverConfig is null) throw new Exception(String.Format("No section UserAgentService in config file")); string gridService = serverConfig.GetString("GridService", String.Empty); @@ -152,13 +150,12 @@ public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnec { m_GridName = m_GridName.ToLowerInvariant(); if (!m_GridName.EndsWith("/")) - m_GridName = m_GridName + "/"; - Uri gateURI; - if(!Uri.TryCreate(m_GridName, UriKind.Absolute, out gateURI)) + m_GridName += "/"; + if (!Uri.TryCreate(m_GridName, UriKind.Absolute, out Uri gateURI)) throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri")); string host = gateURI.DnsSafeHost; IPAddress ip = Util.GetHostFromDNS(host); - if(ip == null) + if(ip is null) throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host")); m_MyExternalIP = ip.ToString(); } @@ -174,8 +171,7 @@ protected void LoadTripPermissionsFromConfig(IConfig config, string variable) { if (keyName.StartsWith(variable + "_Level_")) { - int level = 0; - if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level)) + if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level)) m_ForeignTripsAllowed.Add(level, config.GetBoolean(keyName, true)); } } @@ -187,8 +183,7 @@ protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, D { if (keyName.StartsWith(variable + "_Level_")) { - int level = 0; - if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level) && !exceptions.ContainsKey(level)) + if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level) && !exceptions.ContainsKey(level)) { exceptions.Add(level, new List()); string value = config.GetString(keyName, string.Empty); @@ -214,18 +209,18 @@ public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 l GridRegion home = null; GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); - if (uinfo != null) + if (uinfo is not null) { - if (!uinfo.HomeRegionID.IsZero()) + if (uinfo.HomeRegionID.IsNotZero()) { home = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); position = uinfo.HomePosition; lookAt = uinfo.HomeLookAt; } - if (home == null) + if (home is null) { List defs = m_GridService.GetDefaultRegions(UUID.Zero); - if (defs != null && defs.Count > 0) + if (defs is not null && defs.Count > 0) home = defs[0]; } } @@ -241,7 +236,7 @@ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, G string gridName = gatekeeper.ServerURI.ToLowerInvariant(); UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID); - if (account == null) + if (account is null) { m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname); reason = "Forbidden to launch your agents from here"; @@ -271,27 +266,28 @@ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, G } // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination - GridRegion region = new GridRegion(gatekeeper); - region.ServerURI = gatekeeper.ServerURI; - region.ExternalHostName = finalDestination.ExternalHostName; - region.InternalEndPoint = finalDestination.InternalEndPoint; - region.RegionName = finalDestination.RegionName; - region.RegionID = finalDestination.RegionID; - region.RegionLocX = finalDestination.RegionLocX; - region.RegionLocY = finalDestination.RegionLocY; + GridRegion region = new(gatekeeper) + { + ServerURI = gatekeeper.ServerURI, + ExternalHostName = finalDestination.ExternalHostName, + InternalEndPoint = finalDestination.InternalEndPoint, + RegionName = finalDestination.RegionName, + RegionID = finalDestination.RegionID, + RegionLocX = finalDestination.RegionLocX, + RegionLocY = finalDestination.RegionLocY + }; // Generate a new service session agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); - TravelingAgentInfo old = null; - TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old); + TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out TravelingAgentInfo old); - if(!fromLogin && old != null && !string.IsNullOrEmpty(old.ClientIPAddress)) + if(!fromLogin && old is not null && !string.IsNullOrEmpty(old.ClientIPAddress)) { m_log.DebugFormat("[USER AGENT SERVICE]: stored IP = {0}. Old circuit IP: {1}", old.ClientIPAddress, agentCircuit.IPAddress); agentCircuit.IPAddress = old.ClientIPAddress; } - bool success = false; + bool success; m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID); @@ -302,7 +298,7 @@ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, G else { //TODO: Should there not be a call to QueryAccess here? - EntityTransferContext ctx = new EntityTransferContext(); + EntityTransferContext ctx = new(); success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out reason); } @@ -311,7 +307,7 @@ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, G m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); - if (old != null) + if (old is not null) StoreTravelInfo(old); else m_Database.Delete(agentCircuit.SessionID); @@ -328,7 +324,6 @@ public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, G public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) { - reason = string.Empty; return LoginAgentToGrid(source, agentCircuit, gatekeeper, finalDestination, false, out reason); } @@ -337,7 +332,7 @@ TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion re HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID); existing = null; - if (hgt != null) + if (hgt is not null) { // Very important! Override whatever this agent comes with. // UserAgentService always sets the IP for every new agent @@ -346,11 +341,13 @@ TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion re agentCircuit.IPAddress = existing.ClientIPAddress; } - TravelingAgentInfo travel = new TravelingAgentInfo(existing); - travel.SessionID = agentCircuit.SessionID; - travel.UserID = agentCircuit.AgentID; - travel.GridExternalName = region.ServerURI; - travel.ServiceToken = agentCircuit.ServiceSessionID; + TravelingAgentInfo travel = new(existing) + { + SessionID = agentCircuit.SessionID, + UserID = agentCircuit.AgentID, + GridExternalName = region.ServerURI, + ServiceToken = agentCircuit.ServiceSessionID + }; if (fromLogin) travel.ClientIPAddress = agentCircuit.IPAddress; @@ -367,7 +364,7 @@ public void LogoutAgent(UUID userID, UUID sessionID) m_Database.Delete(sessionID); GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); - if (guinfo != null) + if (guinfo is not null) m_GridUserService.LoggedOut(userID.ToString(), sessionID, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); } @@ -375,12 +372,11 @@ public void LogoutAgent(UUID userID, UUID sessionID) public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) { HGTravelingData hgt = m_Database.Get(sessionID); - if (hgt == null) + if (hgt is null || hgt.Data is null) return false; - - TravelingAgentInfo travel = new TravelingAgentInfo(hgt); - - return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower(); + if(!hgt.Data.TryGetValue("GridExternalName", out string htgGrid)) + return false; + return htgGrid.Equals(thisGridExternalName, StringComparison.InvariantCultureIgnoreCase); } public bool VerifyClient(UUID sessionID, string reportedIP) @@ -392,10 +388,10 @@ public bool VerifyClient(UUID sessionID, string reportedIP) sessionID, reportedIP); HGTravelingData hgt = m_Database.Get(sessionID); - if (hgt == null) + if (hgt is null) return false; - TravelingAgentInfo travel = new TravelingAgentInfo(hgt); + TravelingAgentInfo travel = new(hgt); bool result = travel.ClientIPAddress == reportedIP; if(!result && !string.IsNullOrEmpty(m_MyExternalIP)) @@ -410,7 +406,7 @@ public bool VerifyClient(UUID sessionID, string reportedIP) public bool VerifyAgent(UUID sessionID, string token) { HGTravelingData hgt = m_Database.Get(sessionID); - if (hgt == null) + if (hgt is null) { m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID); return false; @@ -430,18 +426,16 @@ public List StatusNotification(List friends, UUID foreignUserID, b return new List(); } - List localFriendsOnline = new List(); + List localFriendsOnline = new(); m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count); // First, let's double check that the reported friends are, indeed, friends of that user // And let's check that the secret matches - List usersToBeNotified = new List(); + List usersToBeNotified = new(); foreach (string uui in friends) { - UUID localUserID; - string secret = string.Empty, tmp = string.Empty; - if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret)) + if (Util.ParseUniversalUserIdentifier(uui, out UUID localUserID, out _, out _, out _, out string secret)) { FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); foreach (FriendInfo finfo in friendInfos) @@ -464,18 +458,18 @@ public List StatusNotification(List friends, UUID foreignUserID, b { PresenceInfo friendSession = null; foreach (PresenceInfo pinfo in friendSessions) - if (!pinfo.RegionID.IsZero()) // let's guard against traveling agents + { + if (pinfo.RegionID.IsNotZero()) // let's guard against traveling agents { friendSession = pinfo; break; } - - if (friendSession != null) + } + if (friendSession is not null) { ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online); usersToBeNotified.Remove(friendSession.UserID.ToString()); - UUID id; - if (UUID.TryParse(friendSession.UserID, out id)) + if (UUID.TryParse(friendSession.UserID, out UUID id)) localFriendsOnline.Add(id); } @@ -505,10 +499,9 @@ public List StatusNotification(List friends, UUID foreignUserID, b [Obsolete] protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online) { - UUID userID; - if (UUID.TryParse(user, out userID)) + if (UUID.TryParse(user, out UUID userID)) { - if (m_FriendsLocalSimConnector != null) + if (m_FriendsLocalSimConnector is not null) { m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline")); m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online); @@ -516,7 +509,7 @@ protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, else { GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID); - if (region != null) + if (region is not null) { m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online); @@ -527,9 +520,9 @@ protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, public List GetOnlineFriends(UUID foreignUserID, List friends) { - List online = new List(); + List online = new(); - if (m_FriendsService == null || m_PresenceService == null) + if (m_FriendsService is null || m_PresenceService is null) { m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing"); return online; @@ -539,12 +532,10 @@ public List GetOnlineFriends(UUID foreignUserID, List friends) // First, let's double check that the reported friends are, indeed, friends of that user // And let's check that the secret matches and the rights - List usersToBeNotified = new List(); + List usersToBeNotified = new(); foreach (string uui in friends) { - UUID localUserID; - string secret = string.Empty, tmp = string.Empty; - if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret)) + if (Util.ParseUniversalUserIdentifier(uui, out UUID localUserID, out _, out _, out _, out string secret)) { FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); foreach (FriendInfo finfo in friendInfos) @@ -564,12 +555,11 @@ public List GetOnlineFriends(UUID foreignUserID, List friends) // First, let's send notifications to local users who are online in the home grid PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray()); - if (friendSessions != null && friendSessions.Length > 0) + if (friendSessions is not null && friendSessions.Length > 0) { foreach (PresenceInfo pi in friendSessions) { - UUID presenceID; - if (UUID.TryParse(pi.UserID, out presenceID)) + if (UUID.TryParse(pi.UserID, out UUID presenceID)) online.Add(presenceID); } } @@ -579,9 +569,9 @@ public List GetOnlineFriends(UUID foreignUserID, List friends) public Dictionary GetUserInfo(UUID userID) { - Dictionary info = new Dictionary(); + Dictionary info = new(); - if (m_UserAccountService == null) + if (m_UserAccountService is null) { m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get user flags because user account service is missing"); info["result"] = "fail"; @@ -616,7 +606,7 @@ public Dictionary GetUserInfo(UUID userID) public Dictionary GetServerURLs(UUID userID) { - if (m_UserAccountService == null) + if (m_UserAccountService is null) { m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing"); return new Dictionary(); @@ -645,21 +635,21 @@ public string GetUUI(UUID userID, UUID targetUserID) { // Let's see if it's a local user UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, targetUserID); - if (account != null) + if (account is not null) return targetUserID.ToString() + ";" + m_GridName + ";" + account.FirstName + " " + account.LastName ; // Let's try the list of friends - if(m_FriendsService != null) + if(m_FriendsService is not null) { FriendInfo[] friends = m_FriendsService.GetFriends(userID); - if (friends != null && friends.Length > 0) + if (friends is not null && friends.Length > 0) { foreach (FriendInfo f in friends) if (f.Friend.StartsWith(targetUserID.ToString())) { // Let's remove the secret - UUID id; string tmp = string.Empty, secret = string.Empty; - if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret)) + if (Util.ParseUniversalUserIdentifier(f.Friend, out _, + out _, out _, out _, out string secret)) return f.Friend.Replace(secret, "0"); } } @@ -671,7 +661,7 @@ public UUID GetUUID(String first, String last) { // Let's see if it's a local user UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last); - if (account != null) + if (account is not null) { // check user level if (account.UserLevel < m_LevelOutsideContacts) @@ -696,7 +686,7 @@ private bool IsException(string dest, int level, Dictionary> e if (!destination.EndsWith("/")) destination += "/"; - foreach(string s in excep) + foreach (string s in excep) { if (destination.Equals(s)) return true; @@ -707,16 +697,20 @@ private bool IsException(string dest, int level, Dictionary> e private void StoreTravelInfo(TravelingAgentInfo travel) { - if (travel == null) + if (travel is null) return; - HGTravelingData hgt = new HGTravelingData(); - hgt.SessionID = travel.SessionID; - hgt.UserID = travel.UserID; - hgt.Data = new Dictionary(); - hgt.Data["GridExternalName"] = travel.GridExternalName; - hgt.Data["ServiceToken"] = travel.ServiceToken; - hgt.Data["ClientIPAddress"] = travel.ClientIPAddress; + HGTravelingData hgt = new() + { + SessionID = travel.SessionID, + UserID = travel.UserID, + Data = new Dictionary + { + ["GridExternalName"] = travel.GridExternalName, + ["ServiceToken"] = travel.ServiceToken, + ["ClientIPAddress"] = travel.ClientIPAddress + } + }; m_Database.Store(hgt); } @@ -734,7 +728,7 @@ class TravelingAgentInfo public TravelingAgentInfo(HGTravelingData t) { - if (t.Data != null) + if (t.Data is not null) { SessionID = new UUID(t.SessionID); UserID = new UUID(t.UserID); @@ -746,7 +740,7 @@ public TravelingAgentInfo(HGTravelingData t) public TravelingAgentInfo(TravelingAgentInfo old) { - if (old != null) + if (old is not null) { SessionID = old.SessionID; UserID = old.UserID; diff --git a/OpenSim/Services/HypergridService/UserAgentServiceBase.cs b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs index d146b684374..be9cfaa8918 100644 --- a/OpenSim/Services/HypergridService/UserAgentServiceBase.cs +++ b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs @@ -26,11 +26,8 @@ */ using System; -using System.Reflection; using Nini.Config; -using OpenSim.Framework; using OpenSim.Data; -using OpenSim.Services.Interfaces; using OpenSim.Services.Base; namespace OpenSim.Services.HypergridService @@ -50,7 +47,7 @@ public UserAgentServiceBase(IConfigSource config) // Try reading the [DatabaseService] section, if it exists // IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) + if (dbConfig is not null) { if (dllName.Length == 0) dllName = dbConfig.GetString("StorageProvider", String.Empty); @@ -62,7 +59,7 @@ public UserAgentServiceBase(IConfigSource config) // [UserAgentService] section overrides [DatabaseService], if it exists // IConfig gridConfig = config.Configs["UserAgentService"]; - if (gridConfig != null) + if (gridConfig is not null) { dllName = gridConfig.GetString("StorageProvider", dllName); connString = gridConfig.GetString("ConnectionString", connString); @@ -76,7 +73,7 @@ public UserAgentServiceBase(IConfigSource config) throw new Exception("No StorageProvider configured"); m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); - if (m_Database == null) + if (m_Database is null) throw new Exception("Could not find a storage interface in the given module"); } diff --git a/OpenSim/Services/Interfaces/IFriendsService.cs b/OpenSim/Services/Interfaces/IFriendsService.cs index d0d3b1002d5..38cc7456c60 100644 --- a/OpenSim/Services/Interfaces/IFriendsService.cs +++ b/OpenSim/Services/Interfaces/IFriendsService.cs @@ -54,26 +54,29 @@ public FriendInfo() public FriendInfo(Dictionary kvp) { PrincipalID = UUID.Zero; - if (kvp.ContainsKey("PrincipalID") && kvp["PrincipalID"] != null) - UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID); + object tmpo; + if (kvp.TryGetValue("PrincipalID", out tmpo) && tmpo is not null) + UUID.TryParse(tmpo.ToString(), out PrincipalID); Friend = string.Empty; - if (kvp.ContainsKey("Friend") && kvp["Friend"] != null) - Friend = kvp["Friend"].ToString(); + if (kvp.TryGetValue("Friend", out tmpo) && tmpo is not null) + Friend = tmpo.ToString(); MyFlags = (int)FriendRights.None; - if (kvp.ContainsKey("MyFlags") && kvp["MyFlags"] != null) - Int32.TryParse(kvp["MyFlags"].ToString(), out MyFlags); + if (kvp.TryGetValue("MyFlags", out tmpo) && tmpo is not null) + Int32.TryParse(tmpo.ToString(), out MyFlags); TheirFlags = 0; - if (kvp.ContainsKey("TheirFlags") && kvp["TheirFlags"] != null) - Int32.TryParse(kvp["TheirFlags"].ToString(), out TheirFlags); + if (kvp.TryGetValue("TheirFlags", out tmpo) && tmpo is not null) + Int32.TryParse(tmpo.ToString(), out TheirFlags); } public Dictionary ToKeyValuePairs() { - Dictionary result = new Dictionary(); - result["PrincipalID"] = PrincipalID.ToString(); - result["Friend"] = Friend; - result["MyFlags"] = MyFlags.ToString(); - result["TheirFlags"] = TheirFlags.ToString(); + Dictionary result = new() + { + ["PrincipalID"] = PrincipalID.ToString(), + ["Friend"] = Friend, + ["MyFlags"] = MyFlags.ToString(), + ["TheirFlags"] = TheirFlags.ToString() + }; return result; } diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 89828102018..a6bfbc88a93 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -85,6 +85,9 @@ public interface IGridService GridRegion GetRegionByName(UUID scopeID, string regionName); GridRegion GetRegionByURI(UUID scopeID, RegionURI uri); + GridRegion GetLocalRegionByName(UUID scopeID, string regionName); + GridRegion GetLocalRegionByURI(UUID scopeID, RegionURI uri); + /// /// Get information about regions starting with the provided name. /// diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index e0a63cabe14..bb0b165da4e 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -36,7 +36,7 @@ namespace OpenSim.Services.Interfaces { public interface IGatekeeperService { - bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY); + bool LinkLocalRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY); /// /// Returns the region a Hypergrid visitor should enter. diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs index db501fd7f5e..b7d76829169 100644 --- a/OpenSim/Services/Interfaces/IOfflineIMService.cs +++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs @@ -50,49 +50,50 @@ public class OfflineIMDataUtils public static GridInstantMessage GridInstantMessage(Dictionary dict) { GridInstantMessage im = new GridInstantMessage(); + object otmp; - if (dict.ContainsKey("BinaryBucket") && dict["BinaryBucket"] != null) - im.binaryBucket = OpenMetaverse.Utils.HexStringToBytes(dict["BinaryBucket"].ToString(), true); + if (dict.TryGetValue("BinaryBucket", out otmp) && otmp is string bbs) + im.binaryBucket = OpenMetaverse.Utils.HexStringToBytes(bbs, true); - if (dict.ContainsKey("Dialog") && dict["Dialog"] != null) - im.dialog = byte.Parse(dict["Dialog"].ToString()); + if (dict.TryGetValue("Dialog", out otmp) && otmp is string ds) + im.dialog = byte.Parse(ds); - if (dict.ContainsKey("FromAgentID") && dict["FromAgentID"] != null) - im.fromAgentID = new Guid(dict["FromAgentID"].ToString()); + if (dict.TryGetValue("FromAgentID", out otmp) && otmp is string faid) + im.fromAgentID = new Guid(faid); - if (dict.ContainsKey("FromAgentName") && dict["FromAgentName"] != null) - im.fromAgentName = dict["FromAgentName"].ToString(); + if (dict.TryGetValue("FromAgentName", out otmp) && otmp is string fan) + im.fromAgentName = fan; else im.fromAgentName = string.Empty; - if (dict.ContainsKey("FromGroup") && dict["FromGroup"] != null) - im.fromGroup = bool.Parse(dict["FromGroup"].ToString()); + if (dict.TryGetValue("FromGroup", out otmp) && otmp is string fg) + im.fromGroup = bool.Parse(fg); - if (dict.ContainsKey("SessionID") && dict["SessionID"] != null) - im.imSessionID = new Guid(dict["SessionID"].ToString()); + if (dict.TryGetValue("SessionID", out otmp) && otmp is string sid) + im.imSessionID = new Guid(sid); - if (dict.ContainsKey("Message") && dict["Message"] != null) - im.message = dict["Message"].ToString(); + if (dict.TryGetValue("Message", out otmp) && otmp is string msg) + im.message = msg; else im.message = string.Empty; - if (dict.ContainsKey("Offline") && dict["Offline"] != null) - im.offline = byte.Parse(dict["Offline"].ToString()); + if (dict.TryGetValue("Offline", out otmp) && otmp is string off) + im.offline = byte.Parse(off); - if (dict.ContainsKey("EstateID") && dict["EstateID"] != null) - im.ParentEstateID = UInt32.Parse(dict["EstateID"].ToString()); + if (dict.TryGetValue("EstateID", out otmp) && otmp is string eid) + im.ParentEstateID = UInt32.Parse(eid); - if (dict.ContainsKey("Position") && dict["Position"] != null) - im.Position = Vector3.Parse(dict["Position"].ToString()); + if (dict.TryGetValue("Position", out otmp) && otmp is string vpos) + im.Position = Vector3.Parse(vpos); - if (dict.ContainsKey("RegionID") && dict["RegionID"] != null) - im.RegionID = new Guid(dict["RegionID"].ToString()); + if (dict.TryGetValue("RegionID", out otmp) && otmp is string rid) + im.RegionID = new Guid(rid); - if (dict.ContainsKey("Timestamp") && dict["Timestamp"] != null) - im.timestamp = UInt32.Parse(dict["Timestamp"].ToString()); + if (dict.TryGetValue("Timestamp", out otmp) && otmp is string ts) + im.timestamp = UInt32.Parse(ts); - if (dict.ContainsKey("ToAgentID") && dict["ToAgentID"] != null) - im.toAgentID = new Guid(dict["ToAgentID"].ToString()); + if (dict.TryGetValue("ToAgentID", out otmp) && otmp is string tid) + im.toAgentID = new Guid(tid); return im; } diff --git a/OpenSim/Services/Interfaces/OpenSim.Services.Interfaces.csproj b/OpenSim/Services/Interfaces/OpenSim.Services.Interfaces.csproj index fb114a2390f..28f3e18d7a9 100644 --- a/OpenSim/Services/Interfaces/OpenSim.Services.Interfaces.csproj +++ b/OpenSim/Services/Interfaces/OpenSim.Services.Interfaces.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.Interfaces http://opensimulator.org OpenSim diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs index f2ddce59560..cb1c3d6cc96 100644 --- a/OpenSim/Services/InventoryService/LibraryService.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs @@ -213,7 +213,7 @@ private void ReadItemFromConfig(IConfig config, string path) item.NextPermissions = (uint)config.GetLong("nextPermissions", m_NextPermissions); item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", m_EveryOnePermissions); item.BasePermissions = (uint)config.GetLong("basePermissions", m_BasePermissions); - item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);; + item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions); item.Flags = (uint)config.GetInt("flags", 0); if (libraryFolders.TryGetValue(item.Folder, out InventoryFolderImpl parentFolder)) @@ -306,8 +306,8 @@ public InventoryItemBase GetItem(UUID itemID) public InventoryItemBase[] GetMultipleItems(UUID[] ids) { - List items = new List(); - foreach (UUID id in ids) + List items = new(ids.Length); + foreach (UUID id in ids.AsSpan()) { if (m_items.TryGetValue(id, out InventoryItemBase it)) items.Add(it); diff --git a/OpenSim/Services/InventoryService/OpenSim.Services.InventoryService.csproj b/OpenSim/Services/InventoryService/OpenSim.Services.InventoryService.csproj index b042679505b..abbe763751c 100644 --- a/OpenSim/Services/InventoryService/OpenSim.Services.InventoryService.csproj +++ b/OpenSim/Services/InventoryService/OpenSim.Services.InventoryService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.InventoryService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/InventoryService/Tests/OpenSim.Services.InventoryService.Tests.csproj b/OpenSim/Services/InventoryService/Tests/OpenSim.Services.InventoryService.Tests.csproj deleted file mode 100644 index e9d7e2f6e40..00000000000 --- a/OpenSim/Services/InventoryService/Tests/OpenSim.Services.InventoryService.Tests.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - net48 - - - - - - - - ..\..\..\..\bin\Nini.dll - False - - - ..\..\..\..\bin\nunit.framework.dll - False - - - ..\..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\..\bin\OpenMetaverseTypes.dll - False - - - False - - - False - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs deleted file mode 100644 index cf23f6147d4..00000000000 --- a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; - -namespace OpenSim.Services.InventoryService.Tests -{ - /// - /// Tests for the XInventoryService - /// - /// - /// TODO: Fill out more tests. - /// - [TestFixture] - public class XInventoryServiceTests : OpenSimTestCase - { - private IInventoryService CreateXInventoryService() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("InventoryService"); - config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - return ServerUtils.LoadPlugin( - "OpenSim.Services.InventoryService.dll:XInventoryService", new Object[] { config }); - } - - /// - /// Tests add item operation. - /// - /// - /// TODO: Test all operations. - /// - [Test] - public void TestAddItem() - { - TestHelpers.InMethod(); - - string creatorId = TestHelpers.ParseTail(0x1).ToString(); - UUID ownerId = TestHelpers.ParseTail(0x2); - UUID itemId = TestHelpers.ParseTail(0x10); - UUID assetId = TestHelpers.ParseTail(0x20); - UUID folderId = TestHelpers.ParseTail(0x30); - int invType = (int)InventoryType.Animation; - int assetType = (int)AssetType.Animation; - string itemName = "item1"; - - IInventoryService xis = CreateXInventoryService(); - - InventoryItemBase itemToStore - = new InventoryItemBase(itemId, ownerId) - { - CreatorIdentification = creatorId.ToString(), - AssetID = assetId, - Name = itemName, - Folder = folderId, - InvType = invType, - AssetType = assetType - }; - - Assert.That(xis.AddItem(itemToStore), Is.True); - - InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); - - Assert.That(itemRetrieved, Is.Not.Null); - Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); - Assert.That(itemRetrieved.Owner, Is.EqualTo(ownerId)); - Assert.That(itemRetrieved.AssetID, Is.EqualTo(assetId)); - Assert.That(itemRetrieved.Folder, Is.EqualTo(folderId)); - Assert.That(itemRetrieved.InvType, Is.EqualTo(invType)); - Assert.That(itemRetrieved.AssetType, Is.EqualTo(assetType)); - Assert.That(itemRetrieved.Name, Is.EqualTo(itemName)); - } - - [Test] - public void TestUpdateItem() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - string creatorId = TestHelpers.ParseTail(0x1).ToString(); - UUID ownerId = TestHelpers.ParseTail(0x2); - UUID itemId = TestHelpers.ParseTail(0x10); - UUID assetId = TestHelpers.ParseTail(0x20); - UUID folderId = TestHelpers.ParseTail(0x30); - int invType = (int)InventoryType.Animation; - int assetType = (int)AssetType.Animation; - string itemName = "item1"; - string itemName2 = "item2"; - - IInventoryService xis = CreateXInventoryService(); - - InventoryItemBase itemToStore - = new InventoryItemBase(itemId, ownerId) - { - CreatorIdentification = creatorId.ToString(), - AssetID = assetId, - Name = itemName, - Folder = folderId, - InvType = invType, - AssetType = assetType - }; - - Assert.That(xis.AddItem(itemToStore), Is.True); - - // Normal update - itemToStore.Name = itemName2; - - Assert.That(xis.UpdateItem(itemToStore), Is.True); - - InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); - - Assert.That(itemRetrieved, Is.Not.Null); - Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); - - // Attempt to update properties that should never change - string creatorId2 = TestHelpers.ParseTail(0x7).ToString(); - UUID ownerId2 = TestHelpers.ParseTail(0x8); - UUID folderId2 = TestHelpers.ParseTail(0x70); - int invType2 = (int)InventoryType.CallingCard; - int assetType2 = (int)AssetType.CallingCard; - string itemName3 = "item3"; - - itemToStore.CreatorIdentification = creatorId2.ToString(); - //itemToStore.Owner = ownerId2; this cant be done - itemToStore.Folder = folderId2; - itemToStore.InvType = invType2; - itemToStore.AssetType = assetType2; - itemToStore.Name = itemName3; - - Assert.That(xis.UpdateItem(itemToStore), Is.True); - - itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID); - - Assert.That(itemRetrieved, Is.Not.Null); - Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); - Assert.That(itemRetrieved.Owner, Is.EqualTo(ownerId)); - Assert.That(itemRetrieved.AssetID, Is.EqualTo(assetId)); - Assert.That(itemRetrieved.Folder, Is.EqualTo(folderId)); - Assert.That(itemRetrieved.InvType, Is.EqualTo(invType)); - Assert.That(itemRetrieved.AssetType, Is.EqualTo(assetType)); - Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); - } - } -} diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 8547e3fd42a..5100e728465 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -40,9 +40,7 @@ namespace OpenSim.Services.InventoryService { public class XInventoryService : ServiceBase, IInventoryService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IXInventoryData m_Database; protected bool m_AllowDelete = true; @@ -161,14 +159,15 @@ public virtual bool CreateUserInventory(UUID principalID) protected XInventoryFolder CreateFolder(UUID principalID, UUID parentID, int type, string name) { - XInventoryFolder newFolder = new XInventoryFolder(); - - newFolder.folderName = name; - newFolder.type = type; - newFolder.version = 1; - newFolder.folderID = UUID.Random(); - newFolder.agentID = principalID; - newFolder.parentFolderID = parentID; + var newFolder = new XInventoryFolder + { + folderName = name, + type = type, + version = 1, + folderID = UUID.Random(), + agentID = principalID, + parentFolderID = parentID + }; m_Database.StoreFolder(newFolder); @@ -207,7 +206,7 @@ public virtual List GetInventorySkeleton(UUID principalID) if (allFolders.Length == 0) return null; - List folders = new List(); + List folders = new(); foreach (XInventoryFolder x in allFolders) { @@ -237,8 +236,7 @@ public virtual InventoryFolderBase GetRootFolder(UUID principalID) } } - if (root == null) // oops - root = folders[0]; + root ??= folders[0]; //oops return ConvertToOpenSim(root); } @@ -292,14 +290,12 @@ public virtual InventoryCollection GetFolderContent(UUID principalID, UUID folde // by ID. // //m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString()); - InventoryCollection inventory = new InventoryCollection(); - inventory.OwnerID = principalID; - inventory.Folders = new List(); - inventory.Items = new List(); - - InventoryFolderBase f = GetFolder(principalID, folderID); - if (f == null) - return inventory; + InventoryCollection inventory = new() + { + OwnerID = principalID, + Folders = new List(), + Items = new List() + }; XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "parentFolderID"}, @@ -321,8 +317,12 @@ public virtual InventoryCollection GetFolderContent(UUID principalID, UUID folde inventory.Items.Add(ConvertToOpenSim(i)); } - inventory.Version = f.Version; - inventory.OwnerID = f.Owner; + InventoryFolderBase f = GetFolder(principalID, folderID); + if (f != null) + { + inventory.Version = f.Version; + inventory.OwnerID = f.Owner; + } inventory.FolderID = folderID; return inventory; @@ -344,7 +344,7 @@ public virtual List GetFolderItems(UUID principalID, UUID fol // Since we probably don't get a valid principal here, either ... // - List invItems = new List(); + List invItems = new(); XInventoryItem[] items = m_Database.GetItems( new string[] { "parentFolderID" }, @@ -460,8 +460,7 @@ public virtual bool DeleteFolders(UUID principalID, List folderIDs, bool o if (onlyIfTrash && !ParentIsTrashOrLost(id)) continue; //m_log.InfoFormat("[XINVENTORY SERVICE]: Delete folder {0}", id); - InventoryFolderBase f = new InventoryFolderBase(); - f.ID = id; + InventoryFolderBase f = new() { ID = id }; PurgeFolder(f, onlyIfTrash); m_Database.DeleteFolders("folderID", id.ToString()); } @@ -562,20 +561,12 @@ public virtual bool MoveItems(UUID principalID, List items) { // Principal is b0rked. *sigh* // - int len = items.Count; - if(len == 0) - return false; - string[] ids = new string[len]; - string[] folders = new string[len]; - int i=0; - foreach (InventoryItemBase it in items) + foreach (InventoryItemBase i in items) { - ids[i] = it.ID.ToString(); - folders[i++] = it.Folder.ToString(); - + m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString()); } - return m_Database.MoveItems(ids, folders); + return true; } public virtual bool DeleteItems(UUID principalID, List itemIDs) @@ -602,39 +593,18 @@ public virtual bool DeleteItems(UUID principalID, List itemIDs) { // Just use the ID... *facepalms* // - if(principalID.IsZero()) - { - foreach (UUID id in itemIDs) - m_Database.DeleteItems("inventoryID", id.ToString()); - } - else - { - string u = principalID.ToString(); - string[] fields = new string[] { "avatarID", "inventoryID" }; - foreach (UUID id in itemIDs) - m_Database.DeleteItems( - fields, - new string[] { u, id.ToString()}); - } + foreach (UUID id in itemIDs) + m_Database.DeleteItems("inventoryID", id.ToString()); } + return true; } public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) { - XInventoryItem[] items; - if (principalID.IsZero()) - { - items = m_Database.GetItems( + XInventoryItem[] items = m_Database.GetItems( new string[] { "inventoryID" }, new string[] { itemID.ToString() }); - } - else - { - items = m_Database.GetItems( - new string[] { "avatarID", "inventoryID" }, - new string[] { principalID.ToString(), itemID.ToString() }); - } if (items.Length == 0) return null; @@ -644,63 +614,19 @@ public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) public virtual InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] ids) { - int len = ids.Length; - if(len == 0) - return new InventoryItemBase[0]; - - string[] sids = new string[len]; - - int i; - for(i = 0; i< len; ++i) - sids[i] = ids[i].ToString(); - - XInventoryItem[] xits = m_Database.GetItems("inventoryID", sids); - sids = null; - - len = xits.Length; - InventoryItemBase[] items = new InventoryItemBase[len]; - i = 0; + InventoryItemBase[] items = new InventoryItemBase[ids.Length]; + int i = 0; + foreach (UUID id in ids) + items[i++] = GetItem(userID, id); - if(userID.IsZero()) - { - for (i = 0; i < len; ++i) - { - if (xits[i] == null) - items[i] = null; - else - items[i] = ConvertToOpenSim(xits[i]); - } - } - else - { - for (i = 0; i < len; ++i) - { - if (xits[i] == null) - items[i] = null; - else if (xits[i].avatarID.Equals(userID)) - items[i] = ConvertToOpenSim(xits[i]); - else - items[i] = null; - } - } return items; } public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { - XInventoryFolder[] folders; - if(principalID.IsZero()) - { - folders = m_Database.GetFolders( - new string[] { "folderID" }, + XInventoryFolder[] folders = m_Database.GetFolders( + new string[] { "folderID"}, new string[] { folderID.ToString() }); - } - else - { - folders = m_Database.GetFolders( - new string[] { "agentID", "folderID" }, - new string[] { principalID.ToString(), folderID.ToString() }); - } if (folders.Length == 0) return null; @@ -715,7 +641,7 @@ public virtual List GetActiveGestures(UUID principalID) if (items.Length == 0) return new List(); - List ret = new List(); + List ret = new(); foreach (XInventoryItem x in items) ret.Add(ConvertToOpenSim(x)); @@ -737,97 +663,84 @@ public bool HasInventoryForUser(UUID userID) // CM Helpers // - protected InventoryFolderBase ConvertToOpenSim(XInventoryFolder folder) + protected static InventoryFolderBase ConvertToOpenSim(XInventoryFolder folder) { - InventoryFolderBase newFolder = new InventoryFolderBase(); - - newFolder.ParentID = folder.parentFolderID; - newFolder.Type = (short)folder.type; - //// Viewer can't understand anything that's not in it's LLFolderType enum - //if (newFolder.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) - // newFolder.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; - newFolder.Version = (ushort)folder.version; - newFolder.Name = folder.folderName; - newFolder.Owner = folder.agentID; - newFolder.ID = folder.folderID; - - return newFolder; + return new InventoryFolderBase + { + ParentID = folder.parentFolderID, + Type = (short)folder.type, + Version = (ushort)folder.version, + Name = folder.folderName, + Owner = folder.agentID, + ID = folder.folderID + }; } - protected XInventoryFolder ConvertFromOpenSim(InventoryFolderBase folder) + protected static XInventoryFolder ConvertFromOpenSim(InventoryFolderBase folder) { - XInventoryFolder newFolder = new XInventoryFolder(); - - newFolder.parentFolderID = folder.ParentID; - newFolder.type = (int)folder.Type; - newFolder.version = (int)folder.Version; - newFolder.folderName = folder.Name; - newFolder.agentID = folder.Owner; - newFolder.folderID = folder.ID; - - return newFolder; + return new XInventoryFolder + { + parentFolderID = folder.ParentID, + type = (int)folder.Type, + version = (int)folder.Version, + folderName = folder.Name, + agentID = folder.Owner, + folderID = folder.ID + }; } - protected InventoryItemBase ConvertToOpenSim(XInventoryItem item) - { - InventoryItemBase newItem = new InventoryItemBase(); - - newItem.AssetID = item.assetID; - newItem.AssetType = item.assetType; - newItem.Name = item.inventoryName; - newItem.Owner = item.avatarID; - newItem.ID = item.inventoryID; - newItem.InvType = item.invType; - newItem.Folder = item.parentFolderID; - newItem.CreatorIdentification = item.creatorID; - newItem.Description = item.inventoryDescription; - newItem.NextPermissions = (uint)item.inventoryNextPermissions; - newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions; - newItem.BasePermissions = (uint)item.inventoryBasePermissions; - newItem.EveryOnePermissions = (uint)item.inventoryEveryOnePermissions; - newItem.GroupPermissions = (uint)item.inventoryGroupPermissions; - newItem.GroupID = item.groupID; - if (item.groupOwned == 0) - newItem.GroupOwned = false; - else - newItem.GroupOwned = true; - newItem.SalePrice = item.salePrice; - newItem.SaleType = (byte)item.saleType; - newItem.Flags = (uint)item.flags; - newItem.CreationDate = item.creationDate; - - return newItem; - } - - protected XInventoryItem ConvertFromOpenSim(InventoryItemBase item) - { - XInventoryItem newItem = new XInventoryItem(); - - newItem.assetID = item.AssetID; - newItem.assetType = item.AssetType; - newItem.inventoryName = item.Name; - newItem.avatarID = item.Owner; - newItem.inventoryID = item.ID; - newItem.invType = item.InvType; - newItem.parentFolderID = item.Folder; - newItem.creatorID = item.CreatorIdentification; - newItem.inventoryDescription = item.Description; - newItem.inventoryNextPermissions = (int)item.NextPermissions; - newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions; - newItem.inventoryBasePermissions = (int)item.BasePermissions; - newItem.inventoryEveryOnePermissions = (int)item.EveryOnePermissions; - newItem.inventoryGroupPermissions = (int)item.GroupPermissions; - newItem.groupID = item.GroupID; - if (item.GroupOwned) - newItem.groupOwned = 1; - else - newItem.groupOwned = 0; - newItem.salePrice = item.SalePrice; - newItem.saleType = (int)item.SaleType; - newItem.flags = (int)item.Flags; - newItem.creationDate = item.CreationDate; - - return newItem; + protected static InventoryItemBase ConvertToOpenSim(XInventoryItem item) + { + return new InventoryItemBase + { + AssetID = item.assetID, + AssetType = item.assetType, + Name = item.inventoryName, + Owner = item.avatarID, + ID = item.inventoryID, + InvType = item.invType, + Folder = item.parentFolderID, + CreatorIdentification = item.creatorID, + Description = item.inventoryDescription, + NextPermissions = (uint)item.inventoryNextPermissions, + CurrentPermissions = (uint)item.inventoryCurrentPermissions, + BasePermissions = (uint)item.inventoryBasePermissions, + EveryOnePermissions = (uint)item.inventoryEveryOnePermissions, + GroupPermissions = (uint)item.inventoryGroupPermissions, + GroupID = item.groupID, + GroupOwned = item.groupOwned != 0, + SalePrice = item.salePrice, + SaleType = (byte)item.saleType, + Flags = (uint)item.flags, + CreationDate = item.creationDate + }; + } + + protected static XInventoryItem ConvertFromOpenSim(InventoryItemBase item) + { + return new XInventoryItem + { + assetID = item.AssetID, + assetType = item.AssetType, + inventoryName = item.Name, + avatarID = item.Owner, + inventoryID = item.ID, + invType = item.InvType, + parentFolderID = item.Folder, + creatorID = item.CreatorIdentification, + inventoryDescription = item.Description, + inventoryNextPermissions = (int)item.NextPermissions, + inventoryCurrentPermissions = (int)item.CurrentPermissions, + inventoryBasePermissions = (int)item.BasePermissions, + inventoryEveryOnePermissions = (int)item.EveryOnePermissions, + inventoryGroupPermissions = (int)item.GroupPermissions, + groupID = item.GroupID, + groupOwned = item.GroupOwned ? 1 : 0, + salePrice = item.SalePrice, + saleType = (int)item.SaleType, + flags = (int)item.Flags, + creationDate = item.CreationDate + }; } private bool ParentIsTrash(UUID folderID) @@ -868,7 +781,7 @@ private bool ParentIsTrashOrLost(UUID folderID) UUID parentFolder = folder[0].parentFolderID; - while (!parentFolder.IsZero()) + while (parentFolder.IsNotZero()) { XInventoryFolder[] parent = m_Database.GetFolders(new string[] { "folderID" }, new string[] { parentFolder.ToString() }); if (parent.Length < 1) diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 78a133f306c..9cb72cbd186 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -277,7 +277,7 @@ public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserI DST = "N"; break; case "local": - DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + DST = TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; break; default: TimeZoneInfo dstTimeZone = null; @@ -300,7 +300,7 @@ public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserI { m_log.WarnFormat( "[LLOGIN RESPONSE]: No valid timezone found for DST in {0}, falling back to system time.", tzList); - DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; + DST = TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; } else { @@ -673,7 +673,7 @@ public override OSD ToOSDMap() map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); - map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; + map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 82632c2b2ce..173172ec41c 100755 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -95,13 +95,13 @@ public class LLLoginService : ILoginService protected bool m_allowLoginFallbackToAnyRegion = true; // if login requested region if not found and there are no Default or fallback regions, // try any online. This is legacy behaviour - IConfig m_LoginServerConfig; + readonly IConfig m_LoginServerConfig; // IConfig m_ClientsConfig; public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService) { m_LoginServerConfig = config.Configs["LoginService"]; - if (m_LoginServerConfig == null) + if (m_LoginServerConfig is null) throw new Exception(string.Format("No section LoginService in config file")); string accountService = m_LoginServerConfig.GetString("UserAccountService", string.Empty); @@ -169,11 +169,11 @@ public LLLoginService(IConfigSource config, ISimulationService simService, ILibr m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); IConfig groupConfig = config.Configs["Groups"]; - if (groupConfig != null) + if (groupConfig is not null) m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); IConfig presenceConfig = config.Configs["PresenceService"]; - if (presenceConfig != null) + if (presenceConfig is not null) { m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences); } @@ -183,11 +183,11 @@ public LLLoginService(IConfigSource config, ISimulationService simService, ILibr { m_MapTileURL = m_MapTileURL.Trim(); if (!m_MapTileURL.EndsWith("/")) - m_MapTileURL = m_MapTileURL + "/"; + m_MapTileURL += "/"; } IConfig messagingConfig = config.Configs["Messaging"]; - if (messagingConfig != null) + if (messagingConfig is not null) m_messageKey = messagingConfig.GetString("MessageKey", string.Empty); // These are required; the others aren't if (accountService.Length == 0 || authService.Length == 0) @@ -232,7 +232,7 @@ public LLLoginService(IConfigSource config, ISimulationService simService, ILibr // deal with the services given as argument // m_LocalSimulationService = simService; - if (libraryService != null) + if (libraryService is not null) { m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument"); m_LibraryService = libraryService; @@ -261,8 +261,10 @@ public LLLoginService(IConfigSource config) : this(config, null, null) public Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP) { - Hashtable response = new Hashtable(); - response["success"] = "false"; + Hashtable response = new() + { + ["success"] = "false" + }; if (!m_AllowRemoteSetLoginLevel) return response; @@ -270,7 +272,7 @@ public Hashtable SetLevel(string firstName, string lastName, string passwd, int try { UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); - if (account == null) + if (account is null) { m_log.InfoFormat("[LLOGIN SERVICE]: Set Level failed, user {0} {1} not found", firstName, lastName); return response; @@ -311,7 +313,7 @@ public Hashtable SetLevel(string firstName, string lastName, string passwd, int public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) { - bool success = false; + bool success; UUID session = UUID.Random(); string processedMessage; @@ -327,12 +329,12 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // Check client // string clientNameToCheck; - if(clientVersion.Contains(" ")) + if(clientVersion.Contains(' ')) clientNameToCheck = clientVersion; else clientNameToCheck = channel + " " + clientVersion; - if (m_AllowedClientsRegex != null) + if (m_AllowedClientsRegex is not null) { lock(m_AllowedClientsRegex) { @@ -348,7 +350,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str } } - if (m_DeniedClientsRegex != null) + if (m_DeniedClientsRegex is not null) { lock(m_DeniedClientsRegex) { @@ -388,7 +390,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // Get the account and check that it exists // UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName); - if (account == null) + if (account is null) { m_log.InfoFormat( "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user not found", firstName, lastName); @@ -403,7 +405,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str return LLFailedLoginResponse.LoginBlockedProblem; } - if (account.PrincipalID == Constants.servicesGodAgentID) + if (account.PrincipalID.Equals(Constants.servicesGodAgentID)) { // really? return LLFailedLoginResponse.UserProblem; @@ -432,8 +434,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str if (!passwd.StartsWith("$1$")) passwd = "$1$" + Util.Md5Hash(passwd); passwd = passwd.Remove(0, 3); //remove $1$ - UUID realID; - string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID); + string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out UUID realID); UUID secureSession = UUID.Zero; if (string.IsNullOrWhiteSpace(token) || !UUID.TryParse(token, out secureSession)) { @@ -448,7 +449,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str if(!m_allowDuplicatePresences) { - if(guinfo != null && guinfo.Online && !guinfo.LastRegionID.IsZero()) + if(guinfo is not null && guinfo.Online && !guinfo.LastRegionID.IsZero()) { if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo)) { @@ -472,15 +473,12 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str return LLFailedLoginResponse.InventoryProblem; } - if (m_HGInventoryService != null) - { - // Give the Suitcase service a chance to create the suitcase folder. - // (If we're not using the Suitcase inventory service then this won't do anything.) - m_HGInventoryService.GetRootFolder(account.PrincipalID); - } + // Give the Suitcase service a chance to create the suitcase folder. + // (If we're not using the Suitcase inventory service then this won't do anything.) + m_HGInventoryService?.GetRootFolder(account.PrincipalID); List inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); - if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) + if (m_RequireInventory && ((inventorySkel is null) || (inventorySkel is not null && inventorySkel.Count == 0))) { m_log.InfoFormat( "[LLOGIN SERVICE]: Login failed, for {0} {1}, reason: unable to retrieve user inventory", @@ -495,7 +493,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // // Login the presence // - if (m_PresenceService != null) + if (m_PresenceService is not null) { success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession); @@ -515,7 +513,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // We are only going to complain about no home if the user actually tries to login there, to avoid // spamming the console. - if (guinfo != null) + if (guinfo is not null) { if (guinfo.HomeRegionID.IsZero()) { @@ -524,12 +522,12 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location but they have none set", account.Name); } - else if (m_GridService != null) + else if (m_GridService is not null) { home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID); - if (home == null) + if (home is null) { - if (startLocation == "home") + if (startLocation.Equals("home")) m_log.WarnFormat( "[LLOGIN SERVICE]: User {0} tried to login to a 'home' start location with ID {1} but this was not found.", account.Name, guinfo.HomeRegionID); @@ -550,10 +548,8 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str string where = string.Empty; Vector3 position = Vector3.Zero; Vector3 lookAt = Vector3.Zero; - GridRegion gatekeeper = null; - TeleportFlags flags; - GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags); - if (destination == null) + GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out GridRegion gatekeeper, out where, out position, out lookAt, out TeleportFlags flags); + if (destination is null) { m_PresenceService.LogoutAgent(session); @@ -575,7 +571,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // Get the avatar // AvatarAppearance avatar = null; - if (m_AvatarService != null) + if (m_AvatarService is not null) { avatar = m_AvatarService.GetAppearance(account.PrincipalID); } @@ -584,9 +580,8 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // Instantiate/get the simulation interface and launch an agent at the destination // string reason = string.Empty; - GridRegion dest; AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, - clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest); + clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out GridRegion dest); destination = dest; if (aCircuit == null) { @@ -600,8 +595,8 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str guinfo = m_GridUserService.LoggedIn(PrincipalIDstr); // Get Friends list - FriendInfo[] friendsList = new FriendInfo[0]; - if (m_FriendsService != null) + FriendInfo[] friendsList = Array.Empty(); + if (m_FriendsService is not null) { friendsList = m_FriendsService.GetFriends(account.PrincipalID); // m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length); @@ -612,7 +607,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str // if (m_MessageUrl != string.Empty) { - using(WebClient client = new WebClient()) + using(WebClient client = new()) processedMessage = client.DownloadString(m_MessageUrl); } else @@ -621,8 +616,7 @@ public LoginResponse Login(string firstName, string lastName, string passwd, str } processedMessage = processedMessage.Replace("\\n", "\n").Replace("", firstName + " " + lastName); - LLLoginResponse response - = new LLLoginResponse( + LLLoginResponse response = new( account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone, @@ -635,12 +629,13 @@ LLLoginResponse response catch (Exception e) { m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace); - if (m_PresenceService != null) - m_PresenceService.LogoutAgent(session); + m_PresenceService?.LogoutAgent(session); return LLFailedLoginResponse.InternalError; } } + private static readonly Regex URIRegex = new(@"^uri:(?[^&]+)&(?\d+[.]?\d*)&(?\d+[.]?\d*)&(?\d+[.]?\d*)$", RegexOptions.Compiled); + protected GridRegion FindDestination( UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out GridRegion gatekeeper, @@ -657,16 +652,16 @@ protected GridRegion FindDestination( position = new Vector3(128, 128, 0); lookAt = new Vector3(0, 1, 0); - if (m_GridService == null) + if (m_GridService is null) return null; if (startLocation.Equals("home")) { // logging into home region - if (pinfo == null) + if (pinfo is null) return null; - if(home != null) + if(home is not null) { position = pinfo.HomePosition; lookAt = pinfo.HomeLookAt; @@ -675,7 +670,7 @@ protected GridRegion FindDestination( } List defaults = m_GridService.GetDefaultRegions(scopeID); - if (defaults != null && defaults.Count > 0) + if (defaults is not null && defaults.Count > 0) { flags |= TeleportFlags.ViaRegionID; where = "safe"; @@ -685,7 +680,7 @@ protected GridRegion FindDestination( m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", account.FirstName, account.LastName); GridRegion region = FindAlternativeRegion(scopeID); - if (region != null) + if (region is not null) { flags |= TeleportFlags.ViaRegionID; where = "safe"; @@ -698,15 +693,15 @@ protected GridRegion FindDestination( // logging into last visited region where = "last"; - if (pinfo == null) + if (pinfo is null) return null; - GridRegion region = null; + GridRegion region; if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null) { List defaults = m_GridService.GetDefaultRegions(scopeID); - if (defaults != null && defaults.Count > 0) + if (defaults is not null && defaults.Count > 0) { flags |= TeleportFlags.ViaRegionID; region = defaults[0]; @@ -716,7 +711,7 @@ protected GridRegion FindDestination( { m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); region = FindAlternativeRegion(scopeID); - if (region != null) + if (region is not null) { flags |= TeleportFlags.ViaRegionID; where = "safe"; @@ -726,6 +721,8 @@ protected GridRegion FindDestination( else { position = pinfo.LastPosition; + position.X = Util.Clamp(position.X, 0.5f, region.RegionSizeX - 0.5f); + position.Y = Util.Clamp(position.Y, 0.5f, region.RegionSizeY - 0.5f); lookAt = pinfo.LastLookAt; } @@ -738,10 +735,11 @@ protected GridRegion FindDestination( // free uri form // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 where = "url"; - GridRegion region = null; - Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+[.]?\d*)&(?\d+[.]?\d*)&(?\d+[.]?\d*)$"); - Match uriMatch = reURI.Match(startLocation); - if (uriMatch == null) + GridRegion region; + Match uriMatch; + lock (URIRegex) + uriMatch = URIRegex.Match(startLocation); + if (uriMatch is null) { m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation); return null; @@ -753,17 +751,17 @@ protected GridRegion FindDestination( float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); string regionName = uriMatch.Groups["region"].ToString(); - if (regionName != null) + if (regionName is not null) { - if (!regionName.Contains("@")) + if (!regionName.Contains('@')) { region = m_GridService.GetRegionByName (scopeID, regionName); - if(region != null) + if(region is not null) return region; m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName); List regions = m_GridService.GetDefaultRegions(scopeID); - if (regions != null && regions.Count > 0) + if (regions is not null && regions.Count > 0) { where = "safe"; return regions[0]; @@ -772,7 +770,7 @@ protected GridRegion FindDestination( { m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); region = FindAlternativeRegion(scopeID); - if (region != null) + if (region is not null) { where = "safe"; return region; @@ -821,7 +819,7 @@ protected GridRegion FindDestination( else { List defaults = m_GridService.GetDefaultRegions(scopeID); - if (defaults != null && defaults.Count > 0) + if (defaults is not null && defaults.Count > 0) { where = "safe"; return defaults[0]; @@ -840,13 +838,13 @@ protected GridRegion FindDestination( private GridRegion FindAlternativeRegion(UUID scopeID) { List regions = m_GridService.GetFallbackRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000)); - if (regions != null && regions.Count > 0 ) + if (regions is not null && regions.Count > 0 ) return regions[0]; if(m_allowLoginFallbackToAnyRegion) { regions = m_GridService.GetOnlineRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000), 10); - if (regions != null && regions.Count > 0) + if (regions is not null && regions.Count > 0) return regions[0]; } @@ -891,7 +889,7 @@ private void SetHostAndPort(string url) { try { - Uri uri = new Uri(url); + Uri uri = new(url); hostName = uri.Host; port = uri.Port; } @@ -908,35 +906,35 @@ protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion d where = currentWhere; ISimulationService simConnector = null; reason = string.Empty; - uint circuitCode = 0; - AgentCircuitData aCircuit = null; + uint circuitCode; + AgentCircuitData aCircuit; dest = null; - bool success = false; + bool success; - if (m_UserAgentService == null) + if (m_UserAgentService is null) { // HG standalones have both a localSimulatonDll and a remoteSimulationDll // non-HG standalones have just a localSimulationDll // independent login servers have just a remoteSimulationDll - if (m_LocalSimulationService != null) + if (m_LocalSimulationService is not null) simConnector = m_LocalSimulationService; - else if (m_RemoteSimulationService != null) + else if (m_RemoteSimulationService is not null) simConnector = m_RemoteSimulationService; - if(simConnector == null) + if(simConnector is null) return null; - circuitCode = (uint)Util.RandomClass.Next(); + circuitCode = (uint)Random.Shared.Next(); aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); - if (!success && m_GridService != null) + if (!success && m_GridService is not null) { // Try the fallback regions List fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); - if (fallbacks != null) + if (fallbacks is not null) { foreach (GridRegion r in fallbacks) { @@ -954,27 +952,29 @@ protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion d else { - if (gatekeeper == null) // login to local grid + if (gatekeeper is null) // login to local grid { if (hostName.Length == 0) SetHostAndPort(m_GatekeeperURL); - gatekeeper = new GridRegion(destination); - gatekeeper.ExternalHostName = hostName; - gatekeeper.HttpPort = (uint)port; - gatekeeper.ServerURI = m_GatekeeperURL; + gatekeeper = new GridRegion(destination) + { + ExternalHostName = hostName, + HttpPort = (uint)port, + ServerURI = m_GatekeeperURL + }; } - circuitCode = (uint)Util.RandomClass.Next(); ; + circuitCode = (uint)Random.Shared.Next(); aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); aCircuit.teleportFlags |= (uint)flags; success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); - if (!success && m_GridService != null) + if (!success && m_GridService is not null) { // Try the fallback regions List fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); - if (fallbacks != null) + if (fallbacks is not null) { foreach (GridRegion r in fallbacks) { @@ -1000,10 +1000,12 @@ private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, string ipaddress, string viewer, string channel, string mac, string id0) { - AgentCircuitData aCircuit = new AgentCircuitData(); + AgentCircuitData aCircuit = new() + { + AgentID = account.PrincipalID + }; - aCircuit.AgentID = account.PrincipalID; - if (avatar != null) + if (avatar is not null) aCircuit.Appearance = new AvatarAppearance(avatar); else aCircuit.Appearance = new AvatarAppearance(); @@ -1032,13 +1034,13 @@ private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account) { aCircuit.ServiceURLs = new Dictionary(); - if (account.ServiceURLs == null) + if (account.ServiceURLs is null) return; // Old style: get the service keys from the DB foreach (KeyValuePair kvp in account.ServiceURLs) { - if (kvp.Value != null) + if (kvp.Value is not null) { aCircuit.ServiceURLs[kvp.Key] = kvp.Value; @@ -1059,7 +1061,7 @@ private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account) string keyName = serviceKey.Replace("SRV_", ""); string keyValue = m_LoginServerConfig.GetString(serviceKey, string.Empty); if (!keyValue.EndsWith("/")) - keyValue = keyValue + "/"; + keyValue += "/"; if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && (string)account.ServiceURLs[keyName] != keyValue)) { @@ -1088,7 +1090,7 @@ private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account) private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason) { - EntityTransferContext ctx = new EntityTransferContext(); + EntityTransferContext ctx = new(); if (!simConnector.QueryAccess( region, aCircuit.AgentID, null, true, aCircuit.startpos, new List(), ctx, out reason)) @@ -1164,7 +1166,7 @@ private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo { UUID regionID = guinfo.LastRegionID; GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID); - if(regInfo == null) + if(regInfo is null) return false; string regURL = regInfo.ServerURI; @@ -1172,20 +1174,22 @@ private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo return false; - GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = UUID.Zero.Guid; - msg.fromAgentID = Constants.servicesGodAgentID.Guid; - msg.toAgentID = agentID.Guid; - msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); - msg.fromAgentName = "GRID"; - msg.message = string.Format("New login detected"); - msg.dialog = 250; // God kick - msg.fromGroup = false; - msg.offline = (byte)0; - msg.ParentEstateID = 0; - msg.Position = Vector3.Zero; - msg.RegionID = scopeID.Guid; - msg.binaryBucket = new byte[1] {0}; + GridInstantMessage msg = new() + { + imSessionID = UUID.Zero.Guid, + fromAgentID = Constants.servicesGodAgentID.Guid, + toAgentID = agentID.Guid, + timestamp = (uint)Util.UnixTimeSinceEpoch(), + fromAgentName = "GRID", + message = string.Format("New login detected"), + dialog = 250, // God kick + fromGroup = false, + offline = (byte)0, + ParentEstateID = 0, + Position = Vector3.Zero, + RegionID = scopeID.Guid, + binaryBucket = new byte[1] { 0 } + }; InstantMessageServiceConnector.SendInstantMessage(regURL,msg, m_messageKey); m_GridUserService.LoggedOut(agentID.ToString(), diff --git a/OpenSim/Services/LLLoginService/OpenSim.Services.LLLoginService.csproj b/OpenSim/Services/LLLoginService/OpenSim.Services.LLLoginService.csproj index 33e4180e761..aa15961ed7a 100644 --- a/OpenSim/Services/LLLoginService/OpenSim.Services.LLLoginService.csproj +++ b/OpenSim/Services/LLLoginService/OpenSim.Services.LLLoginService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.LLLoginService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index bb9fb4b9185..aaaac97a7ac 100644 --- a/OpenSim/Services/MapImageService/MapImageService.cs +++ b/OpenSim/Services/MapImageService/MapImageService.cs @@ -29,31 +29,25 @@ * https://github.com/openmetaversefoundation/simiangrid/ */ +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Net; using System.Reflection; using System.Threading; -using Nini.Config; -using log4net; -using OpenMetaverse; - -using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Services.Interfaces; - namespace OpenSim.Services.MapImageService { public class MapImageService : IMapImageService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); #pragma warning disable 414 private string LogHeader = "[MAP IMAGE SERVICE]"; #pragma warning restore 414 @@ -67,43 +61,31 @@ public class MapImageService : IMapImageService private static object m_Sync = new object(); private static bool m_Initialized = false; - private static string m_WaterTileFile = string.Empty; - private static Color m_Watercolor = Color.FromArgb(29, 71, 95); + private static Color m_Watercolor = Color.FromArgb(29, 72, 96); private static Bitmap m_WaterBitmap = null; - private static byte[] m_WaterBytes = null; + private static byte[] m_WaterJPEGBytes = null; public MapImageService(IConfigSource config) { - if (!m_Initialized) + lock (m_Sync) { - m_Initialized = true; - m_log.Debug("[MAP IMAGE SERVICE]: Starting MapImage service"); - - IConfig serviceConfig = config.Configs["MapImageService"]; - if (serviceConfig != null) + if (!m_Initialized) { - m_TilesStoragePath = serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath); - if (!Directory.Exists(m_TilesStoragePath)) - Directory.CreateDirectory(m_TilesStoragePath); - + m_Initialized = true; + m_log.Debug("[MAP IMAGE SERVICE]: Starting MapImage service"); - m_WaterTileFile = Path.Combine(m_TilesStoragePath, "water.jpg"); - if (!File.Exists(m_WaterTileFile)) + IConfig serviceConfig = config.Configs["MapImageService"]; + if (serviceConfig is not null) { - Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH); - FillImage(waterTile, m_Watercolor); - waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg); - m_WaterBitmap = waterTile; - } - - if (File.Exists(m_WaterTileFile)) - { - m_WaterBitmap = new Bitmap(m_WaterTileFile); + m_TilesStoragePath = serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath); + //memory cache JPEG tile with just water. + m_WaterBitmap = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); + FillImage(m_WaterBitmap, m_Watercolor); using (MemoryStream ms = new MemoryStream()) { - m_WaterBitmap.Save(ms,ImageFormat.Jpeg); + m_WaterBitmap.Save(ms, ImageFormat.Jpeg); ms.Seek(0, SeekOrigin.Begin); - m_WaterBytes = ms.ToArray(); + m_WaterJPEGBytes = ms.ToArray(); } } } @@ -115,14 +97,13 @@ public MapImageService(IConfigSource config) public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason) { reason = string.Empty; - string fileName = GetFileName(1, x, y, scopeID); - + ReadOnlySpan path = GetFolder(scopeID); + string fileName = GetFileName(1, x, y, path); lock (m_Sync) { try { - using (FileStream f = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write)) - f.Write(imageData, 0, imageData.Length); + File.WriteAllBytes(fileName, imageData); } catch (Exception e) { @@ -132,7 +113,7 @@ public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string } } - return UpdateMultiResolutionFiles(x, y, scopeID, out reason); + return UpdateMultiResolutionFiles(x, y, scopeID); } public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) @@ -148,43 +129,43 @@ public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) } catch (Exception e) { - m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e); + m_log.Warn($"[MAP IMAGE SERVICE]: Unable to save delete file {fileName}: {e.Message}"); reason = e.Message; return false; } } - return UpdateMultiResolutionFiles(x, y, scopeID, out reason); + return UpdateMultiResolutionFiles(x, y, scopeID); } // When large varregions start up, they can send piles of new map tiles. This causes // this multi-resolution routine to be called a zillion times an causes much CPU // time to be spent creating multi-resolution tiles that will be replaced when // the next maptile arrives. - private class mapToMultiRez + private struct MapToMultiRez { - public int xx; - public int yy; + public int x; + public int y; public UUID scopeID; - public mapToMultiRez(int pX, int pY, UUID pscopeID) - { - xx = pX; - yy = pY; - scopeID = pscopeID; - } - }; - private Queue multiRezToBuild = new Queue(); + } - private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID, out string reason) - { - reason = String.Empty; + private readonly Queue m_MultiRezToBuild = new Queue(); - lock (multiRezToBuild) + private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID) + { + lock (m_MultiRezToBuild) { // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y); - multiRezToBuild.Enqueue(new mapToMultiRez(x, y, scopeID)); - if (multiRezToBuild.Count == 1) - Util.FireAndForget( - DoUpdateMultiResolutionFilesAsync); + m_MultiRezToBuild.Enqueue( + new MapToMultiRez + { + x = x, + y = y, + scopeID = scopeID + } + ); + + if (m_MultiRezToBuild.Count == 1) + Util.FireAndForget(DoUpdateMultiResolutionFilesAsync); } return true; @@ -195,44 +176,26 @@ private void DoUpdateMultiResolutionFilesAsync(object o) // let acumulate large region tiles Thread.Sleep(60 * 1000); // large regions take time to upload tiles - while (multiRezToBuild.Count > 0) + while (true) { - mapToMultiRez toMultiRez = null; - lock (multiRezToBuild) + MapToMultiRez toMultiRez; + lock (m_MultiRezToBuild) { - if (multiRezToBuild.Count > 0) - toMultiRez = multiRezToBuild.Dequeue(); + if(!m_MultiRezToBuild.TryDequeue(out toMultiRez)) + return; } - if (toMultiRez != null) - { - int x = toMultiRez.xx; - int y = toMultiRez.yy; - UUID scopeID = toMultiRez.scopeID; - // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y); - - int width = 1; - // Stitch seven more aggregate tiles together - for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++) + ReadOnlySpan path = GetFolder(toMultiRez.scopeID); + for (int zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++) + { + if (!CreateTile(zoomLevel, toMultiRez.x, toMultiRez.y, path)) { - // Calculate the width (in full resolution tiles) and bottom-left - // corner of the current zoom level - width *= 2; - int x1 = x - (x % width); - int y1 = y - (y % width); - - lock (m_Sync) // must lock the reading and writing of the maptile files - { - if (!CreateTile(zoomLevel, x1, y1, scopeID)) - { - m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); - return; - } - } + m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", toMultiRez.x, toMultiRez.y, zoomLevel); + return; } } + Thread.Sleep(50); // slow things a bit } - return; } public byte[] GetMapTile(string fileName, UUID scopeID, out string format) @@ -242,44 +205,61 @@ public byte[] GetMapTile(string fileName, UUID scopeID, out string format) fullName = Path.Combine(fullName, fileName); try { - format = Path.GetExtension(fileName).ToLower(); - //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); - return File.ReadAllBytes(fullName); + lock (m_Sync) + { + format = Path.GetExtension(fileName).ToLower(); + //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); + return File.ReadAllBytes(fullName); + } } catch { format = ".jpg"; - if (m_WaterBytes != null) - return (byte[])m_WaterBytes.Clone(); - else - { - //m_log.DebugFormat("[MAP IMAGE SERVICE]: unable to get file {0}", fileName); - return Array.Empty(); - } + return m_WaterJPEGBytes is null ? Array.Empty() : m_WaterJPEGBytes; } } #endregion + private string GetFileName(int zoomLevel, int x, int y, UUID scopeID) + { + string path = Path.Combine(m_TilesStoragePath, scopeID.ToString()); + return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, "jpg")); + } + private string GetFileName(int zoomLevel, int x, int y, ReadOnlySpan path) + { + return Path.Combine(path.ToString(), string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, "jpg")); + } - private string GetFileName(uint zoomLevel, int x, int y, UUID scopeID) + private string GetFolder(UUID scopeID) { - string extension = "jpg"; string path = Path.Combine(m_TilesStoragePath, scopeID.ToString()); Directory.CreateDirectory(path); - return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); + return path; } private Bitmap GetInputTileImage(string fileName) { try { - if (File.Exists(fileName)) - return new Bitmap(fileName); + lock(m_Sync) + { + if (File.Exists(fileName)) + { + Bitmap bm = new Bitmap(fileName); + if (bm.Width != IMAGE_WIDTH || bm.Height != IMAGE_WIDTH || bm.PixelFormat != PixelFormat.Format24bppRgb) + { + m_log.Error($"[MAP IMAGE SERVICE]: invalid map tile {fileName}: {bm.Width} , {bm.Height}, {bm.PixelFormat}"); + bm.Dispose(); + return null; + } + return bm; + } + } } catch (Exception e) { - m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to read image data from {0}: {1}", fileName, e); + m_log.Warn($"[MAP IMAGE SERVICE]: Unable to read image data from {fileName}: {e.Message}"); } return null; @@ -289,15 +269,9 @@ private Bitmap GetOutputTileImage(string fileName) { try { - if (File.Exists(fileName)) - return new Bitmap(fileName); - - else + lock(m_Sync) { - // Create a new output tile with a transparent background - Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); - //bm.MakeTransparent(); // 24bpp does not have transparency, this would make it 32bpp - return bm; + return File.Exists(fileName) ? new Bitmap(fileName) : new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); } } catch (Exception e) @@ -308,66 +282,62 @@ private Bitmap GetOutputTileImage(string fileName) return null; } - private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID) + private bool CreateTile(int zoomLevel, int inx, int iny, ReadOnlySpan path) { -// m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); - int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); - int thisWidth = (int)Math.Pow(2, (double)zoomLevel - 1); + int previusLevel = zoomLevel - 1; + int prevStep = 1 << previusLevel - 1; - // Convert x and y to the bottom left tile for this zoom level - int xIn = x - (x % prevWidth); - int yIn = y - (y % prevWidth); + int mask = unchecked((int)0xffffffff) << previusLevel; - // Convert x and y to the bottom left tile for the next zoom level - int xOut = x - (x % thisWidth); - int yOut = y - (y % thisWidth); - - // Try to open the four input tiles from the previous zoom level - Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn, scopeID)); - Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn, scopeID)); - Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth, scopeID)); - Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth, scopeID)); - - // Open the output tile (current zoom level) - string outputFile = GetFileName(zoomLevel, xOut, yOut, scopeID); + // Convert x and y to the bottom left of current tile + int x = inx & mask; + int y = iny & mask; int ntiles = 0; Bitmap output = (Bitmap)m_WaterBitmap.Clone(); - if (inputBL != null) + Bitmap input = GetInputTileImage(GetFileName(previusLevel, x, y, path)); + if (input is not null) { - ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0); - inputBL.Dispose(); + ImageCopyResampled(output, input, 0, HALF_WIDTH); + input.Dispose(); ntiles++; } - if (inputBR != null) + input = GetInputTileImage(GetFileName(previusLevel, x + prevStep, y, path)); + if (input is not null) { - ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0); - inputBR.Dispose(); + ImageCopyResampled(output, input, HALF_WIDTH, HALF_WIDTH); + input.Dispose(); ntiles++; } - if (inputTL != null) + input = GetInputTileImage(GetFileName(previusLevel, x, y + prevStep, path)); + if (input is not null) { - ImageCopyResampled(output, inputTL, 0, 0, 0, 0); - inputTL.Dispose(); + ImageCopyResampled(output, input, 0, 0); + input.Dispose(); ntiles++; } - if (inputTR != null) + input = GetInputTileImage(GetFileName(previusLevel, x + prevStep, y + prevStep, path)); + if (input is not null) { - ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0); - inputTR.Dispose(); + ImageCopyResampled(output, input, HALF_WIDTH, 0); + input.Dispose(); ntiles++; } + string outputFile = GetFileName(zoomLevel, x, y, path); try { - File.Delete(outputFile); - if (ntiles > 0) - output.Save(outputFile, ImageFormat.Jpeg); + lock(m_Sync) + { + File.Delete(outputFile); + if (ntiles > 0) + output.Save(outputFile, ImageFormat.Jpeg); + } } catch (Exception e) { - m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e); + m_log.Warn($"[MAP IMAGE SERVICE]: Oops on saving {outputFile} {e.Message}"); } output.Dispose(); @@ -378,22 +348,75 @@ private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID) private void FillImage(Bitmap bm, Color c) { - for (int x = 0; x < bm.Width; x++) - for (int y = 0; y < bm.Height; y++) - bm.SetPixel(x, y, c); + BitmapData srcData = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb); + byte r = c.R; + byte g = c.G; + byte b = c.B; + unsafe + { + byte* ptr = (byte*)srcData.Scan0; + for(int y = 0; y < bm.Height; y++) + { + for(int x = 0; x < bm.Width; x++) + { + *ptr++ = b; + *ptr++ = g; + *ptr++ = r; + } + } + } + bm.UnlockBits(srcData); } - private void ImageCopyResampled(Bitmap output, Bitmap input, int destX, int destY, int srcX, int srcY) + private void ImageCopyResampled(Bitmap output, Bitmap input, int destX, int destY) { - int resamplingRateX = 2; // (input.Width - srcX) / (output.Width - destX); - int resamplingRateY = 2; // (input.Height - srcY) / (output.Height - destY); - - for (int x = destX; x < destX + HALF_WIDTH; x++) - for (int y = destY; y < destY + HALF_WIDTH; y++) + try + { + BitmapData srcData = input.LockBits(new Rectangle(0, 0, input.Width, input.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); + BitmapData dstData = output.LockBits(new Rectangle(0, 0, output.Width, output.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); + unsafe { - Color p = input.GetPixel(srcX + (x - destX) * resamplingRateX, srcY + (y - destY) * resamplingRateY); - output.SetPixel(x, y, p); + byte* srcPointer = (byte*)srcData.Scan0; + byte* srcPointer2 = (byte*)srcData.Scan0 + srcData.Stride; + byte* dstPointer = (byte*)dstData.Scan0 + destY * dstData.Stride + 3 * destX; + for (int y = 0; y < HALF_WIDTH; y++) + { + byte* dxptr = dstPointer; + for (int i = 0; i < HALF_WIDTH; i++) + { + // Blue + int t = srcPointer[0] + srcPointer[3] + srcPointer2[0] + srcPointer2[3]; + dxptr[0] = (byte)(t >> 2); + // Green + t = srcPointer[1] + srcPointer[4] + srcPointer2[1] + srcPointer2[4]; + dxptr[1] = (byte)(t >> 2); + + // Red + t = srcPointer[2] + srcPointer[5] + srcPointer2[2] + srcPointer2[5]; + dxptr[2] = (byte)(t >> 2); + + /* + dxptr[0] = srcPointer[0]; // Blue + dxptr[1] = srcPointer[1]; // Green + dxptr[2] = srcPointer[2]; // Red + */ + srcPointer += 6; // skip one point + srcPointer2 += 6; // skip one point + dxptr += 3; + } + srcPointer += srcData.Stride; // skip extra line + srcPointer2 += srcData.Stride; + dstPointer += dstData.Stride; + } } + + output.UnlockBits(dstData); + input.UnlockBits(srcData); + } + //catch (InvalidOperationException e) + catch + { + } } #endregion diff --git a/OpenSim/Services/MapImageService/OpenSim.Services.MapImageService.csproj b/OpenSim/Services/MapImageService/OpenSim.Services.MapImageService.csproj index 3a9b6ca5bf2..7d4f207b003 100644 --- a/OpenSim/Services/MapImageService/OpenSim.Services.MapImageService.csproj +++ b/OpenSim/Services/MapImageService/OpenSim.Services.MapImageService.csproj @@ -1,10 +1,11 @@ - net48 + net8.0 OpenSim.Services.MapImageService http://opensimulator.org OpenSim OpenSimulator developers + true diff --git a/OpenSim/Services/MuteListService/OpenSim.Services.MuteListService.csproj b/OpenSim/Services/MuteListService/OpenSim.Services.MuteListService.csproj index b4792767050..f1ad874c016 100644 --- a/OpenSim/Services/MuteListService/OpenSim.Services.MuteListService.csproj +++ b/OpenSim/Services/MuteListService/OpenSim.Services.MuteListService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.MuteListService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/PresenceService/OpenSim.Services.PresenceService.csproj b/OpenSim/Services/PresenceService/OpenSim.Services.PresenceService.csproj index 7aef8e81946..3232c7bdc1e 100644 --- a/OpenSim/Services/PresenceService/OpenSim.Services.PresenceService.csproj +++ b/OpenSim/Services/PresenceService/OpenSim.Services.PresenceService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.PresenceService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index d61637b6fb3..fb6ac37a2f6 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -114,10 +114,11 @@ public bool LogoutAgent(UUID sessionID) (presence == null) ? null : presence.RegionID.ToString()); bool ret = m_Database.Delete("SessionID", sessionID.ToString()); - if(inCache && presence != null) + if(inCache) { - BySessionCache.Remove(presence.SessionID); - ByUserCache.Remove(presence.UserID); + BySessionCache.Remove(sessionID); + if(presence is not null) + ByUserCache.Remove(presence.UserID); } return ret; } @@ -125,7 +126,7 @@ public bool LogoutAgent(UUID sessionID) public bool LogoutRegionAgents(UUID regionID) { PresenceData[] prevSessions = GetRegionAgents(regionID); - if ((prevSessions == null) || (prevSessions.Length == 0)) + if ((prevSessions is null) || (prevSessions.Length == 0)) return true; m_log.DebugFormat("[PRESENCE SERVICE]: Logout users in region {0}", regionID); @@ -136,7 +137,6 @@ public bool LogoutRegionAgents(UUID regionID) ByUserCache.Remove(pd.UserID); } - // There's a small chance that LogoutRegionAgents() will logout different users than the // list that was logged above, but it's unlikely and not worth dealing with. diff --git a/OpenSim/Services/SimulationService/OpenSim.Services.SimulationService.csproj b/OpenSim/Services/SimulationService/OpenSim.Services.SimulationService.csproj index 5e979f98d73..217a2157386 100644 --- a/OpenSim/Services/SimulationService/OpenSim.Services.SimulationService.csproj +++ b/OpenSim/Services/SimulationService/OpenSim.Services.SimulationService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.SimulationService http://opensimulator.org OpenSim @@ -23,9 +23,6 @@ ..\..\..\bin\OpenMetaverseTypes.dll False - - False - False @@ -41,4 +38,4 @@ - \ No newline at end of file + diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs index 6a6d8482ec2..52e68c21dae 100644 --- a/OpenSim/Services/SimulationService/SimulationDataService.cs +++ b/OpenSim/Services/SimulationService/SimulationDataService.cs @@ -81,6 +81,10 @@ public SimulationDataService(IConfigSource config) public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { + uint flags = obj.RootPart.GetEffectiveObjectFlags(); + if ((flags & (uint)(PrimFlags.Temporary | PrimFlags.TemporaryOnRez)) != 0) + return; + m_database.StoreObject(obj, regionUUID); } diff --git a/OpenSim/Services/UserAccountService/OpenSim.Services.UserAccountService.csproj b/OpenSim/Services/UserAccountService/OpenSim.Services.UserAccountService.csproj index 9fc1ca24dd2..9a95ff3dd26 100644 --- a/OpenSim/Services/UserAccountService/OpenSim.Services.UserAccountService.csproj +++ b/OpenSim/Services/UserAccountService/OpenSim.Services.UserAccountService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.UserAccountService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/UserProfilesService/OpenSim.Services.UserProfilesService.csproj b/OpenSim/Services/UserProfilesService/OpenSim.Services.UserProfilesService.csproj index eea8891312c..1dee22e611d 100644 --- a/OpenSim/Services/UserProfilesService/OpenSim.Services.UserProfilesService.csproj +++ b/OpenSim/Services/UserProfilesService/OpenSim.Services.UserProfilesService.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Services.UserProfilesService http://opensimulator.org OpenSim diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs index 76aa093c074..fa5ed18fdfe 100644 --- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs +++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs @@ -42,9 +42,7 @@ namespace OpenSim.Services.ProfilesService { public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService { - static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); IUserAccountService userAccounts; diff --git a/OpenSim/Tests/Clients/Assets/AssetsClient.cs b/OpenSim/Tests/Clients/Assets/AssetsClient.cs deleted file mode 100644 index d6731ed81ab..00000000000 --- a/OpenSim/Tests/Clients/Assets/AssetsClient.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Text; -using System.Reflection; -using System.Threading; - -using OpenMetaverse; -using log4net; -using log4net.Appender; -using log4net.Layout; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace OpenSim.Tests.Clients.AssetsClient -{ - public class AssetsClient - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private static int m_MaxThreadID = 0; - private static readonly int NREQS = 150; - private static int m_NReceived = 0; - - public static void Main(string[] args) - { - ConsoleAppender consoleAppender = new ConsoleAppender(); - consoleAppender.Layout = - new PatternLayout("[%thread] - %message%newline"); - log4net.Config.BasicConfigurator.Configure(consoleAppender); - - string serverURI = "http://127.0.0.1:8003"; - if (args.Length > 1) - serverURI = args[1]; - int max1, max2; - ThreadPool.GetMaxThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2); - ThreadPool.GetMinThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2); - - if (!ThreadPool.SetMinThreads(1, 1)) - m_log.WarnFormat("[ASSET CLIENT]: Failed to set min threads"); - - if (!ThreadPool.SetMaxThreads(10, 3)) - m_log.WarnFormat("[ASSET CLIENT]: Failed to set max threads"); - - ThreadPool.GetMaxThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2); - ThreadPool.GetMinThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2); - - AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI); - m_Connector.MaxAssetRequestConcurrency = 30; - - for (int i = 0; i < NREQS; i++) - { - UUID uuid = UUID.Random(); - m_Connector.Get(uuid.ToString(), null, ResponseReceived); - m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid); - } - - for (int i = 0; i < 500; i++) - { - var x = i; - ThreadPool.QueueUserWorkItem(delegate - { - Dummy(x); - }); - } - - Thread.Sleep(30 * 1000); - m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived); - } - - private static void ResponseReceived(string id, Object sender, AssetBase asset) - { - if (Thread.CurrentThread.ManagedThreadId > m_MaxThreadID) - m_MaxThreadID = Thread.CurrentThread.ManagedThreadId; - int max1, max2; - ThreadPool.GetAvailableThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: Received asset {0} ({1}) ({2}-{3}) {4}", id, m_MaxThreadID, max1, max2, DateTime.Now.ToString("hh:mm:ss")); - m_NReceived++; - } - - private static void Dummy(int i) - { - int max1, max2; - ThreadPool.GetAvailableThreads(out max1, out max2); - m_log.InfoFormat("[ASSET CLIENT]: ({0}) Hello! {1} - {2} {3}", i, max1, max2, DateTime.Now.ToString("hh:mm:ss")); - Thread.Sleep(2000); - } - } -} diff --git a/OpenSim/Tests/Clients/Assets/OpenSim.Tests.Clients.AssetClient.csproj b/OpenSim/Tests/Clients/Assets/OpenSim.Tests.Clients.AssetClient.csproj deleted file mode 100644 index 08b8baeb77d..00000000000 --- a/OpenSim/Tests/Clients/Assets/OpenSim.Tests.Clients.AssetClient.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - net48 - Exe - - - - - - - - - ..\..\..\..\bin\Nini.dll - False - - - ..\..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\..\bin\OpenMetaverseTypes.dll - False - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs deleted file mode 100644 index 7d3aee31380..00000000000 --- a/OpenSim/Tests/Clients/Grid/GridClient.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using System.Reflection; - -using OpenMetaverse; -using log4net; -using log4net.Appender; -using log4net.Layout; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenSim.Services.Connectors; - -namespace OpenSim.Tests.Clients.GridClient -{ - public class GridClient - { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - - public static void Main(string[] args) - { - ConsoleAppender consoleAppender = new ConsoleAppender(); - consoleAppender.Layout = - new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); - log4net.Config.BasicConfigurator.Configure(consoleAppender); - - string serverURI = "http://127.0.0.1:8001"; - GridServicesConnector m_Connector = new GridServicesConnector(serverURI); - - GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); - GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); - GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); - - Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); - string msg = m_Connector.RegisterRegion(UUID.Zero, r1); - if (msg == String.Empty) - Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); - else - Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); - - Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); - msg = m_Connector.RegisterRegion(UUID.Zero, r2); - if (msg == String.Empty) - Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); - else - Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); - - Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); - msg = m_Connector.RegisterRegion(UUID.Zero, r3); - if (msg == String.Empty) - Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); - else - Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); - - - bool success; - Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); - success = m_Connector.DeregisterRegion(r3.RegionID); - if (success) - Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); - else - Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); - Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); - msg = m_Connector.RegisterRegion(UUID.Zero, r3); - if (msg == String.Empty) - Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); - else - Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); - - Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1"); - List regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); - if (regions == null) - Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed"); - else if (regions.Count > 0) - { - if (regions.Count != 1) - Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count); - else - Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName); - } - else - Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours"); - - - Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)"); - GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); - if (region == null) - Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); - - Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)"); - region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); - if (region == null) - Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName); - - Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)"); - region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); - if (region == null) - Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); - - Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)"); - region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); - if (region == null) - Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName); - - Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)"); - regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); - if (regions == null) - Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions"); - - Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)"); - regions = m_Connector.GetRegionRange(UUID.Zero, - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); - if (regions == null) - Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); - Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)"); - regions = m_Connector.GetRegionRange(UUID.Zero, - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); - if (regions == null) - Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); - else - Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); - - Console.Write("Proceed to deregister? Press enter..."); - Console.ReadLine(); - - // Deregister them all - Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1"); - success = m_Connector.DeregisterRegion(r1.RegionID); - if (success) - Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1"); - else - Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister"); - Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2"); - success = m_Connector.DeregisterRegion(r2.RegionID); - if (success) - Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2"); - else - Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister"); - Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); - success = m_Connector.DeregisterRegion(r3.RegionID); - if (success) - Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3"); - else - Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); - - } - - private static GridRegion CreateRegion(string name, uint xcell, uint ycell) - { - GridRegion region = new GridRegion(xcell, ycell); - region.RegionName = name; - region.RegionID = UUID.Random(); - region.ExternalHostName = "127.0.0.1"; - region.HttpPort = 9000; - region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); - - return region; - } - } -} diff --git a/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs b/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs deleted file mode 100644 index 15c88021fcf..00000000000 --- a/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework.Constraints; - -namespace OpenSim.Tests.Common -{ - public abstract class ANumericalToleranceConstraint : Constraint - { - protected double _tolerance; - - public ANumericalToleranceConstraint(double tolerance) - { - if (tolerance < 0) - { - throw new ArgumentException("Tolerance cannot be negative."); - } - _tolerance = tolerance; - } - - protected bool IsWithinDoubleConstraint(double doubleValue, double baseValue) - { - if (doubleValue >= baseValue - _tolerance && doubleValue <= baseValue + _tolerance) - { - return true; - } - - return false; - } - } -} diff --git a/OpenSim/Tests/Common/DatabaseTestAttribute.cs b/OpenSim/Tests/Common/DatabaseTestAttribute.cs deleted file mode 100644 index d6a03cd6883..00000000000 --- a/OpenSim/Tests/Common/DatabaseTestAttribute.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using NUnit.Framework; - -namespace OpenSim.Tests.Common -{ - [AttributeUsage(AttributeTargets.All, - AllowMultiple=false, - Inherited=true)] - public class DatabaseTestAttribute : LongRunningAttribute - { - public DatabaseTestAttribute() : base("Database") - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs deleted file mode 100644 index b2f20571ae4..00000000000 --- a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using NUnit.Framework.Constraints; - -namespace OpenSim.Tests.Common -{ - public class DoubleToleranceConstraint : ANumericalToleranceConstraint - { - private double _baseValue; - private double _valueToBeTested; - - public DoubleToleranceConstraint(double baseValue, double tolerance) : base(tolerance) - { - _baseValue = baseValue; - } - - /// - ///Test whether the constraint is satisfied by a given value - /// - ///The value to be tested - /// - ///True for success, false for failure - /// - public override bool Matches(object valueToBeTested) - { - if (valueToBeTested == null) - { - throw new ArgumentException("Constraint cannot be used upon null values."); - } - if (valueToBeTested.GetType() != typeof(double)) - { - throw new ArgumentException("Constraint cannot be used upon non double-values."); - } - - _valueToBeTested = (double)valueToBeTested; - - return IsWithinDoubleConstraint(_valueToBeTested, _baseValue); - } - - public override void WriteDescriptionTo(MessageWriter writer) - { - writer.WriteExpectedValue(string.Format("A value {0} within tolerance of plus or minus {1}",_baseValue,_tolerance)); - } - - public override void WriteActualValueTo(MessageWriter writer) - { - writer.WriteActualValue(_valueToBeTested); - } - } -} diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs deleted file mode 100644 index 974da4ca2bd..00000000000 --- a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - public class AssetHelpers - { - /// - /// Create a notecard asset with a random uuids and dummy text. - /// - /// - public static AssetBase CreateNotecardAsset() - { - return CreateNotecardAsset(UUID.Random()); - } - - /// - /// Create a notecard asset with dummy text and a random owner. - /// - /// /param> - /// - public static AssetBase CreateNotecardAsset(UUID assetId) - { - return CreateNotecardAsset(assetId, "hello"); - } - - /// - /// Create a notecard asset with a random owner. - /// - /// /param> - /// - /// - public static AssetBase CreateNotecardAsset(UUID assetId, string text) - { - return CreateAsset(assetId, AssetType.Notecard, text, UUID.Random()); - } - -// /// -// /// Create and store a notecard asset with a random uuid and dummy text. -// /// -// /// /param> -// /// -// public static AssetBase CreateNotecardAsset(Scene scene, UUID creatorId) -// { -// AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); -// scene.AssetService.Store(asset); -// return asset; -// } - - /// - /// Create an asset from the given object. - /// - /// - /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be used. - /// - /// - /// - public static AssetBase CreateAsset(int assetUuidTail, SceneObjectGroup sog) - { - return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), sog); - } - - /// - /// Create an asset from the given object. - /// - /// - /// - /// - public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) - { - return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), - sog.OwnerID); - } - - /// - /// Create an asset from the given scene object. - /// - /// - /// The hexadecimal last part of the UUID for the asset created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be used. - /// - /// - /// - public static AssetBase CreateAsset(int assetUuidTail, CoalescedSceneObjects coa) - { - return CreateAsset(new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", assetUuidTail)), coa); - } - - /// - /// Create an asset from the given scene object. - /// - /// - /// - /// - public static AssetBase CreateAsset(UUID assetUuid, CoalescedSceneObjects coa) - { - return CreateAsset( - assetUuid, - AssetType.Object, - Encoding.ASCII.GetBytes(CoalescedSceneObjectsSerializer.ToXml(coa)), - coa.CreatorId); - } - - /// - /// Create an asset from the given data. - /// - public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string text, UUID creatorID) - { - AssetNotecard anc = new AssetNotecard(); - anc.BodyText = text; - anc.Encode(); - - return CreateAsset(assetUuid, assetType, anc.AssetData, creatorID); - } - - /// - /// Create an asset from the given data. - /// - public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID) - { - AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString()); - asset.Data = data; - return asset; - } - - public static string ReadAssetAsString(IAssetService assetService, UUID uuid) - { - byte[] assetData = assetService.GetData(uuid.ToString()); - return Encoding.ASCII.GetString(assetData); - } - } -} diff --git a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs b/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs deleted file mode 100644 index b27c7197801..00000000000 --- a/OpenSim/Tests/Common/Helpers/BaseRequestHandlerHelpers.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Tests.Common -{ - public class BaseRequestHandlerHelpers - { - private static string[] m_emptyStringArray = new string[] { }; - - public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); - Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); - Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); - Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); - - Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); - Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); - Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); - Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); - Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); - Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); - } - - public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) - { - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); - - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); - Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); - - Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); - Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); - Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); - Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); - } - - public static byte[] EmptyByteArray = new byte[] {}; - - } -} diff --git a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs deleted file mode 100644 index cfb776b2467..00000000000 --- a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.Packets; -using OpenSim.Framework; -using OpenSim.Region.ClientStack.LindenUDP; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Tests.Common -{ - /// - /// This class adds full UDP client classes and associated scene presence to scene. - /// - /// - /// This is used for testing client stack code. For testing other code, use SceneHelper methods instead since - /// they operate without the burden of setting up UDP structures which should be unnecessary for testing scene - /// code. - /// - public static class ClientStackHelpers - { - public static ScenePresence AddChildClient( - Scene scene, LLUDPServer udpServer, UUID agentId, UUID sessionId, uint circuitCode) - { - IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); - - UseCircuitCodePacket uccp = new UseCircuitCodePacket(); - - UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock - = new UseCircuitCodePacket.CircuitCodeBlock(); - uccpCcBlock.Code = circuitCode; - uccpCcBlock.ID = agentId; - uccpCcBlock.SessionID = sessionId; - uccp.CircuitCode = uccpCcBlock; - - byte[] uccpBytes = uccp.ToBytes(); - UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length); - upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. - Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); - - AgentCircuitData acd = new AgentCircuitData(); - acd.AgentID = agentId; - acd.SessionID = sessionId; - - scene.AuthenticateHandler.AddNewCircuit(circuitCode, acd); - - udpServer.PacketReceived(upb); - - return scene.GetScenePresence(agentId); - } - - public static TestLLUDPServer AddUdpServer(Scene scene) - { - return AddUdpServer(scene, new IniConfigSource()); - } - - public static TestLLUDPServer AddUdpServer(Scene scene, IniConfigSource configSource) - { - uint port = 0; - AgentCircuitManager acm = scene.AuthenticateHandler; - - TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, port, 0, configSource, acm); - udpServer.AddScene(scene); - - return udpServer; - } - } -} diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs deleted file mode 100644 index b0c9596665d..00000000000 --- a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Reflection; -using System.Text; -using System.Threading; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; - -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests.Common -{ - public static class EntityTransferHelpers - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the - /// viewer to setup a connection with the destination region. - /// - /// - /// - /// A list that will be populated with any TestClients set up in response to - /// being informed about a destination region. - /// - public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate( - TestClient tc, List neighbourTcs) - { - // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the - // event queue). - - tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) => - { - uint x, y; - Util.RegionHandleToRegionLoc(neighbourHandle, out x, out y); - - m_log.DebugFormat( - "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", - x, y, neighbourExternalEndPoint); - - AgentCircuitData newAgent = tc.RequestClientInfo(); - - Scene neighbourScene; - SceneManager.Instance.TryGetScene(x, y, out neighbourScene); - - TestClient neighbourTc = new TestClient(newAgent, neighbourScene); - neighbourTcs.Add(neighbourTc); - neighbourScene.AddNewAgent(neighbourTc, PresenceType.User); - }; - } - - /// - /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the - /// viewer to setup a connection with the destination region. - /// - /// - /// - /// A list that will be populated with any TestClients set up in response to - /// being informed about a destination region. - /// - public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement( - TestClient client, List destinationClients) - { - client.OnTestClientSendRegionTeleport - += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) => - { - uint x, y; - Util.RegionHandleToRegionLoc(regionHandle, out x, out y); - - m_log.DebugFormat( - "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}", - x, y, regionExternalEndPoint); - - AgentCircuitData newAgent = client.RequestClientInfo(); - - Scene destinationScene; - SceneManager.Instance.TryGetScene(x, y, out destinationScene); - - TestClient destinationClient = new TestClient(newAgent, destinationScene); - destinationClients.Add(destinationClient); - destinationScene.AddNewAgent(destinationClient, PresenceType.User); - - ThreadPool.UnsafeQueueUserWorkItem(o => destinationClient.CompleteMovement(), null); - }; - } - } -} diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs deleted file mode 100644 index ec6697eba5d..00000000000 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ /dev/null @@ -1,737 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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; -using System.Collections.Generic; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data.Null; -using OpenSim.Framework; - -using OpenSim.Framework.Console; -using OpenSim.Region.PhysicsModules.SharedBase; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.Avatar.Gods; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; -using OpenSim.Region.PhysicsModule.BasicPhysics; -using OpenSim.Services.Interfaces; -using OpenSim.Server.Base; - -namespace OpenSim.Tests.Common -{ - /// - /// Helpers for setting up scenes. - /// - public class SceneHelpers - { - /// - /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests. - /// - public SceneManager SceneManager { get; private set; } - - public ISimulationDataService SimDataService { get; private set; } - - private AgentCircuitManager m_acm = new AgentCircuitManager(); - private IEstateDataService m_estateDataService = null; - - private LocalAssetServicesConnector m_assetService; - private LocalAuthenticationServicesConnector m_authenticationService; - private LocalInventoryServicesConnector m_inventoryService; - private RegionGridServicesConnector m_gridService; - private LocalUserAccountServicesConnector m_userAccountService; - private LocalPresenceServicesConnector m_presenceService; - - private TestsAssetCache m_cache; - - private PhysicsScene m_physicsScene; - - public SceneHelpers() : this(null) {} - - public SceneHelpers(TestsAssetCache cache) - { - SceneManager = new SceneManager(); - - m_assetService = StartAssetService(cache); - m_authenticationService = StartAuthenticationService(); - m_inventoryService = StartInventoryService(); - m_gridService = StartGridService(); - m_userAccountService = StartUserAccountService(); - m_presenceService = StartPresenceService(); - - m_inventoryService.PostInitialise(); - m_assetService.PostInitialise(); - m_userAccountService.PostInitialise(); - m_presenceService.PostInitialise(); - - m_cache = cache; - - m_physicsScene = StartPhysicsScene(); - - SimDataService = ServerUtils.LoadPlugin("OpenSim.Tests.Common.dll", null); - } - - /// - /// Set up a test scene - /// - /// - /// Automatically starts services, as would the normal runtime. - /// - /// - public TestScene SetupScene() - { - return SetupScene("Unit test region", UUID.Random(), 1000, 1000); - } - - public TestScene SetupScene(string name, UUID id, uint x, uint y) - { - return SetupScene(name, id, x, y, new IniConfigSource()); - } - - public TestScene SetupScene(string name, UUID id, uint x, uint y, IConfigSource configSource) - { - return SetupScene(name, id, x, y, Constants.RegionSize, Constants.RegionSize, configSource); - } - - /// - /// Set up a scene. - /// - /// Name of the region - /// ID of the region - /// X co-ordinate of the region - /// Y co-ordinate of the region - /// X size of scene - /// Y size of scene - /// - /// - public TestScene SetupScene( - string name, UUID id, uint x, uint y, uint sizeX, uint sizeY, IConfigSource configSource) - { - Console.WriteLine("Setting up test scene {0}", name); - - // We must set up a console otherwise setup of some modules may fail - MainConsole.Instance = new MockConsole(); - - RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); - regInfo.RegionName = name; - regInfo.RegionID = id; - regInfo.RegionSizeX = sizeX; - regInfo.RegionSizeY = sizeY; - regInfo.ServerURI = "http://127.0.0.1:9000/"; - - - TestScene testScene = new TestScene( - regInfo, m_acm, SimDataService, m_estateDataService, configSource, null); - - testScene.RegionInfo.EstateSettings = new EstateSettings(); - testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); - - INonSharedRegionModule godsModule = new GodsModule(); - godsModule.Initialise(new IniConfigSource()); - godsModule.AddRegion(testScene); - - // Add scene to physics - ((INonSharedRegionModule)m_physicsScene).AddRegion(testScene); - ((INonSharedRegionModule)m_physicsScene).RegionLoaded(testScene); - - // Add scene to services - m_assetService.AddRegion(testScene); - - if (m_cache != null) - { - m_cache.AddRegion(testScene); - m_cache.RegionLoaded(testScene); - testScene.AddRegionModule(m_cache.Name, m_cache); - } - - m_assetService.RegionLoaded(testScene); - testScene.AddRegionModule(m_assetService.Name, m_assetService); - - m_authenticationService.AddRegion(testScene); - m_authenticationService.RegionLoaded(testScene); - testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService); - - m_inventoryService.AddRegion(testScene); - m_inventoryService.RegionLoaded(testScene); - testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService); - - m_gridService.AddRegion(testScene); - m_gridService.RegionLoaded(testScene); - testScene.AddRegionModule(m_gridService.Name, m_gridService); - - m_userAccountService.AddRegion(testScene); - m_userAccountService.RegionLoaded(testScene); - testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); - - m_presenceService.AddRegion(testScene); - m_presenceService.RegionLoaded(testScene); - testScene.AddRegionModule(m_presenceService.Name, m_presenceService); - - testScene.SetModuleInterfaces(); - - testScene.LandChannel = new TestLandChannel(testScene); - testScene.LoadWorldMap(); - - testScene.LoginsEnabled = true; - testScene.RegisterRegionWithGrid(); - - SceneManager.Add(testScene); - - return testScene; - } - - private static LocalAssetServicesConnector StartAssetService(TestsAssetCache cache) - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); - config.AddConfig("AssetService"); - config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); - config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); - assetService.Initialise(config); - - if (cache != null) - { - IConfigSource cacheConfig = new IniConfigSource(); - cacheConfig.AddConfig("Modules"); - cacheConfig.Configs["Modules"].Set("AssetCaching", "TestsAssetCache"); - cacheConfig.AddConfig("AssetCache"); - - cache.Initialise(cacheConfig); - } - - return assetService; - } - - private static LocalAuthenticationServicesConnector StartAuthenticationService() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("AuthenticationService"); - config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); - config.Configs["AuthenticationService"].Set( - "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); - config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - - LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector(); - service.Initialise(config); - - return service; - } - - private static LocalInventoryServicesConnector StartInventoryService() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("InventoryService"); - config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); - config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); - config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); - - LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); - inventoryService.Initialise(config); - - return inventoryService; - } - - private static RegionGridServicesConnector StartGridService() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("GridService"); - config.Configs["Modules"].Set("GridServices", "RegionGridServicesConnector"); - config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); - config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); - config.Configs["GridService"].Set("ConnectionString", "!static"); - - RegionGridServicesConnector gridService = new RegionGridServicesConnector(); - gridService.Initialise(config); - - return gridService; - } - - /// - /// Start a user account service - /// - /// - /// - private static LocalUserAccountServicesConnector StartUserAccountService() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("UserAccountService"); - config.Configs["Modules"].Set("UserAccountServices", "LocalUserAccountServicesConnector"); - config.Configs["UserAccountService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - config.Configs["UserAccountService"].Set( - "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); - - LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); - userAccountService.Initialise(config); - - return userAccountService; - } - - /// - /// Start a presence service - /// - /// - private static LocalPresenceServicesConnector StartPresenceService() - { - // Unfortunately, some services share data via statics, so we need to null every time to stop interference - // between tests. - // This is a massive non-obvious pita. - NullPresenceData.Instance = null; - - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.AddConfig("PresenceService"); - config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); - config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); - config.Configs["PresenceService"].Set( - "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); - - LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); - presenceService.Initialise(config); - - return presenceService; - } - - private static PhysicsScene StartPhysicsScene() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Startup"); - config.Configs["Startup"].Set("physics", "basicphysics"); - - PhysicsScene pScene = new BasicScene(); - INonSharedRegionModule mod = pScene as INonSharedRegionModule; - mod.Initialise(config); - - return pScene; - } - - /// - /// Setup modules for a scene using their default settings. - /// - /// - /// - public static void SetupSceneModules(Scene scene, params object[] modules) - { - SetupSceneModules(scene, new IniConfigSource(), modules); - } - - /// - /// Setup modules for a scene. - /// - /// - /// If called directly, then all the modules must be shared modules. - /// - /// - /// - /// - public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) - { - SetupSceneModules(new Scene[] { scene }, config, modules); - } - - /// - /// Setup modules for a scene using their default settings. - /// - /// - /// - public static void SetupSceneModules(Scene[] scenes, params object[] modules) - { - SetupSceneModules(scenes, new IniConfigSource(), modules); - } - - /// - /// Setup modules for scenes. - /// - /// - /// If called directly, then all the modules must be shared modules. - /// - /// We are emulating here the normal calls made to setup region modules - /// (Initialise(), PostInitialise(), AddRegion, RegionLoaded()). - /// TODO: Need to reuse normal runtime module code. - /// - /// - /// - /// - public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules) - { - List newModules = new List(); - foreach (object module in modules) - { - IRegionModuleBase m = (IRegionModuleBase)module; -// Console.WriteLine("MODULE {0}", m.Name); - m.Initialise(config); - newModules.Add(m); - } - - foreach (IRegionModuleBase module in newModules) - { - if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise(); - } - - foreach (IRegionModuleBase module in newModules) - { - foreach (Scene scene in scenes) - { - module.AddRegion(scene); - scene.AddRegionModule(module.Name, module); - } - } - - // RegionLoaded is fired after all modules have been appropriately added to all scenes - foreach (IRegionModuleBase module in newModules) - foreach (Scene scene in scenes) - module.RegionLoaded(scene); - - foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); } - } - - /// - /// Generate some standard agent connection data. - /// - /// - /// - public static AgentCircuitData GenerateAgentData(UUID agentId) - { - AgentCircuitData acd = GenerateCommonAgentData(); - - acd.AgentID = agentId; - acd.firstname = "testfirstname"; - acd.lastname = "testlastname"; - acd.ServiceURLs = new Dictionary(); - - return acd; - } - - /// - /// Generate some standard agent connection data. - /// - /// - /// - public static AgentCircuitData GenerateAgentData(UserAccount ua) - { - AgentCircuitData acd = GenerateCommonAgentData(); - - acd.AgentID = ua.PrincipalID; - acd.firstname = ua.FirstName; - acd.lastname = ua.LastName; - acd.ServiceURLs = ua.ServiceURLs; - - return acd; - } - - private static AgentCircuitData GenerateCommonAgentData() - { - AgentCircuitData acd = new AgentCircuitData(); - - // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. - acd.SessionID = UUID.Random(); - acd.SecureSessionID = UUID.Random(); - - acd.circuitcode = 123; - acd.BaseFolder = UUID.Zero; - acd.InventoryFolder = UUID.Zero; - acd.startpos = Vector3.Zero; - acd.CapsPath = "http://wibble.com"; - acd.Appearance = new AvatarAppearance(); - - return acd; - } - - /// - /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test - /// - /// - /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will - /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. - /// - /// - /// - /// - public static ScenePresence AddScenePresence(Scene scene, UUID agentId) - { - return AddScenePresence(scene, GenerateAgentData(agentId)); - } - - /// - /// Add a root agent. - /// - /// - /// - /// - public static ScenePresence AddScenePresence(Scene scene, UserAccount ua) - { - return AddScenePresence(scene, GenerateAgentData(ua)); - } - - /// - /// Add a root agent. - /// - /// - /// This function - /// - /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the - /// userserver if grid) would give initial login data back to the client and separately tell the scene that the - /// agent was coming. - /// - /// 2) Connects the agent with the scene - /// - /// This function performs actions equivalent with notifying the scene that an agent is - /// coming and then actually connecting the agent to the scene. The one step missed out is the very first - /// - /// - /// - /// - public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) - { - return AddScenePresence(scene, new TestClient(agentData, scene), agentData); - } - - /// - /// Add a root agent. - /// - /// - /// This function - /// - /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the - /// userserver if grid) would give initial login data back to the client and separately tell the scene that the - /// agent was coming. - /// - /// 2) Connects the agent with the scene - /// - /// This function performs actions equivalent with notifying the scene that an agent is - /// coming and then actually connecting the agent to the scene. The one step missed out is the very first - /// - /// - /// - /// - public static ScenePresence AddScenePresence( - Scene scene, IClientAPI client, AgentCircuitData agentData) - { - // We emulate the proper login sequence here by doing things in four stages - - // Stage 0: login - // We need to punch through to the underlying service because scene will not, correctly, let us call it - // through it's reference to the LPSC - LocalPresenceServicesConnector lpsc = (LocalPresenceServicesConnector)scene.PresenceService; - lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); - - // Stages 1 & 2 - ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin); - - // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. - sp.CompleteMovement(sp.ControllingClient, true); - - return sp; - } - - /// - /// Introduce an agent into the scene by adding a new client. - /// - /// The scene presence added - /// - /// - /// - /// - private static ScenePresence IntroduceClientToScene( - Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf) - { - string reason; - - // Stage 1: tell the scene to expect a new user connection - if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason)) - Console.WriteLine("NewUserConnection failed: " + reason); - - // Stage 2: add the new client as a child agent to the scene - scene.AddNewAgent(client, PresenceType.User); - - return scene.GetScenePresence(client.AgentId); - } - - public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) - { - return AddChildScenePresence(scene, GenerateAgentData(agentId)); - } - - public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd) - { - acd.child = true; - - // XXX: ViaLogin may not be correct for child agents - TestClient client = new TestClient(acd, scene); - return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin); - } - - /// - /// Add a test object - /// - /// - /// - public static SceneObjectGroup AddSceneObject(Scene scene) - { - return AddSceneObject(scene, "Test Object", UUID.Random()); - } - - /// - /// Add a test object - /// - /// - /// - /// - /// - public static SceneObjectGroup AddSceneObject(Scene scene, string name, UUID ownerId) - { - SceneObjectGroup so = new SceneObjectGroup(CreateSceneObjectPart(name, UUID.Random(), ownerId)); - - //part.UpdatePrimFlags(false, false, true); - //part.ObjectFlags |= (uint)PrimFlags.Phantom; - - scene.AddNewSceneObject(so, true); - so.InvalidateDeepEffectivePerms(); - - return so; - } - - /// - /// Add a test object - /// - /// - /// - /// The number of parts that should be in the scene object - /// - /// - /// - /// The prefix to be given to part names. This will be suffixed with "Part" - /// (e.g. mynamePart1 for the root part) - /// - /// - /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be given to the root part, and incremented for each part thereafter. - /// - /// - public static SceneObjectGroup AddSceneObject(Scene scene, int parts, UUID ownerId, string partNamePrefix, int uuidTail) - { - SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail); - - scene.AddNewSceneObject(so, false); - so.InvalidateDeepEffectivePerms(); - - return so; - } - - /// - /// Create a scene object part. - /// - /// - /// - /// - /// - public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) - { - return new SceneObjectPart( - ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; - } - - /// - /// Create a scene object but do not add it to the scene. - /// - /// - /// UUID always starts at 00000000-0000-0000-0000-000000000001. For some purposes, (e.g. serializing direct - /// to another object's inventory) we do not need a scene unique ID. So it would be better to add the - /// UUID when we actually add an object to a scene rather than on creation. - /// - /// The number of parts that should be in the scene object - /// - /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) - { - return CreateSceneObject(parts, ownerId, 0x1); - } - - /// - /// Create a scene object but do not add it to the scene. - /// - /// The number of parts that should be in the scene object - /// - /// - /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be given to the root part, and incremented for each part thereafter. - /// - /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) - { - return CreateSceneObject(parts, ownerId, "", uuidTail); - } - - /// - /// Create a scene object but do not add it to the scene. - /// - /// - /// The number of parts that should be in the scene object - /// - /// - /// - /// The prefix to be given to part names. This will be suffixed with "Part" - /// (e.g. mynamePart1 for the root part) - /// - /// - /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" - /// will be given to the root part, and incremented for each part thereafter. - /// - /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail) - { - string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); - - SceneObjectGroup sog - = new SceneObjectGroup( - CreateSceneObjectPart(string.Format("{0}Part1", partNamePrefix), new UUID(rawSogId), ownerId)); - - if (parts > 1) - for (int i = 2; i <= parts; i++) - sog.AddPart( - CreateSceneObjectPart( - string.Format("{0}Part{1}", partNamePrefix, i), - new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i - 1)), - ownerId)); - - return sog; - } - } -} diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs deleted file mode 100644 index e3110f677c7..00000000000 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenMetaverse.Assets; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - /// - /// Utility functions for carrying out task inventory tests. - /// - /// - public static class TaskInventoryHelpers - { - /// - /// Add a notecard item to the given part. - /// - /// - /// - /// - /// UUID or UUID stem - /// UUID or UUID stem - /// The tex to put in the notecard. - /// The item that was added - public static TaskInventoryItem AddNotecard( - IAssetService assetService, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) - { - return AddNotecard( - assetService, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); - } - - /// - /// Add a notecard item to the given part. - /// - /// - /// - /// - /// - /// - /// The tex to put in the notecard. - /// The item that was added - public static TaskInventoryItem AddNotecard( - IAssetService assetService, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) - { - AssetNotecard nc = new AssetNotecard(); - nc.BodyText = text; - nc.Encode(); - - AssetBase ncAsset - = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); - assetService.Store(ncAsset); - - TaskInventoryItem ncItem - = new TaskInventoryItem - { Name = itemName, AssetID = assetID, ItemID = itemID, - Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; - part.Inventory.AddInventoryItem(ncItem, true); - - return ncItem; - } - - /// - /// Add a simple script to the given part. - /// - /// - /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these - /// functions more than once in a test. - /// - /// - /// - /// The item that was added - public static TaskInventoryItem AddScript(IAssetService assetService, SceneObjectPart part) - { - return AddScript(assetService, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); - } - - /// - /// Add a simple script to the given part. - /// - /// - /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather - /// than a random component. - /// - /// - /// - /// Name of the script to add - /// LSL script source - /// The item that was added - public static TaskInventoryItem AddScript( - IAssetService assetService, SceneObjectPart part, string scriptName, string scriptSource) - { - return AddScript(assetService, part, UUID.Random(), UUID.Random(), scriptName, scriptSource); - } - - /// - /// Add a simple script to the given part. - /// - /// - /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather - /// than a random component. - /// - /// - /// - /// Item UUID for the script - /// Asset UUID for the script - /// Name of the script to add - /// LSL script source - /// The item that was added - public static TaskInventoryItem AddScript( - IAssetService assetService, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource) - { - AssetScriptText ast = new AssetScriptText(); - ast.Source = scriptSource; - ast.Encode(); - - AssetBase asset - = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero); - assetService.Store(asset); - TaskInventoryItem item - = new TaskInventoryItem - { Name = scriptName, AssetID = assetId, ItemID = itemId, - Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; - part.Inventory.AddInventoryItem(item, true); - - return item; - } - - /// - /// Add a scene object item to the given part. - /// - /// - /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these - /// functions more than once in a test. - /// - /// - /// - /// - /// - /// - /// - /// - public static TaskInventoryItem AddSceneObject( - IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, SceneObjectGroup soToAdd, UUID soAssetId) - { - AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(soAssetId, soToAdd); - assetService.Store(taskSceneObjectAsset); - TaskInventoryItem taskSceneObjectItem - = new TaskInventoryItem - { Name = itemName, - AssetID = taskSceneObjectAsset.FullID, - ItemID = itemId, - OwnerID = soToAdd.OwnerID, - Type = (int)AssetType.Object, - InvType = (int)InventoryType.Object }; - sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); - - return taskSceneObjectItem; - } - - /// - /// Add a scene object item to the given part. - /// - /// - /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these - /// functions more than once in a test. - /// - /// - /// - /// - /// - /// - /// - public static TaskInventoryItem AddSceneObject( - IAssetService assetService, SceneObjectPart sop, string itemName, UUID itemId, UUID userId) - { - SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, userId); - - return TaskInventoryHelpers.AddSceneObject( - assetService, sop, itemName, itemId, taskSceneObject, TestHelpers.ParseTail(0x10)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs deleted file mode 100644 index e6af34b879f..00000000000 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using OpenMetaverse; - -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - /// - /// Utility functions for carrying out user profile related tests. - /// - public static class UserAccountHelpers - { -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, OnInventoryReceivedDelegate callback) -// { -// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); -// return CreateUserWithInventory(commsManager, userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); -// } -// -// /// -// /// Create a test user with a standard inventory -// /// -// /// -// /// First name of user -// /// Last name of user -// /// Password -// /// User ID -// /// -// /// Callback to invoke when inventory has been loaded. This is required because -// /// loading may be asynchronous, even on standalone -// /// -// /// -// public static CachedUserInfo CreateUserWithInventory( -// CommunicationsManager commsManager, string firstName, string lastName, string password, -// UUID userId, OnInventoryReceivedDelegate callback) -// { -// LocalUserServices lus = (LocalUserServices)commsManager.UserService; -// lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); -// -// CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); -// userInfo.OnInventoryReceived += callback; -// userInfo.FetchInventory(); -// -// return userInfo; -// } - - public static UserAccount CreateUserWithInventory(Scene scene) - { - return CreateUserWithInventory(scene, TestHelpers.ParseTail(99)); - } - - public static UserAccount CreateUserWithInventory(Scene scene, UUID userId) - { - return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); - } - - public static UserAccount CreateUserWithInventory(Scene scene, int userId) - { - return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll"); - } - - public static UserAccount CreateUserWithInventory( - Scene scene, string firstName, string lastName, UUID userId, string pw) - { - UserAccount ua = new UserAccount(userId) { FirstName = firstName, LastName = lastName }; - CreateUserWithInventory(scene, ua, pw); - return ua; - } - - public static UserAccount CreateUserWithInventory( - Scene scene, string firstName, string lastName, int userId, string pw) - { - UserAccount ua - = new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName }; - CreateUserWithInventory(scene, ua, pw); - return ua; - } - - public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) - { - // FIXME: This should really be set up by UserAccount itself - ua.ServiceURLs = new Dictionary(); - scene.UserAccountService.StoreUserAccount(ua); - scene.InventoryService.CreateUserInventory(ua.PrincipalID); - scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs deleted file mode 100644 index e18866598c3..00000000000 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - /// - /// Utility functions for carrying out user inventory tests. - /// - public static class UserInventoryHelpers - { - public static readonly string PATH_DELIMITER = "/"; - - /// - /// Add an existing scene object as an item in the user's inventory. - /// - /// - /// Will be added to the system Objects folder. - /// - /// - /// - /// - /// - /// The inventory item created. - public static InventoryItemBase AddInventoryItem( - Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail) - { - return AddInventoryItem( - scene, - so.Name, - TestHelpers.ParseTail(inventoryIdTail), - InventoryType.Object, - AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so), - so.OwnerID); - } - - /// - /// Add an existing scene object as an item in the user's inventory at the given path. - /// - /// - /// - /// - /// - /// The inventory item created. - public static InventoryItemBase AddInventoryItem( - Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail, string path) - { - return AddInventoryItem( - scene, - so.Name, - TestHelpers.ParseTail(inventoryIdTail), - InventoryType.Object, - AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so), - so.OwnerID, - path); - } - - /// - /// Adds the given item to the existing system folder for its type (e.g. an object will go in the "Objects" - /// folder). - /// - /// - /// - /// - /// - /// The serialized asset for this item - /// - /// - private static InventoryItemBase AddInventoryItem( - Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId) - { - return AddInventoryItem( - scene, itemName, itemId, itemType, asset, userId, - scene.InventoryService.GetFolderForType(userId, (FolderType)asset.Type).Name); - } - - /// - /// Adds the given item to an inventory folder - /// - /// - /// - /// - /// - /// The serialized asset for this item - /// - /// Existing inventory path at which to add. - /// - private static InventoryItemBase AddInventoryItem( - Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path) - { - scene.AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Name = itemName; - item.AssetID = asset.FullID; - item.ID = itemId; - item.Owner = userId; - item.AssetType = asset.Type; - item.InvType = (int)itemType; - item.BasePermissions = (uint)OpenMetaverse.PermissionMask.All | - (uint)(Framework.PermissionMask.FoldedMask | Framework.PermissionMask.FoldedCopy | Framework.PermissionMask.FoldedModify | Framework.PermissionMask.FoldedTransfer); - item.CurrentPermissions = (uint)OpenMetaverse.PermissionMask.All | - (uint)(Framework.PermissionMask.FoldedMask | Framework.PermissionMask.FoldedCopy | Framework.PermissionMask.FoldedModify | Framework.PermissionMask.FoldedTransfer); - - InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0]; - - item.Folder = folder.ID; - scene.AddInventoryItem(item); - - return item; - } - - /// - /// Creates a notecard in the objects folder and specify an item id. - /// - /// - /// - /// - /// - /// - public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID userId) - { - return CreateInventoryItem(scene, itemName, UUID.Random(), UUID.Random(), userId, InventoryType.Notecard); - } - - /// - /// Creates an item of the given type with an accompanying asset. - /// - /// - /// - /// - /// - /// Type of item to create - /// - public static InventoryItemBase CreateInventoryItem( - Scene scene, string itemName, UUID userId, InventoryType type) - { - return CreateInventoryItem(scene, itemName, UUID.Random(), UUID.Random(), userId, type); - } - - /// - /// Creates a notecard in the objects folder and specify an item id. - /// - /// - /// - /// - /// - /// - /// Type of item to create - /// - public static InventoryItemBase CreateInventoryItem( - Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType) - { - AssetBase asset = null; - - if (itemType == InventoryType.Notecard) - { - asset = AssetHelpers.CreateNotecardAsset(); - asset.CreatorID = userId.ToString(); - } - else if (itemType == InventoryType.Object) - { - asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId)); - } - else - { - throw new Exception(string.Format("Inventory type {0} not supported", itemType)); - } - - return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId); - } - - /// - /// Create inventory folders starting from the user's root folder. - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. - /// If false, then all folders in the path are created, even if there is already a folder at a particular - /// level with the same name. - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// Will return null if the root folder could not be found. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders) - { - return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders); - } - - /// - /// Create inventory folders starting from the user's root folder. - /// - /// - /// - /// - /// - /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER - /// - /// - /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. - /// If false, then all folders in the path are created, even if there is already a folder at a particular - /// level with the same name. - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// Will return null if the root folder could not be found. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders) - { - InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); - - if (null == rootFolder) - return null; - - return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders); - } - - /// - /// Create inventory folders starting from a given parent folder - /// - /// - /// If any stem of the path names folders that already exist then these are not recreated. This includes the - /// final folder. - /// TODO: May need to make it an option to create duplicate folders. - /// - /// - /// ID of the folder to create - /// - /// - /// The folder to create. - /// - /// - /// If true, then folders in the path which already the same name are - /// used. This applies to the terminal folder as well. - /// If false, then all folders in the path are created, even if there is already a folder at a particular - /// level with the same name. - /// - /// - /// The folder created. If the path contains multiple folders then the last one created is returned. - /// - public static InventoryFolderBase CreateInventoryFolder( - IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders) - { - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); - - InventoryFolderBase folder = null; - - if (useExistingFolders) - folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]); - - if (folder == null) - { -// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name); - - UUID folderIdForCreate; - - if (components.Length > 1) - folderIdForCreate = UUID.Random(); - else - folderIdForCreate = folderId; - - folder - = new InventoryFolderBase( - folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); - - inventoryService.AddFolder(folder); - } -// else -// { -// Console.WriteLine("Found existing folder {0}", folder.Name); -// } - - if (components.Length > 1) - return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders); - else - return folder; - } - - /// - /// Get the inventory folder that matches the path name. If there are multiple folders then only the first - /// is returned. - /// - /// - /// - /// - /// null if no folder matching the path was found - public static InventoryFolderBase GetInventoryFolder(IInventoryService inventoryService, UUID userId, string path) - { - List folders = GetInventoryFolders(inventoryService, userId, path); - - if (folders.Count != 0) - return folders[0]; - else - return null; - } - - /// - /// Get the inventory folders that match the path name. - /// - /// - /// - /// - /// An empty list if no matching folders were found - public static List GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path) - { - return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path); - } - - /// - /// Get the inventory item that matches the path name. If there are multiple items then only the first - /// is returned. - /// - /// - /// - /// - /// null if no item matching the path was found - public static InventoryItemBase GetInventoryItem(IInventoryService inventoryService, UUID userId, string path) - { - return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path); - } - - /// - /// Get the inventory items that match the path name. - /// - /// - /// - /// - /// An empty list if no matching items were found. - public static List GetInventoryItems(IInventoryService inventoryService, UUID userId, string path) - { - return InventoryArchiveUtils.FindItemsByPath(inventoryService, userId, path); - } - } -} diff --git a/OpenSim/Tests/Common/LongRunningAttribute.cs b/OpenSim/Tests/Common/LongRunningAttribute.cs deleted file mode 100644 index 6013fcb2186..00000000000 --- a/OpenSim/Tests/Common/LongRunningAttribute.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using NUnit.Framework; - -namespace OpenSim.Tests.Common -{ - [AttributeUsage(AttributeTargets.All, - AllowMultiple = false, - Inherited = true)] - public class LongRunningAttribute : CategoryAttribute - { - public LongRunningAttribute() : this("Long Running Test") - { - - } - - protected LongRunningAttribute(string category) : base(category) - { - } - } -} diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs deleted file mode 100644 index d0430ff63a9..00000000000 --- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Tests.Common -{ - public class BaseAssetRepository - { - protected Dictionary Assets = new Dictionary(); - - public AssetBase FetchAsset(UUID uuid) - { - if (AssetsExist(new[] { uuid })[0]) - return Assets[uuid]; - else - return null; - } - - public void CreateAsset(AssetBase asset) - { - Assets[asset.FullID] = asset; - } - - public void UpdateAsset(AssetBase asset) - { - CreateAsset(asset); - } - - public bool[] AssetsExist(UUID[] uuids) - { - return Array.ConvertAll(uuids, id => Assets.ContainsKey(id)); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs deleted file mode 100644 index aaf61e7df21..00000000000 --- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Data; - -namespace OpenSim.Tests.Common -{ - /// - /// In memory asset data plugin for test purposes. Could be another dll when properly filled out and when the - /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit - /// tests are single threaded. - /// - public class MockAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin - { - public string Version { get { return "0"; } } - public string Name { get { return "MockAssetDataPlugin"; } } - - public void Initialise() {} - public void Initialise(string connect) {} - public void Dispose() {} - - private readonly List assets = new List(); - - public AssetBase GetAsset(UUID uuid) - { - return assets.Find(x=>x.FullID == uuid); - } - - public bool StoreAsset(AssetBase asset) - { - assets.Add(asset); - return true; - } - - public List FetchAssetMetadataSet(int start, int count) { return new List(count); } - - public bool Delete(string id) - { - return false; - } - } -} diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs deleted file mode 100644 index e9deac768d6..00000000000 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using log4net; -using Mono.Addins; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Data.Null; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; - -namespace OpenSim.Tests.Common -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - IXGroupData m_data = new NullXGroupData(null, null); - - public string Name - { - get { return "MockGroupsServicesConnector"; } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public void Initialise(IConfigSource config) - { - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Adding to region {0}", scene.RegionInfo.RegionName); - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - } - - public void PostInitialise() - { - } - - public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, - int membershipFee, bool openEnrollment, bool allowPublish, - bool maturePublish, UUID founderID) - { - XGroup group = new XGroup() - { - groupID = UUID.Random(), - ownerRoleID = UUID.Random(), - name = name, - charter = charter, - showInList = showInList, - insigniaID = insigniaID, - membershipFee = membershipFee, - openEnrollment = openEnrollment, - allowPublish = allowPublish, - maturePublish = maturePublish, - founderID = founderID, - everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers, - ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers - }; - - if (m_data.StoreGroup(group)) - { - m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID); - return group.groupID; - } - else - { - m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name); - return UUID.Zero; - } - } - - public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, - UUID insigniaID, int membershipFee, bool openEnrollment, - bool allowPublish, bool maturePublish) - { - } - - public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, - string title, ulong powers) - { - } - - public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) - { - } - - public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, - string title, ulong powers) - { - } - - private XGroup GetXGroup(UUID groupID, string name) - { - XGroup group = m_data.GetGroup(groupID); - - - if (group == null) - m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID); - - return group; - } - - public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}", - groupID, groupName); - - XGroup xg = GetXGroup(groupID, groupName); - - if (xg == null) - return null; - - GroupRecord gr = new GroupRecord() - { - GroupID = xg.groupID, - GroupName = xg.name, - AllowPublish = xg.allowPublish, - MaturePublish = xg.maturePublish, - Charter = xg.charter, - FounderID = xg.founderID, - // FIXME: group picture storage location unknown - MembershipFee = xg.membershipFee, - OpenEnrollment = xg.openEnrollment, - OwnerRoleID = xg.ownerRoleID, - ShowInList = xg.showInList - }; - - return gr; - } - - public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) - { - return default(GroupProfileData); - } - - public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) - { - } - - public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) - { - } - - public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}", - requestingAgentID, agentID, groupID, acceptNotices, listInProfile); - - XGroup group = GetXGroup(groupID, null); - - if (group == null) - return; - - XGroupMember xgm = null; - if (!group.members.TryGetValue(agentID, out xgm)) - return; - - xgm.acceptNotices = acceptNotices; - xgm.listInProfile = listInProfile; - - m_data.StoreGroup(group); - } - - public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) - { - } - - public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) - { - return null; - } - - public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) - { - } - - public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}", - requestingAgentID, agentID, groupID, roleID); - - XGroup group = GetXGroup(groupID, null); - - if (group == null) - return; - - XGroupMember groupMember = new XGroupMember() - { - agentID = agentID, - groupID = groupID, - roleID = roleID - }; - - group.members[agentID] = groupMember; - - m_data.StoreGroup(group); - } - - public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) - { - } - - public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) - { - } - - public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) - { - } - - public List FindGroups(UUID requestingAgentID, string search) - { - return null; - } - - public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID) - { - return null; - } - - public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID) - { - return null; - } - - public List GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID) - { - return new List(); - } - - public List GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) - { - return null; - } - - public List GetGroupRoles(UUID requestingAgentID, UUID GroupID) - { - return null; - } - - public List GetGroupMembers(UUID requestingAgentID, UUID groupID) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}", - requestingAgentID, groupID); - - List groupMembers = new List(); - - XGroup group = GetXGroup(groupID, null); - - if (group == null) - return groupMembers; - - foreach (XGroupMember xgm in group.members.Values) - { - GroupMembersData gmd = new GroupMembersData(); - gmd.AgentID = xgm.agentID; - gmd.IsOwner = group.founderID == gmd.AgentID; - gmd.AcceptNotices = xgm.acceptNotices; - gmd.ListInProfile = xgm.listInProfile; - - groupMembers.Add(gmd); - } - - return groupMembers; - } - - public List GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) - { - return null; - } - - public List GetGroupNotices(UUID requestingAgentID, UUID groupID) - { - XGroup group = GetXGroup(groupID, null); - - if (group == null) - return null; - - List notices = new List(); - - foreach (XGroupNotice notice in group.notices.Values) - { - GroupNoticeData gnd = new GroupNoticeData() - { - NoticeID = notice.noticeID, - Timestamp = notice.timestamp, - FromName = notice.fromName, - Subject = notice.subject, - HasAttachment = notice.hasAttachment, - AssetType = (byte)notice.assetType - }; - - notices.Add(gnd); - } - - return notices; - } - - public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}", - requestingAgentID, noticeID); - - // Yes, not an efficient way to do it. - Dictionary groups = m_data.GetGroups(); - - foreach (XGroup group in groups.Values) - { - if (group.notices.ContainsKey(noticeID)) - { - XGroupNotice n = group.notices[noticeID]; - - GroupNoticeInfo gni = new GroupNoticeInfo(); - gni.GroupID = n.groupID; - gni.Message = n.message; - gni.BinaryBucket = n.binaryBucket; - gni.noticeData.NoticeID = n.noticeID; - gni.noticeData.Timestamp = n.timestamp; - gni.noticeData.FromName = n.fromName; - gni.noticeData.Subject = n.subject; - gni.noticeData.HasAttachment = n.hasAttachment; - gni.noticeData.AssetType = (byte)n.assetType; - - return gni; - } - } - - return null; - } - - public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) - { - m_log.DebugFormat( - "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}", - requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length); - - XGroup group = GetXGroup(groupID, null); - - if (group == null) - return; - - XGroupNotice groupNotice = new XGroupNotice() - { - groupID = groupID, - noticeID = noticeID, - fromName = fromName, - subject = subject, - message = message, - timestamp = (uint)Util.UnixTimeSinceEpoch(), - hasAttachment = false, - assetType = 0, - binaryBucket = binaryBucket - }; - - group.notices[noticeID] = groupNotice; - - m_data.StoreGroup(group); - } - - public void ResetAgentGroupChatSessions(UUID agentID) - { - } - - public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - return false; - } - - public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) - { - return false; - } - - public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) - { - } - - public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) - { - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs deleted file mode 100644 index ab0e4f4454e..00000000000 --- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using System.Collections.Generic; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Data.Null -{ - public class NullDataService : ISimulationDataService - { - private NullDataStore m_store; - - public NullDataService() - { - m_store = new NullDataStore(); - } - - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) - { - m_store.StoreObject(obj, regionUUID); - } - - public void RemoveObject(UUID uuid, UUID regionUUID) - { - m_store.RemoveObject(uuid, regionUUID); - } - - public void StorePrimInventory(UUID primID, ICollection items) - { - m_store.StorePrimInventory(primID, items); - } - - public List LoadObjects(UUID regionUUID) - { - return m_store.LoadObjects(regionUUID); - } - - public void StoreTerrain(double[,] terrain, UUID regionID) - { - m_store.StoreTerrain(terrain, regionID); - } - - public void StoreTerrain(TerrainData terrain, UUID regionID) - { - m_store.StoreTerrain(terrain, regionID); - } - - public void StoreBakedTerrain(TerrainData terrain, UUID regionID) - { - m_store.StoreBakedTerrain(terrain, regionID); - } - - public double[,] LoadTerrain(UUID regionID) - { - return m_store.LoadTerrain(regionID); - } - - public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) - { - return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); - } - - public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) - { - return m_store.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ); - } - - public void StoreLandObject(ILandObject Parcel) - { - m_store.StoreLandObject(Parcel); - } - - public void RemoveLandObject(UUID globalID) - { - m_store.RemoveLandObject(globalID); - } - - public List LoadLandObjects(UUID regionUUID) - { - return m_store.LoadLandObjects(regionUUID); - } - - public void StoreRegionSettings(RegionSettings rs) - { - m_store.StoreRegionSettings(rs); - } - - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - return m_store.LoadRegionSettings(regionUUID); - } - - public string LoadRegionEnvironmentSettings(UUID regionUUID) - { - return m_store.LoadRegionEnvironmentSettings(regionUUID); - } - - public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) - { - m_store.StoreRegionEnvironmentSettings(regionUUID, settings); - } - - public void RemoveRegionEnvironmentSettings(UUID regionUUID) - { - m_store.RemoveRegionEnvironmentSettings(regionUUID); - } - - public UUID[] GetObjectIDs(UUID regionID) - { - return new UUID[0]; - } - - public void SaveExtra(UUID regionID, string name, string value) - { - } - - public void RemoveExtra(UUID regionID, string name) - { - } - - public Dictionary GetExtra(UUID regionID) - { - return null; - } - } - - /// - /// Mock region data plugin. This obeys the api contract for persistence but stores everything in memory, so that - /// tests can check correct persistence. - /// - public class NullDataStore : ISimulationDataStore - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Dictionary m_regionSettings = new Dictionary(); - protected Dictionary m_sceneObjectParts = new Dictionary(); - protected Dictionary> m_primItems - = new Dictionary>(); - protected Dictionary m_terrains = new Dictionary(); - protected Dictionary m_bakedterrains = new Dictionary(); - protected Dictionary m_landData = new Dictionary(); - - public void Initialise(string dbfile) - { - return; - } - - public void Dispose() - { - } - - public void StoreRegionSettings(RegionSettings rs) - { - m_regionSettings[rs.RegionUUID] = rs; - } - - #region Environment Settings - public string LoadRegionEnvironmentSettings(UUID regionUUID) - { - //This connector doesn't support the Environment module yet - return string.Empty; - } - - public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) - { - //This connector doesn't support the Environment module yet - } - - public void RemoveRegionEnvironmentSettings(UUID regionUUID) - { - //This connector doesn't support the Environment module yet - } - #endregion - - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - RegionSettings rs = null; - m_regionSettings.TryGetValue(regionUUID, out rs); - - if (rs == null) - rs = new RegionSettings(); - - return rs; - } - - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) - { - // We can't simply store groups here because on delinking, OpenSim will not update the original group - // directly. Rather, the newly delinked parts will be updated to be in their own scene object group - // Therefore, we need to store parts rather than groups. - foreach (SceneObjectPart prim in obj.Parts) - { -// m_log.DebugFormat( -// "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}", -// prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID); - - m_sceneObjectParts[prim.UUID] = prim; - } - } - - public void RemoveObject(UUID obj, UUID regionUUID) - { - // All parts belonging to the object with the uuid are removed. - List parts = new List(m_sceneObjectParts.Values); - foreach (SceneObjectPart part in parts) - { - if (part.ParentGroup.UUID == obj) - { -// m_log.DebugFormat( -// "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}", -// part.Name, part.UUID, obj, regionUUID); - m_sceneObjectParts.Remove(part.UUID); - } - } - } - - public void StorePrimInventory(UUID primID, ICollection items) - { - m_primItems[primID] = items; - } - - public List LoadObjects(UUID regionUUID) - { - Dictionary objects = new Dictionary(); - - // Create all of the SOGs from the root prims first - foreach (SceneObjectPart prim in m_sceneObjectParts.Values) - { - if (prim.IsRoot) - { -// m_log.DebugFormat( -// "[MOCK REGION DATA PLUGIN]: Loading root part {0} {1} in {2}", prim.Name, prim.UUID, regionUUID); - objects[prim.UUID] = new SceneObjectGroup(prim); - } - } - - // Add all of the children objects to the SOGs - foreach (SceneObjectPart prim in m_sceneObjectParts.Values) - { - SceneObjectGroup sog; - if (prim.UUID != prim.ParentUUID) - { - if (objects.TryGetValue(prim.ParentUUID, out sog)) - { - int originalLinkNum = prim.LinkNum; - - sog.AddPart(prim); - - // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. - // We override that here - if (originalLinkNum != 0) - prim.LinkNum = originalLinkNum; - } - else - { -// m_log.WarnFormat( -// "[MOCK REGION DATA PLUGIN]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.", -// prim.Name, prim.UUID, regionUUID, prim.ParentUUID); - } - } - } - - // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that - // way! - - return new List(objects.Values); - } - - public void StoreTerrain(TerrainData ter, UUID regionID) - { - m_terrains[regionID] = ter; - } - - public void StoreBakedTerrain(TerrainData ter, UUID regionID) - { - m_bakedterrains[regionID] = ter; - } - - public void StoreTerrain(double[,] ter, UUID regionID) - { - m_terrains[regionID] = new TerrainData(ter); - } - - public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) - { - if (m_terrains.ContainsKey(regionID)) - return m_terrains[regionID]; - else - return null; - } - - public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) - { - if (m_bakedterrains.ContainsKey(regionID)) - return m_bakedterrains[regionID]; - else - return null; - } - - public double[,] LoadTerrain(UUID regionID) - { - if (m_terrains.ContainsKey(regionID)) - return m_terrains[regionID].GetDoubles(); - else - return null; - } - - public void RemoveLandObject(UUID globalID) - { - if (m_landData.ContainsKey(globalID)) - m_landData.Remove(globalID); - } - - public void StoreLandObject(ILandObject land) - { - m_landData[land.LandData.GlobalID] = land.LandData; - } - - public List LoadLandObjects(UUID regionUUID) - { - return new List(m_landData.Values); - } - - public void Shutdown() - { - } - - public UUID[] GetObjectIDs(UUID regionID) - { - return new UUID[0]; - } - - public void SaveExtra(UUID regionID, string name, string value) - { - } - - public void RemoveExtra(UUID regionID, string name) - { - } - - public Dictionary GetExtra(UUID regionID) - { - return null; - } - } -} diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs deleted file mode 100644 index e82456e5ac1..00000000000 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.Interfaces; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Tests.Common -{ - public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine - { - public IConfigSource ConfigSource { get; private set; } - - public IConfig Config { get; private set; } - - private Scene m_scene; - - /// - /// Expose posted events to tests. - /// - public Dictionary> PostedEvents { get; private set; } - - /// - /// A very primitive way of hooking text cose to a posed event. - /// - /// - /// May be replaced with something that uses more original code in the future. - /// - public event Action PostEventHook; - - public void Initialise(IConfigSource source) - { - ConfigSource = source; - - // Can set later on if required - Config = new IniConfig("MockScriptEngine", ConfigSource); - - PostedEvents = new Dictionary>(); - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - m_scene = scene; - - m_scene.StackModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - } - - public string Name { get { return "Mock Script Engine"; } } - public string ScriptEngineName { get { return Name; } } - - public Type ReplaceableInterface { get { return null; } } - -#pragma warning disable 0067 - public event ScriptRemoved OnScriptRemoved; - public event ObjectRemoved OnObjectRemoved; -#pragma warning restore 0067 - - public string GetXMLState (UUID itemID) - { - throw new System.NotImplementedException (); - } - - public bool SetXMLState(UUID itemID, string xml) - { - throw new System.NotImplementedException (); - } - - public void CancelScriptEvent(UUID itemID, string eventName) - { - - } - - public bool PostScriptEvent(UUID itemID, string name, object[] args) - { -// Console.WriteLine("Posting event {0} for {1}", name, itemID); - - return PostScriptEvent(itemID, new EventParams(name, args, null)); - } - - public bool PostScriptEvent(UUID itemID, EventParams evParams) - { - List eventsForItem; - - if (!PostedEvents.ContainsKey(itemID)) - { - eventsForItem = new List(); - PostedEvents.Add(itemID, eventsForItem); - } - else - { - eventsForItem = PostedEvents[itemID]; - } - - eventsForItem.Add(evParams); - - if (PostEventHook != null) - PostEventHook(itemID, evParams); - - return true; - } - - public bool PostObjectEvent(uint localID, EventParams evParams) - { - return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams); - } - - public bool PostObjectEvent(UUID itemID, string name, object[] args) - { - return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null)); - } - - private bool PostObjectEvent(SceneObjectPart part, EventParams evParams) - { - foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL)) - PostScriptEvent(item.ItemID, evParams); - - return true; - } - - public bool SuspendScript(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public bool ResumeScript(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public ArrayList GetScriptErrors(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public bool HasScript(UUID itemID, out bool running) - { - throw new System.NotImplementedException (); - } - - public bool GetScriptState(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public void SaveAllState() - { - throw new System.NotImplementedException (); - } - - public void StartProcessing() - { - throw new System.NotImplementedException (); - } - - public float GetScriptExecutionTime(List itemIDs) - { - return 0; - } - - public int GetScriptsMemory(List itemIDs) - { - return 0; - } - - public Dictionary GetObjectScriptsExecutionTimes() - { - throw new System.NotImplementedException (); - } - - public IScriptWorkItem QueueEventHandler(object parms) - { - throw new System.NotImplementedException (); - } - - public DetectParams GetDetectParams(UUID item, int number) - { - throw new System.NotImplementedException (); - } - - public void SetMinEventDelay(UUID itemID, double delay) - { - throw new System.NotImplementedException (); - } - - public int GetStartParameter(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public void SetScriptState(UUID itemID, bool state, bool self) - { - throw new System.NotImplementedException (); - } - - public void SetState(UUID itemID, string newState) - { - throw new System.NotImplementedException (); - } - - public void ApiResetScript(UUID itemID) - { - throw new System.NotImplementedException (); - } - - public void ResetScript (UUID itemID) - { - throw new System.NotImplementedException (); - } - - public IScriptApi GetApi(UUID itemID, string name) - { - throw new System.NotImplementedException (); - } - - public Scene World { get { return m_scene; } } - - public IScriptModule ScriptModule { get { return this; } } - - public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} - - public string ScriptClassName { get { throw new System.NotImplementedException (); } } - - public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } } - - public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } - - public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } - - public void ClearPostedEvents() - { - PostedEvents.Clear(); - } - - public void SleepScript(UUID itemID, int delay) - { - } - - public ICollection GetTopObjectStats(float mintime, int minmemory, out float totaltime, out float totalmemory) - { - totaltime = 0; - totalmemory = 0; - return null; - } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs deleted file mode 100755 index f4f828891e7..00000000000 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ /dev/null @@ -1,1416 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Reflection; -using System.Threading; -using log4net; -using OpenMetaverse; -using OpenMetaverse.Packets; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Framework.Client; - -namespace OpenSim.Tests.Common -{ - public class TestClient : IClientAPI, IClientCore - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); - - private Scene m_scene; - - // Properties so that we can get at received data for test purposes - public List ReceivedKills { get; private set; } - public List ReceivedOfflineNotifications { get; private set; } - public List ReceivedOnlineNotifications { get; private set; } - public List ReceivedFriendshipTerminations { get; private set; } - - public List SentImageDataPackets { get; private set; } - public List SentImagePacketPackets { get; private set; } - public List SentImageNotInDatabasePackets { get; private set; } - - // Test client specific events - for use by tests to implement some IClientAPI behaviour. - public event Action OnReceivedMoveAgentIntoRegion; - public event Action OnTestClientInformClientOfNeighbour; - public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; - - public event Action OnReceivedEntityUpdate; - - public event OnReceivedChatMessageDelegate OnReceivedChatMessage; - public event Action OnReceivedInstantMessage; - - public event Action OnReceivedSendRebakeAvatarTextures; - - public delegate void TestClientOnSendRegionTeleportDelegate( - ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, - uint locationID, uint flags, string capsURL); - - public delegate void OnReceivedChatMessageDelegate( - string message, byte type, Vector3 fromPos, string fromName, - UUID fromAgentID, UUID ownerID, byte source, byte audible); - - -// disable warning: public events, part of the public API -#pragma warning disable 67 - - public event Action OnLogout; - public event ObjectPermissions OnObjectPermissions; - - public event MoneyTransferRequest OnMoneyTransferRequest; - public event ParcelBuy OnParcelBuy; - public event Action OnConnectionClosed; - public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; - public event ImprovedInstantMessage OnInstantMessage; - public event ChatMessage OnChatFromClient; - public event TextureRequest OnRequestTexture; - public event RezObject OnRezObject; - public event ModifyTerrain OnModifyTerrain; - public event BakeTerrain OnBakeTerrain; - public event SetAppearance OnSetAppearance; - public event AvatarNowWearing OnAvatarNowWearing; - public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; - public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; - public event UUIDNameRequest OnDetachAttachmentIntoInv; - public event ObjectAttach OnObjectAttach; - public event ObjectDeselect OnObjectDetach; - public event ObjectDrop OnObjectDrop; - public event StartAnim OnStartAnim; - public event StopAnim OnStopAnim; - public event ChangeAnim OnChangeAnim; - public event LinkObjects OnLinkObjects; - public event DelinkObjects OnDelinkObjects; - public event RequestMapBlocks OnRequestMapBlocks; - public event RequestMapName OnMapNameRequest; - public event TeleportLocationRequest OnTeleportLocationRequest; - public event TeleportLandmarkRequest OnTeleportLandmarkRequest; - public event TeleportCancel OnTeleportCancel; - public event DisconnectUser OnDisconnectUser; - public event RequestAvatarProperties OnRequestAvatarProperties; - public event SetAlwaysRun OnSetAlwaysRun; - - public event DeRezObject OnDeRezObject; - public event RezRestoreToWorld OnRezRestoreToWorld; - public event Action OnRegionHandShakeReply; - public event GenericCall1 OnRequestWearables; - public event Action OnCompleteMovementToRegion; - public event UpdateAgent OnPreAgentUpdate; - public event UpdateAgent OnAgentUpdate; - public event UpdateAgent OnAgentCameraUpdate; - public event AgentRequestSit OnAgentRequestSit; - public event AgentSit OnAgentSit; - public event AvatarPickerRequest OnAvatarPickerRequest; - public event Action OnRequestAvatarsData; - public event AddNewPrim OnAddPrim; - public event RequestGodlikePowers OnRequestGodlikePowers; - public event GodKickUser OnGodKickUser; - public event ObjectDuplicate OnObjectDuplicate; - public event GrabObject OnGrabObject; - public event DeGrabObject OnDeGrabObject; - public event MoveObject OnGrabUpdate; - public event SpinStart OnSpinStart; - public event SpinObject OnSpinUpdate; - public event SpinStop OnSpinStop; - public event ViewerEffectEventHandler OnViewerEffect; - - public event AgentDataUpdate OnAgentDataUpdateRequest; - public event TeleportLocationRequest OnSetStartLocationRequest; - - public event UpdateShape OnUpdatePrimShape; - public event ObjectExtraParams OnUpdateExtraParams; - public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; - public event ObjectSelect OnObjectSelect; - public event ObjectRequest OnObjectRequest; - public event GenericCall7 OnObjectDescription; - public event GenericCall7 OnObjectName; - public event GenericCall7 OnObjectClickAction; - public event GenericCall7 OnObjectMaterial; - public event UpdatePrimFlags OnUpdatePrimFlags; - public event UpdatePrimTexture OnUpdatePrimTexture; - public event ClientChangeObject onClientChangeObject; - public event UpdateVector OnUpdatePrimGroupPosition; - public event UpdateVector OnUpdatePrimSinglePosition; - public event UpdatePrimRotation OnUpdatePrimGroupRotation; - public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; - public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; - public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; - public event UpdateVector OnUpdatePrimScale; - public event UpdateVector OnUpdatePrimGroupScale; - public event StatusChange OnChildAgentStatus; - public event GenericCall2 OnStopMovement; - public event Action OnRemoveAvatar; - - public event CreateNewInventoryItem OnCreateNewInventoryItem; - public event LinkInventoryItem OnLinkInventoryItem; - public event CreateInventoryFolder OnCreateNewInventoryFolder; - public event UpdateInventoryFolder OnUpdateInventoryFolder; - public event MoveInventoryFolder OnMoveInventoryFolder; - public event RemoveInventoryFolder OnRemoveInventoryFolder; - public event RemoveInventoryItem OnRemoveInventoryItem; - public event FetchInventoryDescendents OnFetchInventoryDescendents; - public event PurgeInventoryDescendents OnPurgeInventoryDescendents; - public event FetchInventory OnFetchInventory; - public event RequestTaskInventory OnRequestTaskInventory; - public event UpdateInventoryItem OnUpdateInventoryItem; - public event CopyInventoryItem OnCopyInventoryItem; - public event MoveInventoryItem OnMoveInventoryItem; - public event UDPAssetUploadRequest OnAssetUploadRequest; - public event RequestTerrain OnRequestTerrain; - public event RequestTerrain OnUploadTerrain; - public event XferReceive OnXferReceive; - public event RequestXfer OnRequestXfer; - public event ConfirmXfer OnConfirmXfer; - public event AbortXfer OnAbortXfer; - public event RezScript OnRezScript; - public event UpdateTaskInventory OnUpdateTaskInventory; - public event MoveTaskInventory OnMoveTaskItem; - public event RemoveTaskInventory OnRemoveTaskItem; - public event RequestAsset OnRequestAsset; - public event GenericMessage OnGenericMessage; - public event UUIDNameRequest OnNameFromUUIDRequest; - public event UUIDNameRequest OnUUIDGroupNameRequest; - - public event ParcelPropertiesRequest OnParcelPropertiesRequest; - public event ParcelDivideRequest OnParcelDivideRequest; - public event ParcelJoinRequest OnParcelJoinRequest; - public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; - public event ParcelAbandonRequest OnParcelAbandonRequest; - public event ParcelGodForceOwner OnParcelGodForceOwner; - public event ParcelReclaim OnParcelReclaim; - public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest; - public event ParcelAccessListRequest OnParcelAccessListRequest; - public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest; - public event ParcelSelectObjects OnParcelSelectObjects; - public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; - public event ParcelDeedToGroup OnParcelDeedToGroup; - public event ObjectDeselect OnObjectDeselect; - public event RegionInfoRequest OnRegionInfoRequest; - public event EstateCovenantRequest OnEstateCovenantRequest; - public event EstateChangeInfo OnEstateChangeInfo; - public event EstateManageTelehub OnEstateManageTelehub; - public event CachedTextureRequest OnCachedTextureRequest; - - public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; - - public event FriendActionDelegate OnApproveFriendRequest; - public event FriendActionDelegate OnDenyFriendRequest; - public event FriendshipTermination OnTerminateFriendship; - public event GrantUserFriendRights OnGrantUserRights; - - public event EconomyDataRequest OnEconomyDataRequest; - public event MoneyBalanceRequest OnMoneyBalanceRequest; - public event UpdateAvatarProperties OnUpdateAvatarProperties; - - public event ObjectIncludeInSearch OnObjectIncludeInSearch; - public event UUIDNameRequest OnTeleportHomeRequest; - - public event ScriptAnswer OnScriptAnswer; - public event RequestPayPrice OnRequestPayPrice; - public event ObjectSaleInfo OnObjectSaleInfo; - public event ObjectBuy OnObjectBuy; - public event BuyObjectInventory OnBuyObjectInventory; - public event AgentSit OnUndo; - public event AgentSit OnRedo; - public event LandUndo OnLandUndo; - - public event ForceReleaseControls OnForceReleaseControls; - - public event GodLandStatRequest OnLandStatRequest; - public event RequestObjectPropertiesFamily OnObjectGroupRequest; - - public event DetailedEstateDataRequest OnDetailedEstateDataRequest; - public event SetEstateFlagsRequest OnSetEstateFlagsRequest; - public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture; - public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture; - public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights; - public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; - public event SetRegionTerrainSettings OnSetRegionTerrainSettings; - public event EstateRestartSimRequest OnEstateRestartSimRequest; - public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; - public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; - public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest; - public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest; - public event EstateDebugRegionRequest OnEstateDebugRegionRequest; - public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; - public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; - public event ScriptReset OnScriptReset; - public event GetScriptRunning OnGetScriptRunning; - public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; - - public event TerrainUnacked OnUnackedTerrain; - - public event RegionHandleRequest OnRegionHandleRequest; - public event ParcelInfoRequest OnParcelInfoRequest; - - public event ActivateGesture OnActivateGesture; - public event DeactivateGesture OnDeactivateGesture; - public event ObjectOwner OnObjectOwner; - - public event DirPlacesQuery OnDirPlacesQuery; - public event DirFindQuery OnDirFindQuery; - public event DirLandQuery OnDirLandQuery; - public event DirPopularQuery OnDirPopularQuery; - public event DirClassifiedQuery OnDirClassifiedQuery; - public event EventInfoRequest OnEventInfoRequest; - public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime; - - public event MapItemRequest OnMapItemRequest; - - public event OfferCallingCard OnOfferCallingCard; - public event AcceptCallingCard OnAcceptCallingCard; - public event DeclineCallingCard OnDeclineCallingCard; - - public event SoundTrigger OnSoundTrigger; - - public event StartLure OnStartLure; - public event TeleportLureRequest OnTeleportLureRequest; - public event NetworkStats OnNetworkStatsUpdate; - - public event ClassifiedInfoRequest OnClassifiedInfoRequest; - public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; - public event ClassifiedDelete OnClassifiedDelete; - public event ClassifiedGodDelete OnClassifiedGodDelete; - - public event EventNotificationAddRequest OnEventNotificationAddRequest; - public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; - public event EventGodDelete OnEventGodDelete; - - public event ParcelDwellRequest OnParcelDwellRequest; - - public event UserInfoRequest OnUserInfoRequest; - public event UpdateUserInfo OnUpdateUserInfo; - - public event RetrieveInstantMessages OnRetrieveInstantMessages; - - public event PickDelete OnPickDelete; - public event PickGodDelete OnPickGodDelete; - public event PickInfoUpdate OnPickInfoUpdate; - public event AvatarNotesUpdate OnAvatarNotesUpdate; - - public event MuteListRequest OnMuteListRequest; - - public event AvatarInterestUpdate OnAvatarInterestUpdate; - - public event PlacesQuery OnPlacesQuery; - - public event FindAgentUpdate OnFindAgent; - public event TrackAgentUpdate OnTrackAgent; - public event NewUserReport OnUserReport; - public event SaveStateHandler OnSaveState; - public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest; - public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest; - public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest; - public event FreezeUserUpdate OnParcelFreezeUser; - public event EjectUserUpdate OnParcelEjectUser; - public event ParcelBuyPass OnParcelBuyPass; - public event ParcelGodMark OnParcelGodMark; - public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest; - public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; - public event SimWideDeletesDelegate OnSimWideDeletes; - public event SendPostcard OnSendPostcard; - public event ChangeInventoryItemFlags OnChangeInventoryItemFlags; - public event MuteListEntryUpdate OnUpdateMuteListEntry; - public event MuteListEntryRemove OnRemoveMuteListEntry; - public event GodlikeMessage onGodlikeMessage; - public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; - public event GenericCall2 OnUpdateThrottles; - public event AgentFOV OnAgentFOV; - -#pragma warning restore 67 - - /// - /// This agent's UUID - /// - private UUID m_agentId; - - public ISceneAgent SceneAgent { get; set; } - - public bool SupportObjectAnimations { get; set; } - - /// - /// The last caps seed url that this client was given. - /// - public string CapsSeedUrl; - - private Vector3 startPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 2); - - public virtual Vector3 StartPos - { - get { return startPos; } - set { } - } - - public float StartFar { get; set; } - - public virtual UUID AgentId - { - get { return m_agentId; } - } - - public UUID SessionId { get; set; } - - public UUID SecureSessionId { get; set; } - - public virtual string FirstName - { - get { return m_firstName; } - } - private string m_firstName; - - public virtual string LastName - { - get { return m_lastName; } - } - private string m_lastName; - - public virtual String Name - { - get { return FirstName + " " + LastName; } - } - - public int PingTimeMS { get { return 0; } } - - public bool IsActive - { - get { return true; } - set { } - } - - public bool IsLoggingOut { get; set; } - - public UUID ActiveGroupId - { - get { return UUID.Zero; } - set { } - } - - public string ActiveGroupName - { - get { return String.Empty; } - set { } - } - - public ulong ActiveGroupPowers - { - get { return 0; } - set { } - } - - public bool IsGroupMember(UUID groupID) - { - return false; - } - - public Dictionary GetGroupPowers() - { - return new Dictionary(); - } - - public void SetGroupPowers(Dictionary powers) { } - - public ulong GetGroupPowers(UUID groupID) - { - return 0; - } - - public virtual int NextAnimationSequenceNumber - { - get { return 1; } - set { } - } - - public IScene Scene - { - get { return m_scene; } - } - - public UUID ScopeId - { - get { return UUID.Zero; } - } - - public bool SendLogoutPacketWhenClosing - { - set { } - } - - private uint m_circuitCode; - - public uint CircuitCode - { - get { return m_circuitCode; } - set { m_circuitCode = value; } - } - - public IPEndPoint RemoteEndPoint - { - get { return new IPEndPoint(IPAddress.Loopback, (ushort)m_circuitCode); } - } - - public List SelectedObjects {get; private set;} - - /// - /// Constructor - /// - /// - /// - /// - public TestClient(AgentCircuitData agentData, Scene scene) - { - m_agentId = agentData.AgentID; - m_firstName = agentData.firstname; - m_lastName = agentData.lastname; - m_circuitCode = agentData.circuitcode; - m_scene = scene; - SessionId = agentData.SessionID; - SecureSessionId = agentData.SecureSessionID; - CapsSeedUrl = agentData.CapsPath; - - ReceivedKills = new List(); - ReceivedOfflineNotifications = new List(); - ReceivedOnlineNotifications = new List(); - ReceivedFriendshipTerminations = new List(); - - SentImageDataPackets = new List(); - SentImagePacketPackets = new List(); - SentImageNotInDatabasePackets = new List(); - } - - /// - /// Trigger chat coming from this connection. - /// - /// - /// - /// - public bool Chat(int channel, ChatTypeEnum type, string message) - { - ChatMessage handlerChatFromClient = OnChatFromClient; - - if (handlerChatFromClient != null) - { - OSChatMessage args = new OSChatMessage(); - args.Channel = channel; - args.From = Name; - args.Message = message; - args.Type = type; - - args.Scene = Scene; - args.Sender = this; - args.SenderUUID = AgentId; - - handlerChatFromClient(this, args); - } - - return true; - } - - /// - /// Attempt a teleport to the given region. - /// - /// - /// - /// - public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt) - { - OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); - } - - public void CompleteMovement() - { - if (OnCompleteMovementToRegion != null) - OnCompleteMovementToRegion(this, true); - } - - /// - /// Emulate sending an IM from the viewer to the simulator. - /// - /// - public void HandleImprovedInstantMessage(GridInstantMessage im) - { - ImprovedInstantMessage handlerInstantMessage = OnInstantMessage; - - if (handlerInstantMessage != null) - handlerInstantMessage(this, im); - } - - public virtual void ActivateGesture(UUID assetId, UUID gestureId) - { - } - - public virtual void SendWearables(AvatarWearable[] wearables, int serial) - { - } - - public virtual void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry, float hover) - { - } - - public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List cachedTextures) - { - - } - - public virtual void Kick(string message) - { - } - - public virtual void SendAvatarPickerReply(UUID QueryID, List users) - { - } - - public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) - { - } - - public virtual void SendKillObject(List localID) - { - ReceivedKills.AddRange(localID); - } - - public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) - { - } - - public virtual void SetChildAgentThrottle(byte[] throttle) - { - } - - public virtual void SetChildAgentThrottle(byte[] throttle, float factor) - { - } - - public void SetAgentThrottleSilent(int throttle, int setting) - { - } - - public int GetAgentThrottleSilent(int throttle) - { - return 0; - } - - public byte[] GetThrottlesPacked(float multiplier) - { - return Array.Empty(); - } - - public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) - { - } - - public virtual void SendChatMessage( - string message, byte type, Vector3 fromPos, string fromName, - UUID fromAgentID, UUID ownerID, byte source, byte audible) - { -// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId); - if (OnReceivedChatMessage != null) - OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); - } - - public void SendInstantMessage(GridInstantMessage im) - { - if (OnReceivedInstantMessage != null) - OnReceivedInstantMessage(im); - } - - public void SendGenericMessage(string method, UUID invoice, List message) - { - - } - - public void SendGenericMessage(string method, UUID invoice, List message) - { - - } - - public virtual bool CanSendLayerData() - { - return false; - } - - public virtual void SendLayerData() - { - } - - public void SendLayerData(int[] map) - { - } - - public virtual void SendWindData(int version, Vector2[] windSpeeds) { } - - public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) - { - if (OnReceivedMoveAgentIntoRegion != null) - OnReceivedMoveAgentIntoRegion(regInfo, pos, look); - } - - public virtual AgentCircuitData RequestClientInfo() - { - AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = AgentId; - agentData.SessionID = SessionId; - agentData.SecureSessionID = UUID.Zero; - agentData.circuitcode = m_circuitCode; - agentData.child = false; - agentData.firstname = m_firstName; - agentData.lastname = m_lastName; - - ICapabilitiesModule capsModule = m_scene.RequestModuleInterface(); - if (capsModule != null) - { - agentData.CapsPath = capsModule.GetCapsPath(m_agentId); - agentData.ChildrenCapSeeds = new Dictionary(capsModule.GetChildrenSeeds(m_agentId)); - } - - return agentData; - } - - public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) - { - if (OnTestClientInformClientOfNeighbour != null) - OnTestClientInformClientOfNeighbour(neighbourHandle, neighbourExternalEndPoint); - } - - public virtual void SendRegionTeleport( - ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, - uint locationID, uint flags, string capsURL) - { - m_log.DebugFormat( - "[TEST CLIENT]: Received SendRegionTeleport for {0} {1} on {2}", m_firstName, m_lastName, m_scene.Name); - - CapsSeedUrl = capsURL; - - if (OnTestClientSendRegionTeleport != null) - OnTestClientSendRegionTeleport( - regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); - } - - public virtual void SendTeleportFailed(string reason) - { - m_log.DebugFormat( - "[TEST CLIENT]: Teleport failed for {0} {1} on {2} with reason {3}", - m_firstName, m_lastName, m_scene.Name, reason); - } - - public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, - IPEndPoint newRegionExternalEndPoint, string capsURL) - { - // This is supposed to send a packet to the client telling it's ready to start region crossing. - // Instead I will just signal I'm ready, mimicking the communication behavior. - // It's ugly, but avoids needless communication setup. This is used in ScenePresenceTests.cs. - // Arthur V. - - wh.Set(); - } - - public virtual void SendMapBlock(List mapBlocks, uint flag) - { - } - - public virtual void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags) - { - } - - public virtual void SendTeleportStart(uint flags) - { - } - - public void SendTeleportProgress(uint flags, string message) - { - } - - public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item) - { - } - - public virtual void SendPayPrice(UUID objectID, int[] payPrice) - { - } - - public virtual void SendCoarseLocationUpdate(List users, List CoarseLocations) - { - } - - public virtual void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels) - { - } - - public void SendEntityFullUpdateImmediate(ISceneEntity ent) - { - } - - public void SendEntityTerseUpdateImmediate(ISceneEntity ent) - { - } - - public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) - { - if (OnReceivedEntityUpdate != null) - OnReceivedEntityUpdate(entity, updateFlags); - } - - public void ReprioritizeUpdates() - { - } - - public void FlushPrimUpdates() - { - } - - public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, - List items, - List folders, - int version, - int descendents, - bool fetchFolders, - bool fetchItems) - { - } - - public void SendInventoryItemDetails(InventoryItemBase[] items) - { - } - - public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackID) - { - } - - public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) - { - } - - public void SendRemoveInventoryItem(UUID itemID) - { - } - - public void SendRemoveInventoryItems(UUID[] items) - { - } - - public void SendBulkUpdateInventory(InventoryNodeBase node, UUID? transactionID = null) - { - } - - public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items) - { - } - - public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) - { - } - - public virtual void SendTaskInventory(UUID taskID, short serial, byte[] fileName) - { - } - - public virtual void SendXferPacket(ulong xferID, uint packet, - byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) - { - } - - public virtual void SendAbortXferPacket(ulong xferID) - { - - } - - public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, - int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, - int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, - int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) - { - } - - public virtual void SendNameReply(UUID profileId, string firstname, string lastname) - { - } - - public virtual void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID) - { - } - - public virtual void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, - byte flags) - { - } - - public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) - { - } - - public void SendAttachedSoundGainChange(UUID objectID, float gain) - { - - } - - public void SendAlertMessage(string message) - { - } - - public void SendAgentAlertMessage(string message, bool modal) - { - } - - public void SendAlertMessage(string message, string info) - { - } - - public void SendSystemAlertMessage(string message) - { - } - - public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, - string url) - { - } - - public virtual void SendRegionHandshake() - { - if (OnRegionHandShakeReply != null) - { - OnRegionHandShakeReply(this); - } - } - - public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) - { - } - - public void SendConfirmXfer(ulong xferID, uint PacketID) - { - } - - public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName) - { - } - - public void SendInitiateDownload(string simFileName, string clientFileName) - { - } - - public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) - { - ImageDataPacket im = new ImageDataPacket(); - im.Header.Reliable = false; - im.ImageID.Packets = numParts; - im.ImageID.ID = ImageUUID; - - if (ImageSize > 0) - im.ImageID.Size = ImageSize; - - im.ImageData.Data = ImageData; - im.ImageID.Codec = imageCodec; - im.Header.Zerocoded = true; - SentImageDataPackets.Add(im); - } - - public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) - { - ImagePacketPacket im = new ImagePacketPacket(); - im.Header.Reliable = false; - im.ImageID.Packet = partNumber; - im.ImageID.ID = imageUuid; - im.ImageData.Data = imageData; - SentImagePacketPackets.Add(im); - } - - public void SendImageNotFound(UUID imageid) - { - ImageNotInDatabasePacket p = new ImageNotInDatabasePacket(); - p.ImageID.ID = imageid; - - SentImageNotInDatabasePackets.Add(p); - } - - public void SendShutdownConnectionNotice() - { - } - - public void SendSimStats(SimStats stats) - { - } - - public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags) - { - } - - public void SendObjectPropertiesReply(ISceneEntity entity) - { - } - - public void SendAgentOffline(UUID[] agentIDs) - { - ReceivedOfflineNotifications.AddRange(agentIDs); - } - - public void SendAgentOnline(UUID[] agentIDs) - { - ReceivedOnlineNotifications.AddRange(agentIDs); - } - - public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY) - { - } - - public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, - Quaternion SitOrientation, bool autopilot, - Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) - { - } - - public void SendAdminResponse(UUID Token, uint AdminLevel) - { - } - - public void SendGroupMembership(GroupMembershipData[] GroupMembership) - { - } - - public void SendViewerTime(Vector3 sunDir, float sunphase) - { - } - - public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) - { - } - - public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, - string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, - UUID partnerID) - { - } - - public int DebugPacketLevel { get; set; } - - public void InPacket(object NewPack) - { - } - - public void ProcessInPacket(Packet NewPack) - { - } - - /// - /// This is a TestClient only method to do shutdown tasks that are normally carried out by LLUDPServer.RemoveClient() - /// - public void Logout() - { - // We must set this here so that the presence is removed from the PresenceService by the PresenceDetector - IsLoggingOut = true; - - Close(); - } - - public void Close() - { - Close(true, false); - } - - public void Close(bool sendStop, bool force) - { - // Fire the callback for this connection closing - // This is necesary to get the presence detector to notice that a client has logged out. - if (OnConnectionClosed != null) - OnConnectionClosed(this); - - m_scene.RemoveClient(AgentId, true); - } - - public void Start() - { - throw new NotImplementedException(); - } - - public void Stop() - { - } - - public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) - { - - } - public void SendLogoutPacket() - { - } - - public void Terminate() - { - } - - public ClientInfo GetClientInfo() - { - return null; - } - - public void SetClientInfo(ClientInfo info) - { - } - - public void SendScriptQuestion(UUID objectID, string taskName, string ownerName, UUID itemID, int question) - { - } - public void SendHealth(float health) - { - } - - public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List SpawnPoint) - { - } - - public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID) - { - } - - public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID) - { - } - - public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) - { - } - - public void SendEstateCovenantInformation(UUID covenant) - { - } - - public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner) - { - } - - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) - { - } - - public void SendLandAccessListData(List accessList, uint accessFlag, int localLandID) - { - } - - public void SendForceClientSelectObjects(List objectIDs) - { - } - - public void SendCameraConstraint(Vector4 ConstraintPlane) - { - } - - public void SendLandObjectOwners(LandData land, List groups, Dictionary ownersAndCount) - { - } - - public void SendLandParcelOverlay(byte[] data, int sequence_id) - { - } - - public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time) - { - } - - public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, - string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop) - { - } - - public void SendGroupNameReply(UUID groupLLUID, string GroupName) - { - } - - public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) - { - } - - public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) - { - } - - public void SendAsset(AssetRequestToClient req) - { - } - - public void SendTexture(AssetBase TextureAsset) - { - - } - - public void SendSetFollowCamProperties (UUID objectID, SortedDictionary parameters) - { - } - - public void SendClearFollowCamProperties (UUID objectID) - { - } - - public void SendRegionHandle (UUID regoinID, ulong handle) - { - } - - public void SendParcelInfo (RegionInfo info, LandData land, UUID parcelID, uint x, uint y) - { - } - - public void SetClientOption(string option, string value) - { - } - - public string GetClientOption(string option) - { - return string.Empty; - } - - public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) - { - } - - public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) - { - } - - public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) - { - } - - public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) - { - } - - public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) - { - } - - public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) - { - } - - public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) - { - } - - public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) - { - } - - public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) - { - } - - public void SendEventInfoReply (EventData info) - { - } - - public void SendOfferCallingCard (UUID destID, UUID transactionID) - { - } - - public void SendAcceptCallingCard (UUID transactionID) - { - } - - public void SendDeclineCallingCard (UUID transactionID) - { - } - - public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) - { - } - - public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data) - { - } - - public void SendJoinGroupReply(UUID groupID, bool success) - { - } - - public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool succss) - { - } - - public void SendLeaveGroupReply(UUID groupID, bool success) - { - } - - public void SendTerminateFriend(UUID exFriendID) - { - ReceivedFriendshipTerminations.Add(exFriendID); - } - - public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) - { - //throw new NotImplementedException(); - return false; - } - - public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) - { - } - - public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) - { - } - - public void SendAgentDropGroup(UUID groupID) - { - } - - public void SendAvatarNotesReply(UUID targetID, string text) - { - } - - public void SendAvatarPicksReply(UUID targetID, Dictionary picks) - { - } - - public void SendAvatarClassifiedReply(UUID targetID, Dictionary classifieds) - { - } - - public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) - { - } - - public void SendUserInfoReply(bool imViaEmail, bool visible, string email) - { - } - - public void SendCreateGroupReply(UUID groupID, bool success, string message) - { - } - - public void RefreshGroupMembership() - { - } - - public void UpdateGroupMembership(GroupMembershipData[] data) - { - } - - public void GroupMembershipRemove(UUID GroupID) - { - } - - public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) - { - } - - public void SendUseCachedMuteList() - { - } - - public void SendEmpytMuteList() - { - } - - public void SendMuteListUpdate(string filename) - { - } - - public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) - { - } - - public bool TryGet(out T iface) - { - iface = default(T); - return false; - } - - public T Get() - { - return default(T); - } - - public void Disconnect(string reason) - { - } - - public void Disconnect() - { - } - - public void SendRebakeAvatarTextures(UUID textureID) - { - if (OnReceivedSendRebakeAvatarTextures != null) - OnReceivedSendRebakeAvatarTextures(textureID); - } - - public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) - { - } - - public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt) - { - } - - public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier) - { - } - - public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt) - { - } - - public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes) - { - } - - public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals) - { - } - - public void SendChangeUserRights(UUID agentID, UUID friendID, int rights) - { - } - - public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId) - { - } - - public void SendAgentTerseUpdate(ISceneEntity presence) - { - } - - public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) - { - } - - public void SendSelectedPartsProprieties(List parts) - { - } - - public void SendPartPhysicsProprieties(ISceneEntity entity) - { - } - - public uint GetViewerCaps() - { - return 0x1000; - } - - } -} diff --git a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs b/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs deleted file mode 100644 index 2cf8cf6b126..00000000000 --- a/OpenSim/Tests/Common/Mock/TestEventQueueGetModule.cs +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Reflection; -using System.Text; -using System.Threading; -using log4net; -using Nini.Config; -using Mono.Addins; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Region.ClientStack.Linden; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Tests.Common -{ - public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule - { - public class Event - { - public string Name { get; set; } - public object[] Args { get; set; } - - public Event(string name, object[] args) - { - name = Name; - args = Args; - } - } - - public Dictionary> Events { get; set; } - - public void Initialise(IConfigSource source) {} - - public void Close() {} - - public void AddRegion(Scene scene) - { - Events = new Dictionary>(); - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion (Scene scene) {} - - public void RegionLoaded (Scene scene) {} - - public string Name { get { return "TestEventQueueGetModule"; } } - - public Type ReplaceableInterface { get { return null; } } - - private void AddEvent(UUID avatarID, string name, params object[] args) - { - Console.WriteLine("Adding event {0} for {1}", name, avatarID); - - List avEvents; - - if (!Events.ContainsKey(avatarID)) - { - avEvents = new List(); - Events[avatarID] = avEvents; - } - else - { - avEvents = Events[avatarID]; - } - - avEvents.Add(new Event(name, args)); - } - - public void ClearEvents() - { - if (Events != null) - Events.Clear(); - } - - public bool Enqueue(string o, UUID avatarID) - { - AddEvent(avatarID, "Enqueue", o); - return true; - } - public bool Enqueue(byte[] o, UUID avatarID) - { - return true; - } - public bool Enqueue(OSD o, UUID avatarID) - { - return true; - } - public bool Enqueue(osUTF8 o, UUID avatarID) - { - return true; - } - public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) - { - AddEvent(avatarID, "EnableSimulator", handle); - } - - public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath, - ulong regionHandle, int regionSizeX, int regionSizeY) - { - AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath); - } - - public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, - uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY) - { - AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL); - } - - public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, - string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) - { - AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID); - } - - public void ChatterboxInvitation( - UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName, - byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl, - UUID transactionID, bool fromGroup, byte[] binaryBucket) - { - AddEvent( - toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, - timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket); - } - - public void ChatterBoxSessionStartReply(UUID sessionID, string sessionName, int type, - bool voiceEnabled, bool voiceModerated, UUID tmpSessionID, - bool sucess, string error, - UUID toAgent) - { - AddEvent(toAgent, "ChatterBoxSessionStartReply", sessionID, sessionName, type, - voiceEnabled, voiceModerated, tmpSessionID, - sucess, error); - } - - public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID toAgent, List updates) - { - AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, toAgent, updates); - } - - public void ChatterBoxForceClose (UUID toAgent, UUID sessionID, string reason) - { - AddEvent(toAgent, "ForceCloseChatterBoxSession", sessionID, reason); - } - - public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) - { - AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage); - } - - public void GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) - { - AddEvent(receiverAgent, "AgentGroupDataUpdate", data); - } - - public void ScriptRunningEvent (UUID objectID, UUID itemID, bool running, UUID avatarID) - { - Console.WriteLine("ONE"); - throw new System.NotImplementedException (); - } - - public byte[] BuildEvent(string eventName, OSD eventBody) - { - Console.WriteLine("TWOoo"); - throw new System.NotImplementedException(); - } - - public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID) - { - AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod); - } - - public void WindlightRefreshEvent(int interpolate, UUID avatarID) - { - } - - public void SendBulkUpdateInventoryItem(InventoryItemBase item, UUID avatarID, UUID? transationID = null) - { - } - - public osUTF8 StartEvent(string eventName) - { - return null; - } - - public osUTF8 StartEvent(string eventName, int cap) - { - return null; - } - - public byte[] EndEventToBytes(osUTF8 sb) - { - return Array.Empty(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs deleted file mode 100644 index 8e2d8e6c989..00000000000 --- a/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs +++ /dev/null @@ -1,339 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using OpenMetaverse; -using OpenSim.Data; - -namespace OpenSim.Tests.Common.Mock -{ - public class TestGroupsDataPlugin : IGroupsData - { - class CompositeKey - { - private readonly string _key; - public string Key - { - get { return _key; } - } - - public CompositeKey(UUID _k1, string _k2) - { - _key = _k1.ToString() + _k2; - } - - public CompositeKey(UUID _k1, string _k2, string _k3) - { - _key = _k1.ToString() + _k2 + _k3; - } - - public override bool Equals(object obj) - { - if (obj is CompositeKey) - { - return Key == ((CompositeKey)obj).Key; - } - return false; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - public override string ToString() - { - return Key; - } - } - - private Dictionary m_Groups; - private Dictionary m_Membership; - private Dictionary m_Roles; - private Dictionary m_RoleMembership; - private Dictionary m_Invites; - private Dictionary m_Notices; - private Dictionary m_Principals; - - public TestGroupsDataPlugin(string connectionString, string realm) - { - m_Groups = new Dictionary(); - m_Membership = new Dictionary(); - m_Roles = new Dictionary(); - m_RoleMembership = new Dictionary(); - m_Invites = new Dictionary(); - m_Notices = new Dictionary(); - m_Principals = new Dictionary(); - } - - #region groups table - public bool StoreGroup(GroupData data) - { - return false; - } - - public GroupData RetrieveGroup(UUID groupID) - { - if (m_Groups.ContainsKey(groupID)) - return m_Groups[groupID]; - - return null; - } - - public GroupData RetrieveGroup(string name) - { - return m_Groups.Values.First(g => g.Data.ContainsKey("Name") && g.Data["Name"] == name); - } - - public GroupData[] RetrieveGroups(string pattern) - { - if (string.IsNullOrEmpty(pattern)) - pattern = "1"; - - IEnumerable groups = m_Groups.Values.Where(g => g.Data.ContainsKey("Name") && (g.Data["Name"].StartsWith(pattern) || g.Data["Name"].EndsWith(pattern))); - - return (groups != null) ? groups.ToArray() : new GroupData[0]; - } - - public bool DeleteGroup(UUID groupID) - { - return m_Groups.Remove(groupID); - } - - public int GroupsCount() - { - return m_Groups.Count; - } - #endregion - - #region membership table - public MembershipData RetrieveMember(UUID groupID, string pricipalID) - { - CompositeKey dkey = new CompositeKey(groupID, pricipalID); - if (m_Membership.ContainsKey(dkey)) - return m_Membership[dkey]; - - return null; - } - - public MembershipData[] RetrieveMembers(UUID groupID) - { - IEnumerable keys = m_Membership.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); - return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray(); - } - - public MembershipData[] RetrieveMemberships(string principalID) - { - IEnumerable keys = m_Membership.Keys.Where(k => k.Key.EndsWith(principalID.ToString())); - return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray(); - } - - public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) - { - return RetrieveMemberships(principalID); - } - - public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) - { - CompositeKey dkey = new CompositeKey(groupID, principalID); - if (m_Membership.ContainsKey(dkey)) - return m_Membership[dkey]; - return null; - } - - public bool StoreMember(MembershipData data) - { - CompositeKey dkey = new CompositeKey(data.GroupID, data.PrincipalID); - m_Membership[dkey] = data; - return true; - } - - public bool DeleteMember(UUID groupID, string principalID) - { - CompositeKey dkey = new CompositeKey(groupID, principalID); - if (m_Membership.ContainsKey(dkey)) - return m_Membership.Remove(dkey); - - return false; - } - - public int MemberCount(UUID groupID) - { - return m_Membership.Count; - } - #endregion - - #region roles table - public bool StoreRole(RoleData data) - { - CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString()); - m_Roles[dkey] = data; - return true; - } - - public RoleData RetrieveRole(UUID groupID, UUID roleID) - { - CompositeKey dkey = new CompositeKey(groupID, roleID.ToString()); - if (m_Roles.ContainsKey(dkey)) - return m_Roles[dkey]; - - return null; - } - - public RoleData[] RetrieveRoles(UUID groupID) - { - IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); - return keys.Where(m_Roles.ContainsKey).Select(x => m_Roles[x]).ToArray(); - } - - public bool DeleteRole(UUID groupID, UUID roleID) - { - CompositeKey dkey = new CompositeKey(groupID, roleID.ToString()); - if (m_Roles.ContainsKey(dkey)) - return m_Roles.Remove(dkey); - - return false; - } - - public int RoleCount(UUID groupID) - { - return m_Roles.Count; - } - #endregion - - #region rolememberhip table - public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) - { - IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString())); - return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); - } - - public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) - { - IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString() + roleID.ToString())); - return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); - } - - public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) - { - IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)); - return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray(); - } - - public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) - { - CompositeKey dkey = new CompositeKey(groupID, roleID.ToString(), principalID); - if (m_RoleMembership.ContainsKey(dkey)) - return m_RoleMembership[dkey]; - - return null; - } - - public int RoleMemberCount(UUID groupID, UUID roleID) - { - return m_RoleMembership.Count; - } - - public bool StoreRoleMember(RoleMembershipData data) - { - CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID); - m_RoleMembership[dkey] = data; - return true; - } - - public bool DeleteRoleMember(RoleMembershipData data) - { - CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID); - if (m_RoleMembership.ContainsKey(dkey)) - return m_RoleMembership.Remove(dkey); - - return false; - } - - public bool DeleteMemberAllRoles(UUID groupID, string principalID) - { - List keys = m_RoleMembership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)).ToList(); - foreach (CompositeKey k in keys) - m_RoleMembership.Remove(k); - return true; - } - #endregion - - #region principals table - public bool StorePrincipal(PrincipalData data) - { - m_Principals[data.PrincipalID] = data; - return true; - } - - public PrincipalData RetrievePrincipal(string principalID) - { - if (m_Principals.ContainsKey(principalID)) - return m_Principals[principalID]; - - return null; - } - - public bool DeletePrincipal(string principalID) - { - if (m_Principals.ContainsKey(principalID)) - return m_Principals.Remove(principalID); - return false; - } - #endregion - - #region invites table - public bool StoreInvitation(InvitationData data) - { - return false; - } - - public InvitationData RetrieveInvitation(UUID inviteID) - { - return null; - } - - public InvitationData RetrieveInvitation(UUID groupID, string principalID) - { - return null; - } - - public bool DeleteInvite(UUID inviteID) - { - return false; - } - - public void DeleteOldInvites() - { - } - #endregion - - #region notices table - public bool StoreNotice(NoticeData data) - { - return false; - } - - public NoticeData RetrieveNotice(UUID noticeID) - { - return null; - } - - public NoticeData[] RetrieveNotices(UUID groupID) - { - return new NoticeData[0]; - } - - public bool DeleteNotice(UUID noticeID) - { - return false; - } - - public void DeleteOldNotices() - { - } - #endregion - - } -} diff --git a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs b/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs deleted file mode 100644 index 72938304921..00000000000 --- a/OpenSim/Tests/Common/Mock/TestHttpClientContext.cs +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Net.Sockets; -using System.Text; -using OSHttpServer; -using OpenSim.Framework; - -namespace OpenSim.Tests.Common -{ -/* - public class TestHttpClientContext: IHttpClientContext - { - /// - /// Bodies of responses from the server. - /// - public string ResponseBody - { - get { return Encoding.UTF8.GetString(m_responseStream.ToArray()); } - } - - public Byte[] ResponseBodyBytes - { - get{ return m_responseStream.ToArray(); } - } - - private MemoryStream m_responseStream = new MemoryStream(); - - public bool IsSecured { get; set; } - - public bool Secured - { - get { return IsSecured; } - set { IsSecured = value; } - } - - public TestHttpClientContext(bool secured) - { - Secured = secured; - } - - public void Disconnect(SocketError error) - { -// Console.WriteLine("TestHttpClientContext.Disconnect Received disconnect with status {0}", error); - } - - public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {Console.WriteLine("x");} - public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {Console.WriteLine("xx");} - public void Respond(string body) { Console.WriteLine("xxx");} - - public void Send(byte[] buffer) - { - // Getting header data here -// Console.WriteLine("xxxx: Got {0}", Encoding.UTF8.GetString(buffer)); - } - - public void Send(byte[] buffer, int offset, int size) - { -// Util.PrintCallStack(); -// -// Console.WriteLine( -// "TestHttpClientContext.Send(byte[], int, int) got offset={0}, size={1}, buffer={2}", -// offset, size, Encoding.UTF8.GetString(buffer)); - - m_responseStream.Write(buffer, offset, size); - } - - public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {Console.WriteLine("xxxxxx");} - public void Close() { } - public bool EndWhenDone { get { return false;} set { return;}} - - public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing() - { - return new HTTPNetworkContext(); - } - - public event EventHandler Disconnected = delegate { }; - /// - /// A request have been received in the context. - /// - public event EventHandler RequestReceived = delegate { }; - } -*/ -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestHttpRequest.cs deleted file mode 100644 index b69c70db5cd..00000000000 --- a/OpenSim/Tests/Common/Mock/TestHttpRequest.cs +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Specialized; -using System.IO; -using OSHttpServer; - -namespace OpenSim.Tests.Common -{ -/* - public class TestHttpRequest: IHttpRequest - { - private string _uriPath; - public bool BodyIsComplete - { - get { return true; } - } - public string[] AcceptTypes - { - get {return _acceptTypes; } - } - private string[] _acceptTypes; - public Stream Body - { - get { return _body; } - set { _body = value;} - } - private Stream _body; - public ConnectionType Connection - { - get { return _connection; } - set { _connection = value; } - } - private ConnectionType _connection; - public int ContentLength - { - get { return _contentLength; } - set { _contentLength = value; } - } - private int _contentLength; - public NameValueCollection Headers - { - get { return _headers; } - } - private NameValueCollection _headers = new NameValueCollection(); - - public string HttpVersion { get; set; } - - public string Method - { - get { return _method; } - set { _method = value; } - } - private string _method = null; - public HttpInput QueryString - { - get { return _queryString; } - } - private HttpInput _queryString = null; - public Uri Uri - { - get { return _uri; } - set { _uri = value; } - } - private Uri _uri = null; - public string[] UriParts - { - get { return _uri.Segments; } - } - public HttpParam Param - { - get { return null; } - } - public HttpForm Form - { - get { return null; } - } - public bool IsAjax - { - get { return false; } - } - public RequestCookies Cookies - { - get { return null; } - } - - public TestHttpRequest() - { - HttpVersion = "HTTP/1.1"; - } - - public TestHttpRequest(string contentEncoding, string contentType, string userAgent, - string remoteAddr, string remotePort, string[] acceptTypes, - ConnectionType connectionType, int contentLength, Uri uri) : base() - { - _headers["content-encoding"] = contentEncoding; - _headers["content-type"] = contentType; - _headers["user-agent"] = userAgent; - _headers["remote_addr"] = remoteAddr; - _headers["remote_port"] = remotePort; - - _acceptTypes = acceptTypes; - _connection = connectionType; - _contentLength = contentLength; - _uri = uri; - } - - public void DecodeBody(FormDecoderProvider providers) {} - public void SetCookies(RequestCookies cookies) {} - public void AddHeader(string name, string value) - { - _headers.Add(name, value); - } - public int AddToBody(byte[] bytes, int offset, int length) - { - return 0; - } - public void Clear() {} - - public object Clone() - { - TestHttpRequest clone = new TestHttpRequest(); - clone._acceptTypes = _acceptTypes; - clone._connection = _connection; - clone._contentLength = _contentLength; - clone._uri = _uri; - clone._headers = new NameValueCollection(_headers); - - return clone; - } - public IHttpResponse CreateResponse(IHttpClientContext context) - { - return new HttpResponse(context, this); - } - /// - /// Path and query (will be merged with the host header) and put in Uri - /// - /// - public string UriPath - { - get { return _uriPath; } - set - { - _uriPath = value; - - } - } - } -*/ -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestHttpResponse.cs deleted file mode 100644 index f6f789819c9..00000000000 --- a/OpenSim/Tests/Common/Mock/TestHttpResponse.cs +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using System.Net; -using System.Text; -using OSHttpServer; - -namespace OpenSim.Tests.Common -{ -/* - public class TestHttpResponse: IHttpResponse - { - public Stream Body - { - get { return _body; } - - set { _body = value; } - } - private Stream _body; - - public string ProtocolVersion - { - get { return _protocolVersion; } - set { _protocolVersion = value; } - } - private string _protocolVersion; - - public bool Chunked - { - get { return _chunked; } - - set { _chunked = value; } - } - private bool _chunked; - - public ConnectionType Connection - { - get { return _connection; } - - set { _connection = value; } - } - private ConnectionType _connection; - - public Encoding Encoding - { - get { return _encoding; } - - set { _encoding = value; } - } - private Encoding _encoding; - - public int KeepAlive - { - get { return _keepAlive; } - - set { _keepAlive = value; } - } - private int _keepAlive; - - public HttpStatusCode Status - { - get { return _status; } - - set { _status = value; } - } - private HttpStatusCode _status; - - public string Reason - { - get { return _reason; } - - set { _reason = value; } - } - private string _reason; - - public long ContentLength - { - get { return _contentLength; } - - set { _contentLength = value; } - } - private long _contentLength; - - public string ContentType - { - get { return _contentType; } - - set { _contentType = value; } - } - private string _contentType; - - public bool HeadersSent - { - get { return _headersSent; } - } - private bool _headersSent; - - public bool Sent - { - get { return _sent; } - } - private bool _sent; - - public ResponseCookies Cookies - { - get { return _cookies; } - } - private ResponseCookies _cookies = null; - - public TestHttpResponse() - { - _headersSent = false; - _sent = false; - } - - public void AddHeader(string name, string value) {} - - public void Send() - { - if (!_headersSent) SendHeaders(); - if (_sent) throw new InvalidOperationException("stuff already sent"); - _sent = true; - } - - public void SendBody(byte[] buffer, int offset, int count) - { - if (!_headersSent) SendHeaders(); - _sent = true; - } - - public void SendBody(byte[] buffer) - { - if (!_headersSent) SendHeaders(); - _sent = true; - } - - public void SendHeaders() - { - if (_headersSent) throw new InvalidOperationException("headers already sent"); - _headersSent = true; - } - - public void Redirect(Uri uri) {} - public void Redirect(string url) {} - } -*/ -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs deleted file mode 100644 index 04cda547bd1..00000000000 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Data; - -namespace OpenSim.Tests.Common -{ - /// - /// In memory inventory data plugin for test purposes. Could be another dll when properly filled out and when the - /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit - /// tests are single threaded. - /// - public class TestInventoryDataPlugin : IInventoryDataPlugin - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Inventory folders - /// - private Dictionary m_folders = new Dictionary(); - - //// - /// Inventory items - /// - private Dictionary m_items = new Dictionary(); - - /// - /// User root folders - /// - private Dictionary m_rootFolders = new Dictionary(); - - public string Version { get { return "0"; } } - public string Name { get { return "TestInventoryDataPlugin"; } } - - public void Initialise() {} - public void Initialise(string connect) {} - public void Dispose() {} - - public List getFolderHierarchy(UUID parentID) - { - List folders = new List(); - - foreach (InventoryFolderBase folder in m_folders.Values) - { - if (folder.ParentID == parentID) - { - folders.AddRange(getFolderHierarchy(folder.ID)); - folders.Add(folder); - } - } - - return folders; - } - - public List getInventoryInFolder(UUID folderID) - { -// InventoryFolderBase folder = m_folders[folderID]; - -// m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID); - - List items = new List(); - - foreach (InventoryItemBase item in m_items.Values) - { - if (item.Folder == folderID) - { -// m_log.DebugFormat("[MOCK INV DB]: getInventoryInFolder() adding item {0}", item.Name); - items.Add(item); - } - } - - return items; - } - - public List getUserRootFolders(UUID user) { return null; } - - public InventoryFolderBase getUserRootFolder(UUID user) - { -// m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); - - InventoryFolderBase folder = null; - m_rootFolders.TryGetValue(user, out folder); - - return folder; - } - - public List getInventoryFolders(UUID parentID) - { -// InventoryFolderBase parentFolder = m_folders[parentID]; - -// m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID); - - List folders = new List(); - - foreach (InventoryFolderBase folder in m_folders.Values) - { - if (folder.ParentID == parentID) - { -// m_log.DebugFormat( -// "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", -// folder.Name, folder.ID, parentFolder.Name, parentFolder.ID); - - folders.Add(folder); - } - } - - return folders; - } - - public InventoryFolderBase getInventoryFolder(UUID folderId) - { - InventoryFolderBase folder = null; - m_folders.TryGetValue(folderId, out folder); - - return folder; - } - - public InventoryFolderBase queryInventoryFolder(UUID folderID) - { - return getInventoryFolder(folderID); - } - - public void addInventoryFolder(InventoryFolderBase folder) - { -// m_log.DebugFormat( -// "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", -// folder.Name, folder.ID, (AssetType)folder.Type); - - m_folders[folder.ID] = folder; - - if (folder.ParentID.IsZero()) - { -// m_log.DebugFormat( -// "[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner); - m_rootFolders[folder.Owner] = folder; - } - } - - public void updateInventoryFolder(InventoryFolderBase folder) - { - m_folders[folder.ID] = folder; - } - - public void moveInventoryFolder(InventoryFolderBase folder) - { - // Simple replace - updateInventoryFolder(folder); - } - - public void deleteInventoryFolder(UUID folderId) - { - if (m_folders.ContainsKey(folderId)) - m_folders.Remove(folderId); - } - - public void addInventoryItem(InventoryItemBase item) - { - InventoryFolderBase folder = m_folders[item.Folder]; - -// m_log.DebugFormat( -// "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); - - m_items[item.ID] = item; - } - - public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } - - public void deleteInventoryItem(UUID itemId) - { - if (m_items.ContainsKey(itemId)) - m_items.Remove(itemId); - } - - public InventoryItemBase getInventoryItem(UUID itemId) - { - if (m_items.ContainsKey(itemId)) - return m_items[itemId]; - else - return null; - } - - public InventoryItemBase queryInventoryItem(UUID item) - { - return null; - } - - public List fetchActiveGestures(UUID avatarID) { return null; } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs deleted file mode 100644 index d32d1b5510c..00000000000 --- a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Net.Sockets; -using Nini.Config; -using OpenMetaverse.Packets; -using OpenSim.Framework; -using OpenSim.Region.ClientStack.LindenUDP; - -namespace OpenSim.Tests.Common -{ - /// - /// This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data. - /// - public class TestLLUDPServer : LLUDPServer - { - public List PacketsSent { get; private set; } - - public TestLLUDPServer(IPAddress listenIP, uint port, int proxyPortOffsetParm, IConfigSource configSource, AgentCircuitManager circuitManager) - : base(listenIP, port, proxyPortOffsetParm, configSource, circuitManager) - { - PacketsSent = new List(); - } - - public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack) - { - PacketsSent.Add(ack); - } - - public override void SendPacket( - LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) - { - PacketsSent.Add(packet); - } - - public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing) - { - m_resendUnacked = resendUnacked; - m_sendAcks = sendAcks; - m_sendPing = sendPing; - - ClientOutgoingPacketHandler(client); - } - -//// /// -//// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive -//// /// -//// protected Queue m_chunksToLoad = new Queue(); -// -//// protected override void BeginReceive() -//// { -//// if (m_chunksToLoad.Count > 0 && m_chunksToLoad.Peek().BeginReceiveException) -//// { -//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); -//// reusedEpSender = tuple.Sender; -//// throw new SocketException(); -//// } -//// } -// -//// protected override bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) -//// { -//// numBytes = 0; -//// -//// //m_log.Debug("Queue size " + m_chunksToLoad.Count); -//// -//// if (m_chunksToLoad.Count <= 0) -//// return false; -//// -//// ChunkSenderTuple tuple = m_chunksToLoad.Dequeue(); -//// RecvBuffer = tuple.Data; -//// numBytes = tuple.Data.Length; -//// epSender = tuple.Sender; -//// -//// return true; -//// } -// -//// public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) -//// { -//// // Don't do anything just yet -//// } -// -// /// -// /// Signal that this chunk should throw an exception on Socket.BeginReceive() -// /// -// /// -// public void LoadReceiveWithBeginException(EndPoint epSender) -// { -// ChunkSenderTuple tuple = new ChunkSenderTuple(epSender); -// tuple.BeginReceiveException = true; -// m_chunksToLoad.Enqueue(tuple); -// } -// -// /// -// /// Load some data to be received by the LLUDPServer on the next receive call -// /// -// /// -// /// -// public void LoadReceive(byte[] data, EndPoint epSender) -// { -// m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); -// } -// -// /// -// /// Load a packet to be received by the LLUDPServer on the next receive call -// /// -// /// -// public void LoadReceive(Packet packet, EndPoint epSender) -// { -// LoadReceive(packet.ToBytes(), epSender); -// } -// -// /// -// /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send -// /// -// /// -// public void ReceiveData(IAsyncResult result) -// { -// // Doesn't work the same way anymore -//// while (m_chunksToLoad.Count > 0) -//// OnReceivedData(result); -// } - } - - /// - /// Record the data and sender tuple - /// - public class ChunkSenderTuple - { - public byte[] Data; - public EndPoint Sender; - public bool BeginReceiveException; - - public ChunkSenderTuple(byte[] data, EndPoint sender) - { - Data = data; - Sender = sender; - } - - public ChunkSenderTuple(EndPoint sender) - { - Sender = sender; - } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs deleted file mode 100644 index 38a4a2a476d..00000000000 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.World.Land; - -namespace OpenSim.Tests.Common -{ - /// - /// Land channel for test purposes - /// - public class TestLandChannel : ILandChannel - { - private Scene m_scene; - private List m_parcels; - - public float BanLineSafeHeight { get { return 100f; } } - - public TestLandChannel(Scene scene) - { - m_scene = scene; - m_parcels = new List(); - SetupDefaultParcel(); - } - - private void SetupDefaultParcel() - { - ILandObject obj = new LandObject(UUID.Zero, false, m_scene); - obj.LandData.Name = "Your Parcel"; - m_parcels.Add(obj); - } - - public List ParcelsNearPoint(Vector3 position) - { - return new List(); - } - - public List AllParcels() - { - return m_parcels; - } - - public void Clear(bool setupDefaultParcel) - { - m_parcels.Clear(); - - if (setupDefaultParcel) - SetupDefaultParcel(); - } - - protected ILandObject GetNoLand() - { - ILandObject obj = new LandObject(UUID.Zero, false, m_scene); - obj.LandData.Name = "NO LAND"; - return obj; - } - - public ILandObject GetLandObject(Vector3 position) - { - return GetLandObject(position.X, position.Y); - } - - public ILandObject GetLandObject(int x, int y) - { - return GetNoLand(); - } - - public ILandObject GetLandObjectClippedXY(float x, float y) - { - return GetNoLand(); - } - - public ILandObject GetLandObject(int localID) - { - return GetNoLand(); - } - - public ILandObject GetLandObject(UUID ID) - { - return GetNoLand(); - } - - public ILandObject GetLandObject(float x, float y) - { - return GetNoLand(); - } - - public bool IsLandPrimCountTainted() { return false; } - public bool IsForcefulBansAllowed() { return false; } - public void UpdateLandObject(int localID, LandData data) {} - public void SendParcelsOverlay(IClientAPI client) {} - public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) {} - public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) {} - public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) {} - public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) {} - - public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} - public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} - public void sendClientInitialLandInfo(IClientAPI remoteClient, bool overlay) { } - public void ClearAllEnvironments(){ } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs deleted file mode 100644 index 464a4f256fe..00000000000 --- a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Specialized; -using System.IO; -using System.Net; -using System.Text; -using System.Web; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Tests.Common -{ - public class TestOSHttpRequest : IOSHttpRequest - { - public string[] AcceptTypes - { - get - { - throw new NotImplementedException (); - } - } - - public Encoding ContentEncoding - { - get - { - throw new NotImplementedException (); - } - } - - public long ContentLength - { - get - { - throw new NotImplementedException (); - } - } - - public long ContentLength64 - { - get - { - throw new NotImplementedException (); - } - } - - public string ContentType - { - get - { - throw new NotImplementedException (); - } - } - - public HttpCookieCollection Cookies - { - get - { - throw new NotImplementedException (); - } - } - - public bool HasEntityBody - { - get - { - throw new NotImplementedException (); - } - } - - public NameValueCollection Headers { get; set; } - - public string HttpMethod - { - get - { - throw new NotImplementedException (); - } - } - - public Stream InputStream { get; set;} - - public bool IsSecured - { - get - { - throw new NotImplementedException (); - } - } - - public bool KeepAlive - { - get - { - throw new NotImplementedException (); - } - } - - public NameValueCollection QueryString - { - get - { - throw new NotImplementedException (); - } - } - - public Hashtable Query - { - get - { - throw new NotImplementedException(); - } - } - - public Dictionary QueryAsDictionary - { - get - { - throw new NotImplementedException(); - } - } - - public HashSet QueryFlags - { - get - { - throw new NotImplementedException(); - } - } - - public string RawUrl - { - get - { - throw new NotImplementedException (); - } - } - - public IPEndPoint RemoteIPEndPoint - { - get - { - throw new NotImplementedException(); - } - } - - public IPEndPoint LocalIPEndPoint - { - get - { - throw new NotImplementedException(); - } - } - - public Uri Url { get; set; } - public string UriPath { get;} - public double ArrivalTS { get; } - - public string UserAgent - { - get - { - throw new NotImplementedException (); - } - } - - public TestOSHttpRequest() - { - Headers = new NameValueCollection(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs deleted file mode 100644 index 6afcb05d8ab..00000000000 --- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Net; -using System.Text; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Tests.Common -{ - public class TestOSHttpResponse : IOSHttpResponse - { - /// - /// Content type property. - /// - /// - /// Setting this property will also set IsContentTypeSet to - /// true. - /// - public string ContentType { get; set; } - - /// - /// Boolean property indicating whether the content type - /// property actively has been set. - /// - /// - /// IsContentTypeSet will go away together with .NET base. - /// - // public bool IsContentTypeSet - // { - // get { return _contentTypeSet; } - // } - // private bool _contentTypeSet; - - /// - /// Length of the body content; 0 if there is no body. - /// - public long ContentLength { get; set; } - - /// - /// Alias for ContentLength. - /// - public long ContentLength64 { get; set; } - - public int Priority { get; set; } - public byte[] RawBuffer { get; set; } - public int RawBufferStart { get; set; } - public int RawBufferLen { get; set; } - - /// - /// Encoding of the body content. - /// - public Encoding ContentEncoding { get; set; } - - public bool KeepAlive { get; set; } - - /// - /// Get or set the keep alive timeout property (default is - /// 20). Setting this to 0 also disables KeepAlive. Setting - /// this to something else but 0 also enable KeepAlive. - /// - public int KeepAliveTimeout { get; set; } - - /// - /// Return the output stream feeding the body. - /// - /// - /// On its way out... - /// - public Stream OutputStream { get; private set; } - - public string ProtocolVersion { get; set; } - - /// - /// Return the output stream feeding the body. - /// - public Stream Body { get; private set; } - - /// - /// Chunk transfers. - /// - public bool SendChunked { get; set; } - - /// - /// HTTP status code. - /// - public int StatusCode { get; set; } - - /// - /// HTTP status description. - /// - public string StatusDescription { get; set; } - - public double RequestTS { get; } - - /// - /// Set response as a http redirect - /// - /// redirection target url - /// the response Status, must be Redirect, Moved,MovedPermanently,RedirectKeepVerb, RedirectMethod, TemporaryRedirect. Defaults to Redirect - public void Redirect(string url, HttpStatusCode redirStatusCode = HttpStatusCode.Redirect) { throw new NotImplementedException(); } - /// - /// Add a header field and content to the response. - /// - /// string containing the header field - /// name - /// string containing the header field - /// value - public void AddHeader(string key, string value) { throw new NotImplementedException(); } - - public void Send() { } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs deleted file mode 100644 index 0b3d4465fc1..00000000000 --- a/OpenSim/Tests/Common/Mock/TestScene.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 Nini.Config; -using OpenSim.Framework; - -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.PhysicsModules.SharedBase; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Tests.Common -{ - public class TestScene : Scene - { - public TestScene( - RegionInfo regInfo, AgentCircuitManager authen, - ISimulationDataService simDataService, IEstateDataService estateDataService, - IConfigSource config, string simulatorVersion) - : base(regInfo, authen, simDataService, estateDataService, - config, simulatorVersion) - { - } - - ~TestScene() - { - //Console.WriteLine("TestScene destructor called for {0}", RegionInfo.RegionName); - Console.WriteLine("TestScene destructor called"); - } - - /// - /// Temporarily override session authentication for tests (namely teleport). - /// - /// - /// TODO: This needs to be mocked out properly. - /// - /// - /// - public override bool VerifyUserPresence(AgentCircuitData agent, out string reason) - { - reason = String.Empty; - return true; - } - - public AsyncSceneObjectGroupDeleter SceneObjectGroupDeleter - { - get { return m_asyncSceneObjectDeleter; } - } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs deleted file mode 100644 index c5d8d18d1df..00000000000 --- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Linq; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Data; -using OpenSim.Data.Null; - -namespace OpenSim.Tests.Common -{ - public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData - { - private Dictionary m_allFolders = new Dictionary(); - private Dictionary m_allItems = new Dictionary(); - - public TestXInventoryDataPlugin(string conn, string realm) {} - - public XInventoryItem[] GetItems(string field, string val) - { -// Console.WriteLine( -// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); - - List origItems = Get(field, val, m_allItems.Values.ToList()); - - XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray(); - -// Console.WriteLine("Found {0} items", items.Length); -// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID)); - - return items; - } - - public XInventoryItem[] GetItems(string field, string[] vals) - { -// Console.WriteLine( -// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); - - List origItems = Get(field, vals, m_allItems.Values.ToList()); - - XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray(); - -// Console.WriteLine("Found {0} items", items.Length); -// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID)); - - return items; - } - - public XInventoryItem[] GetItems(string[] fields, string[] vals) - { -// Console.WriteLine( -// "Requesting items, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); - - List origItems = Get(fields, vals, m_allItems.Values.ToList()); - - XInventoryItem[] items = origItems.Select(i => i.Clone()).ToArray(); - -// Console.WriteLine("Found {0} items", items.Length); -// Array.ForEach(items, i => Console.WriteLine("Found item {0} {1}", i.inventoryName, i.inventoryID)); - - return items; - } - - public XInventoryFolder[] GetFolders(string[] fields, string[] vals) - { -// Console.WriteLine( -// "Requesting folders, fields {0}, vals {1}", string.Join(", ", fields), string.Join(", ", vals)); - - List origFolders - = Get(fields, vals, m_allFolders.Values.ToList()); - - XInventoryFolder[] folders = origFolders.Select(f => f.Clone()).ToArray(); - -// Console.WriteLine("Found {0} folders", folders.Length); -// Array.ForEach(folders, f => Console.WriteLine("Found folder {0} {1}", f.folderName, f.folderID)); - - return folders; - } - - public bool StoreFolder(XInventoryFolder folder) - { - m_allFolders[folder.folderID] = folder.Clone(); - -// Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID); - - return true; - } - - public bool StoreItem(XInventoryItem item) - { - m_allItems[item.inventoryID] = item.Clone(); - -// Console.WriteLine( -// "Added item {0} {1}, folder {2}, creator {3}, owner {4}", -// item.inventoryName, item.inventoryID, item.parentFolderID, item.creatorID, item.avatarID); - - return true; - } - - public bool DeleteFolders(string field, string val) - { - return DeleteFolders(new string[] { field }, new string[] { val }); - } - - public bool DeleteFolders(string[] fields, string[] vals) - { - XInventoryFolder[] foldersToDelete = GetFolders(fields, vals); - Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID)); - - return true; - } - - public bool DeleteItems(string field, string val) - { - return DeleteItems(new string[] { field }, new string[] { val }); - } - - public bool DeleteItems(string[] fields, string[] vals) - { - XInventoryItem[] itemsToDelete = GetItems(fields, vals); - Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID)); - - return true; - } - - public bool MoveItem(string id, string newParent) - { - UUID uid = new UUID(id); - UUID upid = new UUID(newParent); - m_allItems[uid].parentFolderID = upid; - return true; - } - - public bool MoveItems(string[] ids, string[] newParents) - { - if(ids.Length != newParents.Length) - return false; - for(int i =0; i< ids.Length;++i) - MoveItem(ids[i], newParents[i]); - return true; - } - - public bool MoveFolder(string id, string newParent) - { - // Don't use GetFolders() here - it takes a clone! - XInventoryFolder folder = m_allFolders[new UUID(id)]; - - if (folder == null) - return false; - - folder.parentFolderID = new UUID(newParent); - -// XInventoryFolder[] newParentFolders -// = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() }); - -// Console.WriteLine( -// "Moved folder {0} {1}, to {2} {3}", -// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID); - - // TODO: Really need to implement folder version incrementing, though this should be common code anyway, - // not reimplemented in each db plugin. - - return true; - } - - public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } - public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/OpenSim.Tests.Common.csproj b/OpenSim/Tests/Common/OpenSim.Tests.Common.csproj deleted file mode 100644 index cb43b40d7ef..00000000000 --- a/OpenSim/Tests/Common/OpenSim.Tests.Common.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - net48 - - - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - False - - - False - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs deleted file mode 100644 index 9fea34820c9..00000000000 --- a/OpenSim/Tests/Common/OpenSimTestCase.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Servers; - -namespace OpenSim.Tests.Common -{ - [TestFixture] - public class OpenSimTestCase - { - [SetUp] - public virtual void SetUp() - { - //TestHelpers.InMethod(); - // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests - // to have logging on if it failed with an exception. - TestHelpers.DisableLogging(); - - // This is an unfortunate bit of clean up we have to do because MainServer manages things through static - // variables and the VM is not restarted between tests. - if (MainServer.Instance != null) - { - MainServer.RemoveHttpServer(MainServer.Instance.Port); -// MainServer.Instance = null; - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/QuaternionToleranceConstraint.cs b/OpenSim/Tests/Common/QuaternionToleranceConstraint.cs deleted file mode 100644 index b38c382f53b..00000000000 --- a/OpenSim/Tests/Common/QuaternionToleranceConstraint.cs +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using NUnit.Framework; -using NUnit.Framework.Constraints; - -namespace OpenSim.Tests.Common -{ - public class QuaternionToleranceConstraint : ANumericalToleranceConstraint - { - private Quaternion _baseValue; - private Quaternion _valueToBeTested; - - public QuaternionToleranceConstraint(Quaternion baseValue, double tolerance) : base(tolerance) - { - _baseValue = baseValue; - } - - /// - /// Test whether the constraint is satisfied by a given value - /// - /// The value to be tested - /// - /// True for success, false for failure - /// - public override bool Matches(object valueToBeTested) - { - if (valueToBeTested == null) - { - throw new ArgumentException("Constraint cannot be used upon null values."); - } - if (valueToBeTested.GetType() != typeof (Quaternion)) - { - throw new ArgumentException("Constraint cannot be used upon non quaternion values."); - } - - _valueToBeTested = (Quaternion)valueToBeTested; - - return (IsWithinDoubleConstraint(_valueToBeTested.X, _baseValue.X) && - IsWithinDoubleConstraint(_valueToBeTested.Y, _baseValue.Y) && - IsWithinDoubleConstraint(_valueToBeTested.Z, _baseValue.Z) && - IsWithinDoubleConstraint(_valueToBeTested.W, _baseValue.W)); - } - - public override void WriteDescriptionTo(MessageWriter writer) - { - writer.WriteExpectedValue( - string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance)); - } - - public override void WriteActualValueTo(MessageWriter writer) - { - writer.WriteActualValue(_valueToBeTested); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs deleted file mode 100644 index 2b2af346705..00000000000 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Diagnostics; -using System.IO; -using System.Text; -using NUnit.Framework; -using OpenMetaverse; - -namespace OpenSim.Tests.Common -{ - public class TestHelpers - { - private static Stream EnableLoggingConfigStream - = new MemoryStream( - Encoding.UTF8.GetBytes( -@" - - - - - - - - - - - - - - - - -")); - - private static MemoryStream DisableLoggingConfigStream - = new MemoryStream( - Encoding.UTF8.GetBytes( -// "")); - //""))); -// "")); -// ""))); -// "")); - "")); - - public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) - { - try - { - d(); - } - catch(ArgumentException) - { - return true; - } - - return false; - } - - /// - /// A debugging method that can be used to print out which test method you are in - /// - public static void InMethod() - { - StackTrace stackTrace = new StackTrace(); - Console.WriteLine(); - Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); - } - - public static void EnableLogging() - { - log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream); - EnableLoggingConfigStream.Position = 0; - } - - /// - /// Disable logging whilst running the tests. - /// - /// - /// Remember, if a regression test throws an exception before completing this will not be invoked if it's at - /// the end of the test. - /// TODO: Always invoke this after every test - probably need to make all test cases inherit from a common - /// TestCase class where this can be done. - /// - public static void DisableLogging() - { - log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); - DisableLoggingConfigStream.Position = 0; - } - - /// - /// Parse a UUID stem into a full UUID. - /// - /// - /// The fragment will come at the start of the UUID. The rest will be 0s - /// - /// - /// - /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain - /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is - /// given as the 'fragment'. - /// - public static UUID ParseStem(string stem) - { - string rawUuid = stem.PadRight(32, '0'); - - return UUID.Parse(rawUuid); - } - - /// - /// Parse tail section into full UUID. - /// - /// - /// - public static UUID ParseTail(int tail) - { - return new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", tail)); - } - - /// - /// Parse a UUID tail section into a full UUID. - /// - /// - /// The fragment will come at the end of the UUID. The rest will be 0s - /// - /// - /// - /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain - /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is - /// given as the 'fragment'. - /// - public static UUID ParseTail(string stem) - { - string rawUuid = stem.PadLeft(32, '0'); - - return UUID.Parse(rawUuid); - } - } -} diff --git a/OpenSim/Tests/Common/TestLogging.cs b/OpenSim/Tests/Common/TestLogging.cs deleted file mode 100644 index 4a08344321c..00000000000 --- a/OpenSim/Tests/Common/TestLogging.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using log4net.Appender; -using log4net.Layout; - -namespace OpenSim.Tests.Common -{ - public static class TestLogging - { - public static void LogToConsole() - { - ConsoleAppender consoleAppender = new ConsoleAppender(); - consoleAppender.Layout = - new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); - log4net.Config.BasicConfigurator.Configure(consoleAppender); - } - } -} diff --git a/OpenSim/Tests/Common/TestsAssetCache.cs b/OpenSim/Tests/Common/TestsAssetCache.cs deleted file mode 100644 index 933f8b2d1a0..00000000000 --- a/OpenSim/Tests/Common/TestsAssetCache.cs +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 log4net; -using System; -using System.Reflection; -using System.Runtime.Caching; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Tests.Common -{ - public class TestsAssetCache : ISharedRegionModule, IAssetCache - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled; - private MemoryCache m_Cache; - - public string Name - { - get { return "TestsAssetCache"; } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public void Initialise(IConfigSource source) - { - m_Cache = MemoryCache.Default; - m_Enabled = true; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - if (m_Enabled) - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - } - - //////////////////////////////////////////////////////////// - // IAssetCache - // - public bool Check(string id) - { - // XXX This is probably not an efficient implementation. - AssetBase asset; - if (!Get(id, out asset)) - return false; - return asset != null; - } - - public void Cache(AssetBase asset, bool replace = true) - { - if (asset != null) - { - CacheItemPolicy policy = new CacheItemPolicy(); - m_Cache.Set(asset.ID, asset, policy); - } - } - - public void CacheNegative(string id) - { - // We don't do negative caching - } - - public bool Get(string id, out AssetBase asset) - { - asset = (AssetBase)m_Cache.Get(id); - return true; - } - - public bool GetFromMemory(string id, out AssetBase asset) - { - asset = (AssetBase)m_Cache.Get(id); - return true; - } - - public AssetBase GetCached(string id) - { - return (AssetBase)m_Cache.Get(id); - } - - public void Expire(string id) - { - m_Cache.Remove(id); - } - - public void Clear() - { - } - /* - public bool UpdateContent(string id, byte[] data) - { - return false; - } - */ - } -} diff --git a/OpenSim/Tests/Common/VectorToleranceConstraint.cs b/OpenSim/Tests/Common/VectorToleranceConstraint.cs deleted file mode 100644 index 2fa20edec92..00000000000 --- a/OpenSim/Tests/Common/VectorToleranceConstraint.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 OpenMetaverse; -using NUnit.Framework; -using NUnit.Framework.Constraints; - -namespace OpenSim.Tests.Common -{ - public class VectorToleranceConstraint : ANumericalToleranceConstraint - { - private Vector3 _baseValue; - private Vector3 _valueToBeTested; - - public VectorToleranceConstraint(Vector3 baseValue, double tolerance) : base(tolerance) - { - _baseValue = baseValue; - } - - /// - ///Test whether the constraint is satisfied by a given value - /// - ///The value to be tested - /// - ///True for success, false for failure - /// - public override bool Matches(object valueToBeTested) - { - if (valueToBeTested == null) - { - throw new ArgumentException("Constraint cannot be used upon null values."); - } - if (valueToBeTested.GetType() != typeof (Vector3)) - { - throw new ArgumentException("Constraint cannot be used upon non vector values."); - } - - _valueToBeTested = (Vector3) valueToBeTested; - - return (IsWithinDoubleConstraint(_valueToBeTested.X, _baseValue.X) && - IsWithinDoubleConstraint(_valueToBeTested.Y, _baseValue.Y) && - IsWithinDoubleConstraint(_valueToBeTested.Z, _baseValue.Z)); - } - - public override void WriteDescriptionTo(MessageWriter writer) - { - writer.WriteExpectedValue( - string.Format("A value {0} within tolerance of plus or minus {1}", _baseValue, _tolerance)); - } - - public override void WriteActualValueTo(MessageWriter writer) - { - writer.WriteActualValue(_valueToBeTested); - } - } -} diff --git a/OpenSim/Tests/ConfigurationLoaderTest.cs b/OpenSim/Tests/ConfigurationLoaderTest.cs deleted file mode 100644 index a14f1672c8f..00000000000 --- a/OpenSim/Tests/ConfigurationLoaderTest.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.IO; -using Nini.Config; -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests -{ - [TestFixture] - public class ConfigurationLoaderTests : OpenSimTestCase - { - private const string m_testSubdirectory = "test"; - private string m_basePath; - private string m_workingDirectory; - private IConfigSource m_config; - - /// - /// Set up a test directory. - /// - [SetUp] - public override void SetUp() - { - base.SetUp(); - - m_basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - string path = Path.Combine(m_basePath, m_testSubdirectory); - Directory.CreateDirectory(path); - m_workingDirectory = Directory.GetCurrentDirectory(); - Directory.SetCurrentDirectory(path); - } - - /// - /// Remove the test directory. - /// - [TearDown] - public void TearDown() - { - Directory.SetCurrentDirectory(m_workingDirectory); - Directory.Delete(m_basePath, true); - } - - /// - /// Test the including of ini files with absolute and relative paths. - /// - [Test] - public void IncludeTests() - { - const string mainIniFile = "OpenSimDefaults.ini"; - m_config = new IniConfigSource(); - - // Create ini files in a directory structure - IniConfigSource ini; - IConfig config; - - ini = new IniConfigSource(); - config = ini.AddConfig("IncludeTest"); - config.Set("Include-absolute", "absolute/one/config/setting.ini"); - config.Set("Include-absolute1", "absolute/two/config/setting1.ini"); - config.Set("Include-absolute2", "absolute/two/config/setting2.ini"); - config.Set("Include-relative", "../" + m_testSubdirectory + "/relative/one/config/setting.ini"); - config.Set("Include-relative1", "../" + m_testSubdirectory + "/relative/two/config/setting1.ini"); - config.Set("Include-relative2", "../" + m_testSubdirectory + "/relative/two/config/setting2.ini"); - CreateIni(mainIniFile, ini); - - ini = new IniConfigSource(); - ini.AddConfig("Absolute1").Set("name1", "value1"); - CreateIni("absolute/one/config/setting.ini", ini); - - ini = new IniConfigSource(); - ini.AddConfig("Absolute2").Set("name2", 2.3); - CreateIni("absolute/two/config/setting1.ini", ini); - - ini = new IniConfigSource(); - ini.AddConfig("Absolute2").Set("name3", "value3"); - CreateIni("absolute/two/config/setting2.ini", ini); - - ini = new IniConfigSource(); - ini.AddConfig("Relative1").Set("name4", "value4"); - CreateIni("relative/one/config/setting.ini", ini); - - ini = new IniConfigSource(); - ini.AddConfig("Relative2").Set("name5", true); - CreateIni("relative/two/config/setting1.ini", ini); - - ini = new IniConfigSource(); - ini.AddConfig("Relative2").Set("name6", 6); - CreateIni("relative/two/config/setting2.ini", ini); - - // Prepare call to ConfigurationLoader.LoadConfigSettings() - ConfigurationLoader cl = new ConfigurationLoader(); - IConfigSource argvSource = new IniConfigSource(); - EnvConfigSource envConfigSource = new EnvConfigSource(); - argvSource.AddConfig("Startup").Set("inifile", mainIniFile); - argvSource.AddConfig("Network"); - ConfigSettings configSettings; - NetworkServersInfo networkInfo; - - OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, envConfigSource, - out configSettings, out networkInfo); - - // Remove default config - config = source.Source.Configs["Startup"]; - source.Source.Configs.Remove(config); - config = source.Source.Configs["Network"]; - source.Source.Configs.Remove(config); - - // Finally, we are able to check the result - Assert.AreEqual(m_config.ToString(), source.Source.ToString(), - "Configuration with includes does not contain all settings."); - } - - private void CreateIni(string filepath, IniConfigSource source) - { - string path = Path.GetDirectoryName(filepath); - if (path != string.Empty) - { - Directory.CreateDirectory(path); - } - source.Save(filepath); - m_config.Merge(source); - } - } -} diff --git a/OpenSim/Tests/OpenSim.Tests.csproj b/OpenSim/Tests/OpenSim.Tests.csproj deleted file mode 100644 index d4f2c277fbf..00000000000 --- a/OpenSim/Tests/OpenSim.Tests.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - net48 - - - - ..\..\bin\Nini.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Performance/NPCPerformanceTests.cs b/OpenSim/Tests/Performance/NPCPerformanceTests.cs deleted file mode 100644 index b064dca8fb1..00000000000 --- a/OpenSim/Tests/Performance/NPCPerformanceTests.cs +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Diagnostics; -using System.Reflection; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; - -using OpenSim.Region.CoreModules.Avatar.Attachments; -using OpenSim.Region.CoreModules.Avatar.AvatarFactory; -using OpenSim.Region.CoreModules.Framework.InventoryAccess; -using OpenSim.Region.CoreModules.Framework.UserManagement; -using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.OptionalModules.World.NPC; -using OpenSim.Services.AvatarService; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests.Performance -{ - /// - /// NPC performance tests - /// - /// - /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, - /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller - /// earlier tests. - /// - [TestFixture] - public class NPCPerformanceTests : OpenSimTestCase - { - private TestScene scene; - private AvatarFactoryModule afm; - private UserManagementModule umm; - private AttachmentsModule am; - - [OneTimeSetUp] - public void FixtureInit() - { - // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. - Util.FireAndForgetMethod = FireAndForgetMethod.None; - } - - [OneTimeTearDown] - public void TearDown() - { - scene.Close(); - scene = null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - - // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple - // threads. Possibly, later tests should be rewritten not to worry about such things. - Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; - } - - [SetUp] - public void Init() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("NPC"); - config.Configs["NPC"].Set("Enabled", "true"); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - afm = new AvatarFactoryModule(); - umm = new UserManagementModule(); - am = new AttachmentsModule(); - - scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); - } - - [Test] - public void Test_0001_AddRemove100NPCs() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddRemoveNPCs(100); - } - - [Test] - public void Test_0002_AddRemove1000NPCs() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddRemoveNPCs(1000); - } - - [Test] - public void Test_0003_AddRemove2000NPCs() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddRemoveNPCs(2000); - } - - private void TestAddRemoveNPCs(int numberOfNpcs) - { - ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); -// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); - - // 8 is the index of the first baked texture in AvatarAppearance - UUID originalFace8TextureId = TestHelpers.ParseTail(0x10); - Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); - Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); - originalTef.TextureID = originalFace8TextureId; - - // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell - // ScenePresence.SendInitialData() to reset our entire appearance. - scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); - - afm.SetAppearance(sp, originalTe, null, new WearableCacheItem[0]); - - INPCModule npcModule = scene.RequestModuleInterface(); - - List npcs = new List(); - - long startGcMemory = GC.GetTotalMemory(true); - Stopwatch sw = new Stopwatch(); - sw.Start(); - - for (int i = 0; i < numberOfNpcs; i++) - { - npcs.Add( - npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance)); - } - - for (int i = 0; i < numberOfNpcs; i++) - { - Assert.That(npcs[i], Is.Not.Null); - - ScenePresence npc = scene.GetScenePresence(npcs[i]); - Assert.That(npc, Is.Not.Null); - } - - for (int i = 0; i < numberOfNpcs; i++) - { - Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True); - ScenePresence npc = scene.GetScenePresence(npcs[i]); - Assert.That(npc, Is.Null); - } - - sw.Stop(); - - long endGcMemory = GC.GetTotalMemory(true); - - Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds); - Console.WriteLine( - "End {0} MB, Start {1} MB, Diff {2} MB", - endGcMemory / 1024 / 1024, - startGcMemory / 1024 / 1024, - (endGcMemory - startGcMemory) / 1024 / 1024); - } - } -} diff --git a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs b/OpenSim/Tests/Performance/ObjectPerformanceTests.cs deleted file mode 100644 index 9dad423a5fe..00000000000 --- a/OpenSim/Tests/Performance/ObjectPerformanceTests.cs +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Diagnostics; -using System.Reflection; -using log4net; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests.Performance -{ - /// - /// Object performance tests - /// - /// - /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, - /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller - /// earlier tests. - /// - [TestFixture] - public class ObjectPerformanceTests : OpenSimTestCase - { - [TearDown] - public void TearDown() - { - GC.Collect(); - GC.WaitForPendingFinalizers(); - } - -// [Test] -// public void Test0000Clean() -// { -// TestHelpers.InMethod(); -//// log4net.Config.XmlConfigurator.Configure(); -// -// TestAddObjects(200000); -// } - - [Test] - public void Test_0001_10K_1PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(1, 10000); - } - - [Test] - public void Test_0002_100K_1PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(1, 100000); - } - - [Test] - public void Test_0003_200K_1PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(1, 200000); - } - - [Test] - public void Test_0011_100_100PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(100, 100); - } - - [Test] - public void Test_0012_1K_100PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(100, 1000); - } - - [Test] - public void Test_0013_2K_100PrimObjects() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - TestAddObjects(100, 2000); - } - - private void TestAddObjects(int primsInEachObject, int objectsToAdd) - { - UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000"); - - // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage - // collected when we teardown this test. If it's done in a member variable, even if that is subsequently - // nulled out, the garbage collect can be delayed. - TestScene scene = new SceneHelpers().SetupScene(); - -// Process process = Process.GetCurrentProcess(); -// long startProcessMemory = process.PrivateMemorySize64; - long startGcMemory = GC.GetTotalMemory(true); - DateTime start = DateTime.Now; - - for (int i = 1; i <= objectsToAdd; i++) - { - SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i); - Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i)); - } - - TimeSpan elapsed = DateTime.Now - start; -// long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory; - long endGcMemory = GC.GetTotalMemory(false); - - for (int i = 1; i <= objectsToAdd; i++) - { - Assert.That( - scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)), - Is.Not.Null, - string.Format("Object {0} could not be retrieved", i)); - } - - // When a scene object is added to a scene, it is placed in the update list for sending to viewers - // (though in this case we have none). When it is deleted, it is not removed from the update which is - // fine since it will later be ignored. - // - // However, that means that we need to manually run an update here to clear out that list so that deleted - // objects will be clean up by the garbage collector before the next stress test is run. - scene.Update(1); - - Console.WriteLine( - "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)", - Math.Round(elapsed.TotalMilliseconds), - (endGcMemory - startGcMemory) / 1024 / 1024, - endGcMemory / 1024 / 1024, - startGcMemory / 1024 / 1024, - objectsToAdd, - primsInEachObject); - - scene.Close(); -// scene = null; - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Performance/OpenSim.Tests.Performance.csproj b/OpenSim/Tests/Performance/OpenSim.Tests.Performance.csproj deleted file mode 100644 index 62b614d12bb..00000000000 --- a/OpenSim/Tests/Performance/OpenSim.Tests.Performance.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - net48 - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - ..\..\..\bin\XMLRPC.dll - False - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs b/OpenSim/Tests/Performance/ScriptPerformanceTests.cs deleted file mode 100644 index 028f4b00d57..00000000000 --- a/OpenSim/Tests/Performance/ScriptPerformanceTests.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Diagnostics; -using System.Reflection; -using System.Threading; -using log4net; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Scripting.WorldComm; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.ScriptEngine.XEngine; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests.Performance -{ - /// - /// Script performance tests - /// - /// - /// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached, - /// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller - /// earlier tests. - /// - [TestFixture] - public class ScriptPerformanceTests : OpenSimTestCase - { - private TestScene m_scene; - private XEngine m_xEngine; - private AutoResetEvent m_chatEvent = new AutoResetEvent(false); - - private int m_expectedChatMessages; - private List m_osChatMessagesReceived = new List(); - - [SetUp] - public void Init() - { - //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); -// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); - m_xEngine = new XEngine(); - - // Necessary to stop serialization complaining - WorldCommModule wcModule = new WorldCommModule(); - - IniConfigSource configSource = new IniConfigSource(); - - IConfig startupConfig = configSource.AddConfig("Startup"); - startupConfig.Set("DefaultScriptEngine", "XEngine"); - - IConfig xEngineConfig = configSource.AddConfig("XEngine"); - xEngineConfig.Set("Enabled", "true"); - - // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call - // to AssemblyResolver.OnAssemblyResolve fails. - xEngineConfig.Set("AppDomainLoading", "false"); - - m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); - SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); - - m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; - m_scene.StartScripts(); - } - - [TearDown] - public void TearDown() - { - m_scene.Close(); - m_scene = null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - } - - [Test] - public void TestCompileAndStart100Scripts() - { - TestHelpers.InMethod(); - log4net.Config.XmlConfigurator.Configure(); - - TestCompileAndStartScripts(100); - } - - private void TestCompileAndStartScripts(int scriptsToCreate) - { - UUID userId = TestHelpers.ParseTail(0x1); - - m_expectedChatMessages = scriptsToCreate; - int startingObjectIdTail = 0x100; - - GC.Collect(); - - for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++) - { - AddObjectAndScript(idTail, userId); - } - - m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000); - - Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages)); - - foreach (OSChatMessage msg in m_osChatMessagesReceived) - Assert.That( - msg.Message, - Is.EqualTo("Script running"), - string.Format( - "Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running")); - } - - private void AddObjectAndScript(int objectIdTail, UUID userId) - { -// UUID itemId = TestHelpers.ParseTail(0x3); - string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail); - - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail); - m_scene.AddNewSceneObject(so, true); - - InventoryItemBase itemTemplate = new InventoryItemBase(); -// itemTemplate.ID = itemId; - itemTemplate.Name = itemName; - itemTemplate.Folder = so.UUID; - itemTemplate.InvType = (int)InventoryType.LSL; - - m_scene.RezNewScript(userId, itemTemplate); - } - - private void OnChatFromWorld(object sender, OSChatMessage oscm) - { -// Console.WriteLine("Got chat [{0}]", oscm.Message); - - lock (m_osChatMessagesReceived) - { - m_osChatMessagesReceived.Add(oscm); - - if (m_osChatMessagesReceived.Count == m_expectedChatMessages) - m_chatEvent.Set(); - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs deleted file mode 100644 index 90a3dce1b3c..00000000000 --- a/OpenSim/Tests/Permissions/Common.cs +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; -using Nini.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.World.Permissions; -using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; -using OpenSim.Region.CoreModules.Framework.InventoryAccess; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; -using PermissionMask = OpenSim.Framework.PermissionMask; - -namespace OpenSim.Tests.Permissions -{ - [SetUpFixture] - public class Common : OpenSimTestCase - { - public static Common TheInstance; - - public static TestScene TheScene - { - get { return TheInstance.m_Scene; } - } - - public static ScenePresence[] TheAvatars - { - get { return TheInstance.m_Avatars; } - } - - private static string Perms = "Owner: {0}; Group: {1}; Everyone: {2}; Next: {3}"; - private TestScene m_Scene; - private ScenePresence[] m_Avatars = new ScenePresence[3]; - - [SetUp] - public override void SetUp() - { - if (TheInstance == null) - TheInstance = this; - - base.SetUp(); - TestHelpers.EnableLogging(); - - IConfigSource config = new IniConfigSource(); - config.AddConfig("Messaging"); - config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule"); - - config.AddConfig("Modules"); - config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - config.AddConfig("InventoryService"); - config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); - config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin"); - - config.AddConfig("Groups"); - config.Configs["Groups"].Set("Enabled", "true"); - config.Configs["Groups"].Set("Module", "Groups Module V2"); - config.Configs["Groups"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestGroupsDataPlugin"); - config.Configs["Groups"].Set("ServicesConnectorModule", "Groups Local Service Connector"); - config.Configs["Groups"].Set("LocalService", "local"); - - m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config); - // Add modules - SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule()); - - SetUpBasicEnvironment(); - } - - /// - /// The basic environment consists of: - /// - 3 avatars: A1, A2, A3 - /// - 6 simple boxes inworld belonging to A0 and with Next Owner perms: - /// C, CT, MC, MCT, MT, T - /// - Copies of all of these boxes in A0's inventory in the Objects folder - /// - One additional box inworld and in A0's inventory which is a copy of MCT, but - /// with C removed in inventory. This one is called MCT-C - /// - private void SetUpBasicEnvironment() - { - Console.WriteLine("===> SetUpBasicEnvironment <==="); - - // Add 3 avatars - for (int i = 0; i < 3; i++) - { - UUID id = TestHelpers.ParseTail(i + 1); - - m_Avatars[i] = AddScenePresence("Bot", "Bot_" + (i+1), id); - Assert.That(m_Avatars[i], Is.Not.Null); - Assert.That(m_Avatars[i].IsChildAgent, Is.False); - Assert.That(m_Avatars[i].UUID, Is.EqualTo(id)); - Assert.That(m_Scene.GetScenePresences().Count, Is.EqualTo(i + 1)); - } - - AddA1Object("Box C", 10, PermissionMask.Copy); - AddA1Object("Box CT", 11, PermissionMask.Copy | PermissionMask.Transfer); - AddA1Object("Box MC", 12, PermissionMask.Modify | PermissionMask.Copy); - AddA1Object("Box MCT", 13, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer); - AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer); - AddA1Object("Box T", 15, PermissionMask.Transfer); - - // MCT-C - AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer); - - Thread.Sleep(5000); - - InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects"); - List items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID); - Assert.That(items.Count, Is.EqualTo(7)); - - RevokePermission(0, "Box MCT-C", PermissionMask.Copy); - } - - private ScenePresence AddScenePresence(string first, string last, UUID id) - { - UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_Scene, first, last, id, "pw"); - ScenePresence sp = SceneHelpers.AddScenePresence(m_Scene, id); - Assert.That(m_Scene.AuthenticateHandler.GetAgentCircuitData(id), Is.Not.Null); - - return sp; - } - - private void AddA1Object(string name, int suffix, PermissionMask nextOwnerPerms) - { - // Create a Box. Default permissions are just T - SceneObjectGroup box = AddSceneObject(name, suffix, 1, m_Avatars[0].UUID); - Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Copy) == 0); - Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0); - Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) != 0); - - // field = 16 is NextOwner - // set = 1 means add the permission; set = 0 means remove permission - - if ((nextOwnerPerms & PermissionMask.Copy) != 0) - m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, - m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Copy, 1); - - if ((nextOwnerPerms & PermissionMask.Modify) != 0) - m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, - m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Modify, 1); - - if ((nextOwnerPerms & PermissionMask.Transfer) == 0) - m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, - m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Transfer, 0); - - PrintPerms(box); - AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); - - TakeCopyToInventory(0, box); - - } - - public void RevokePermission(int ownerIndex, string name, PermissionMask perm) - { - InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); - Assert.That(item, Is.Not.Null); - - // Clone it, so to avoid aliasing -- just like the viewer does. - InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item); - // Revoke the permission in this copy - clone.NextPermissions &= ~(uint)perm; - Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm, - (PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone)); - Assert.That(clone.ID == item.ID); - - // Update properties of the item in inventory. This should affect the original item above. - Common.TheScene.UpdateInventoryItem(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone); - - item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); - Assert.That(item, Is.Not.Null); - Common.TheInstance.PrintPerms(item); - Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm, - (PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item)); - - } - - public void PrintPerms(SceneObjectGroup sog) - { - Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + - String.Format(Perms, (PermissionMask)sog.EffectiveOwnerPerms, - (PermissionMask)sog.EffectiveGroupPerms, (PermissionMask)sog.EffectiveEveryOnePerms, (PermissionMask)sog.RootPart.NextOwnerMask)); - - } - - public void PrintPerms(InventoryItemBase item) - { - Console.WriteLine("Inv " + item.Name + " (" + item.Owner.ToString().Substring(34) + "): " + - String.Format(Perms, (PermissionMask)item.BasePermissions, - (PermissionMask)item.GroupPermissions, (PermissionMask)item.EveryOnePermissions, (PermissionMask)item.NextPermissions)); - - } - - public void AssertPermissions(PermissionMask desired, PermissionMask actual, string message) - { - if ((desired & PermissionMask.Copy) != 0) - Assert.True((actual & PermissionMask.Copy) != 0, message); - else - Assert.True((actual & PermissionMask.Copy) == 0, message); - - if ((desired & PermissionMask.Modify) != 0) - Assert.True((actual & PermissionMask.Modify) != 0, message); - else - Assert.True((actual & PermissionMask.Modify) == 0, message); - - if ((desired & PermissionMask.Transfer) != 0) - Assert.True((actual & PermissionMask.Transfer) != 0, message); - else - Assert.True((actual & PermissionMask.Transfer) == 0, message); - - } - - public SceneObjectGroup AddSceneObject(string name, int suffix, int partsToTestCount, UUID ownerID) - { - SceneObjectGroup so = SceneHelpers.CreateSceneObject(partsToTestCount, ownerID, name, suffix); - so.Name = name; - so.Description = name; - - Assert.That(m_Scene.AddNewSceneObject(so, false), Is.True); - SceneObjectGroup retrievedSo = m_Scene.GetSceneObjectGroup(so.UUID); - - // If the parts have the same UUID then we will consider them as one and the same - Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount)); - - return so; - } - - public void TakeCopyToInventory(int userIndex, SceneObjectGroup sog) - { - InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[userIndex].UUID, "Objects"); - Assert.That(objsFolder, Is.Not.Null); - - List localIds = new List(); localIds.Add(sog.LocalId); - // This is an async operation - m_Scene.DeRezObjects(m_Avatars[userIndex].ControllingClient, localIds, m_Avatars[userIndex].UUID, DeRezAction.TakeCopy, objsFolder.ID); - } - - public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName) - { - InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, userID, folderName); - Assert.That(objsFolder, Is.Not.Null); - List items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID); - InventoryItemBase item = items.Find(i => i.Name == itemName); - Assert.That(item, Is.Not.Null); - - return item; - } - - public InventoryItemBase CloneInventoryItem(InventoryItemBase item) - { - InventoryItemBase clone = new InventoryItemBase(item.ID); - clone.Name = item.Name; - clone.Description = item.Description; - clone.AssetID = item.AssetID; - clone.AssetType = item.AssetType; - clone.BasePermissions = item.BasePermissions; - clone.CreatorId = item.CreatorId; - clone.CurrentPermissions = item.CurrentPermissions; - clone.EveryOnePermissions = item.EveryOnePermissions; - clone.Flags = item.Flags; - clone.Folder = item.Folder; - clone.GroupID = item.GroupID; - clone.GroupOwned = item.GroupOwned; - clone.GroupPermissions = item.GroupPermissions; - clone.InvType = item.InvType; - clone.NextPermissions = item.NextPermissions; - clone.Owner = item.Owner; - - return clone; - } - - public void DeleteObjectsFolders() - { - // Delete everything in A2 and A3's Objects folders, so we can restart - for (int i = 1; i < 3; i++) - { - InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[i].UUID, "Objects"); - Assert.That(objsFolder, Is.Not.Null); - - List items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID); - List ids = new List(); - foreach (InventoryItemBase it in items) - ids.Add(it.ID); - - Common.TheScene.InventoryService.DeleteItems(Common.TheAvatars[i].UUID, ids); - items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID); - Assert.That(items.Count, Is.EqualTo(0), "A" + (i + 1)); - } - - } - - public string IdStr(InventoryItemBase item) - { - return item.Owner.ToString().Substring(34) + " : " + item.Name; - } - - public string IdStr(SceneObjectGroup sog) - { - return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name; - } - - public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) - { - TestClient giverClient = (TestClient)giverSp.ControllingClient; - TestClient receiverClient = (TestClient)receiverSp.ControllingClient; - - UUID initialSessionId = TestHelpers.ParseTail(0x10); - byte[] giveImBinaryBucket = new byte[17]; - byte[] itemIdBytes = itemId.GetBytes(); - Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length); - - GridInstantMessage giveIm - = new GridInstantMessage( - m_Scene, - giverSp.UUID, - giverSp.Name, - receiverSp.UUID, - (byte)InstantMessageDialog.InventoryOffered, - false, - "inventory offered msg", - initialSessionId, - false, - Vector3.Zero, - giveImBinaryBucket, - true); - - giverClient.HandleImprovedInstantMessage(giveIm); - - // These details might not all be correct. - GridInstantMessage acceptIm - = new GridInstantMessage( - m_Scene, - receiverSp.UUID, - receiverSp.Name, - giverSp.UUID, - (byte)InstantMessageDialog.InventoryAccepted, - false, - "inventory accepted msg", - initialSessionId, - false, - Vector3.Zero, - null, - true); - - receiverClient.HandleImprovedInstantMessage(acceptIm); - } - } -} diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs deleted file mode 100644 index 0f251dba436..00000000000 --- a/OpenSim/Tests/Permissions/DirectTransferTests.cs +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Tests.Common; -using PermissionMask = OpenSim.Framework.PermissionMask; - -namespace OpenSim.Tests.Permissions -{ - /// - /// Basic scene object tests (create, read and delete but not update). - /// - [TestFixture] - public class DirectTransferTests - { - - [SetUp] - public void SetUp() - { - // In case we're dealing with some older version of nunit - if (Common.TheInstance == null) - { - Common.TheInstance = new Common(); - Common.TheInstance.SetUp(); - } - - Common.TheInstance.DeleteObjectsFolders(); - } - - /// - /// Test giving simple objecta with various combinations of next owner perms. - /// - [Test] - public void TestGiveBox() - { - TestHelpers.InMethod(); - - // C, CT, MC, MCT, MT, T - string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; - PermissionMask[] perms = new PermissionMask[6] { - PermissionMask.Copy, - PermissionMask.Copy | PermissionMask.Transfer, - PermissionMask.Modify | PermissionMask.Copy, - PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer, - PermissionMask.Modify | PermissionMask.Transfer, - PermissionMask.Transfer - }; - - for (int i = 0; i < 6; i++) - TestOneBox(names[i], perms[i]); - } - - private void TestOneBox(string name, PermissionMask mask) - { - InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); - - Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); - - item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); - - // Check the receiver - Common.TheInstance.PrintPerms(item); - Common.TheInstance.AssertPermissions(mask, (PermissionMask)item.BasePermissions, item.Owner.ToString().Substring(34) + " : " + item.Name); - - int nObjects = Common.TheScene.GetSceneObjectGroups().Count; - // Rez it and check perms in scene too - Common.TheScene.RezObject(Common.TheAvatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero); - Assert.That(Common.TheScene.GetSceneObjectGroups().Count, Is.EqualTo(nObjects + 1)); - - SceneObjectGroup box = Common.TheScene.GetSceneObjectGroups().Find(sog => sog.OwnerID == Common.TheAvatars[1].UUID && sog.Name == name); - Common.TheInstance.PrintPerms(box); - Assert.That(box, Is.Not.Null); - - // Check Owner permissions - Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.EffectiveOwnerPerms, box.OwnerID.ToString().Substring(34) + " : " + box.Name); - - // Check Next Owner permissions - Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); - - } - - /// - /// Test giving simple objecta with variour combinations of next owner perms. - /// - [Test] - public void TestDoubleGiveWithChange() - { - TestHelpers.InMethod(); - - string name = "Box MCT-C"; - InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); - - // Now give the item to A2. We give the original item, not a clone. - // The giving methods are supposed to duplicate it. - Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); - - item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); - - // Check the receiver - Common.TheInstance.PrintPerms(item); - Common.TheInstance.AssertPermissions(PermissionMask.Modify | PermissionMask.Transfer, - (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); - - // --------------------------- - // Second transfer - //---------------------------- - - // A2 revokes M - Common.TheInstance.RevokePermission(1, name, PermissionMask.Modify); - - item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); - - // Now give the item to A3. We give the original item, not a clone. - // The giving methods are supposed to duplicate it. - Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[1], Common.TheAvatars[2]); - - item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[2].UUID, "Objects", name); - - // Check the receiver - Common.TheInstance.PrintPerms(item); - Common.TheInstance.AssertPermissions(PermissionMask.Transfer, - (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); - - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Permissions/IndirectTransferTests.cs b/OpenSim/Tests/Permissions/IndirectTransferTests.cs deleted file mode 100644 index 909bda31b1d..00000000000 --- a/OpenSim/Tests/Permissions/IndirectTransferTests.cs +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Collections.Generic; -using System.Threading; -using NUnit.Framework; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Tests.Common; -using PermissionMask = OpenSim.Framework.PermissionMask; - -namespace OpenSim.Tests.Permissions -{ - /// - /// Basic scene object tests (create, read and delete but not update). - /// - [TestFixture] - public class IndirectTransferTests - { - - [SetUp] - public void SetUp() - { - // In case we're dealing with some older version of nunit - if (Common.TheInstance == null) - { - Common.TheInstance = new Common(); - Common.TheInstance.SetUp(); - } - Common.TheInstance.DeleteObjectsFolders(); - } - - /// - /// Test giving simple objecta with various combinations of next owner perms. - /// - [Test] - public void SimpleTakeCopy() - { - TestHelpers.InMethod(); - - // The Objects folder of A2 - InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects"); - - // C, CT, MC, MCT, MT, T - string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; - PermissionMask[] perms = new PermissionMask[6] { - PermissionMask.Copy, - PermissionMask.Copy | PermissionMask.Transfer, - PermissionMask.Modify | PermissionMask.Copy, - PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer, - PermissionMask.Modify | PermissionMask.Transfer, - PermissionMask.Transfer - }; - - // Try A2 takes copies of objects that cannot be copied. - for (int i = 0; i < 6; i++) - TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); - // Ad-hoc. Enough time to let the take work. - Thread.Sleep(6000); - - List items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); - Assert.That(items.Count, Is.EqualTo(0)); - - // A1 makes the objects copyable - for (int i = 0; i < 6; i++) - MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]); - - // Try A2 takes copies of objects that can be copied. - for (int i = 0; i < 6; i++) - TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); - // Ad-hoc. Enough time to let the take work. - Thread.Sleep(6000); - - items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); - Assert.That(items.Count, Is.EqualTo(6)); - - for (int i = 0; i < 6; i++) - { - InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]); - Assert.That(item, Is.Not.Null); - Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); - } - } - - private void TakeOneBox(List objs, string name, PermissionMask mask) - { - // Find the object inworld - SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); - Assert.That(box, Is.Not.Null, name); - - // A2's inventory (index 1) - Common.TheInstance.TakeCopyToInventory(1, box); - } - - private void MakeCopyable(List objs, string name) - { - SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); - Assert.That(box, Is.Not.Null, name); - - // field = 8 is Everyone - // set = 1 means add the permission; set = 0 means remove permission - Common.TheScene.HandleObjectPermissionsUpdate(Common.TheAvatars[0].ControllingClient, Common.TheAvatars[0].UUID, - Common.TheAvatars[0].ControllingClient.SessionId, 8, box.LocalId, (uint)PermissionMask.Copy, 1); - Common.TheInstance.PrintPerms(box); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Permissions/OpenSim.Tests.Permissions.csproj b/OpenSim/Tests/Permissions/OpenSim.Tests.Permissions.csproj deleted file mode 100644 index 27527f2f52b..00000000000 --- a/OpenSim/Tests/Permissions/OpenSim.Tests.Permissions.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - net48 - - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs b/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs deleted file mode 100644 index 15498517eb1..00000000000 --- a/OpenSim/Tests/Robust/Clients/Grid/GridClient.cs +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using System.Reflection; - -using OpenMetaverse; -using NUnit.Framework; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using OpenSim.Services.Connectors; - -namespace Robust.Tests -{ - [TestFixture] - public class GridClient - { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - - [Test] - public void Grid_001() - { - GridServicesConnector m_Connector = new GridServicesConnector(DemonServer.Address); - - GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000); - GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000); - GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); - - string msg = m_Connector.RegisterRegion(UUID.Zero, r1); - Assert.AreEqual(msg, string.Empty, "Region 1 failed to register"); - - msg = m_Connector.RegisterRegion(UUID.Zero, r2); - Assert.AreEqual(msg, string.Empty, "Region 2 failed to register"); - - msg = m_Connector.RegisterRegion(UUID.Zero, r3); - Assert.AreEqual(msg, string.Empty, "Region 3 failed to register"); - - bool success; - success = m_Connector.DeregisterRegion(r3.RegionID); - Assert.AreEqual(success, true, "Region 3 failed to deregister"); - - msg = m_Connector.RegisterRegion(UUID.Zero, r3); - Assert.AreEqual(msg, string.Empty, "Region 3 failed to re-register"); - - List regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID); - Assert.AreNotEqual(regions, null, "GetNeighbours of region 1 failed"); - Assert.AreEqual(regions.Count, 1, "Region 1 should have 1 neighbor"); - Assert.AreEqual(regions[0].RegionName, "Test Region 2", "Region 1 has the wrong neighbor"); - - GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID); - Assert.AreNotEqual(region, null, "GetRegionByUUID for region 2 failed"); - Assert.AreEqual(region.RegionName, "Test Region 2", "GetRegionByUUID of region 2 returned wrong region"); - - region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random()); - Assert.AreEqual(region, null, "Region with randon id should not exist"); - - region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName); - Assert.AreNotEqual(region, null, "GetRegionByUUID for region 3 failed"); - Assert.AreEqual(region.RegionName, "Test Region 3", "GetRegionByUUID of region 3 returned wrong region"); - - region = m_Connector.GetRegionByName(UUID.Zero, "Foo"); - Assert.AreEqual(region, null, "Region Foo should not exist"); - - regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10); - Assert.AreNotEqual(regions, null, "GetRegionsByName failed"); - Assert.AreEqual(regions.Count, 3, "GetRegionsByName should return 3"); - - regions = m_Connector.GetRegionRange(UUID.Zero, - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002), - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) ); - Assert.AreNotEqual(regions, null, "GetRegionRange failed"); - Assert.AreEqual(regions.Count, 2, "GetRegionRange should return 2"); - - regions = m_Connector.GetRegionRange(UUID.Zero, - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950), - (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) ); - Assert.AreNotEqual(regions, null, "GetRegionRange (bis) failed"); - Assert.AreEqual(regions.Count, 0, "GetRegionRange (bis) should return 0"); - - // Deregister them all - success = m_Connector.DeregisterRegion(r1.RegionID); - Assert.AreEqual(success, true, "Region 1 failed to deregister"); - - success = m_Connector.DeregisterRegion(r2.RegionID); - Assert.AreEqual(success, true, "Region 2 failed to deregister"); - - success = m_Connector.DeregisterRegion(r3.RegionID); - Assert.AreEqual(success, true, "Region 3 failed to deregister"); - } - - private static GridRegion CreateRegion(string name, uint xcell, uint ycell) - { - GridRegion region = new GridRegion(xcell, ycell); - region.RegionName = name; - region.RegionID = UUID.Random(); - region.ExternalHostName = "127.0.0.1"; - region.HttpPort = 9000; - region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000); - - return region; - } - } -} diff --git a/OpenSim/Tests/Robust/Clients/Grid/GridForm.html b/OpenSim/Tests/Robust/Clients/Grid/GridForm.html deleted file mode 100644 index 252920f38d3..00000000000 --- a/OpenSim/Tests/Robust/Clients/Grid/GridForm.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
-xmin: -xmax: -ymin: -ymax: - - -
- diff --git a/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs b/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs deleted file mode 100644 index 4eba7b90847..00000000000 --- a/OpenSim/Tests/Robust/Clients/InstantMessage/IMClient.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; - -using OpenMetaverse; -using NUnit.Framework; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors.InstantMessage; - -namespace Robust.Tests -{ - [TestFixture] - public class IMClient - { - [Test] - public void HGIM_001() - { - GridInstantMessage im = new GridInstantMessage(); - im.fromAgentID = new Guid(); - im.toAgentID = new Guid(); - im.message = "Hello"; - im.imSessionID = new Guid(); - - bool success = InstantMessageServiceConnector.SendInstantMessage(DemonServer.Address, im, String.Empty); - Assert.IsFalse(success, "Sending of IM succeeded, but it should have failed"); - } - - } -} diff --git a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs b/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs deleted file mode 100644 index fe46a4f523c..00000000000 --- a/OpenSim/Tests/Robust/Clients/Inventory/InventoryClient.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using System.Reflection; - -using OpenMetaverse; -using NUnit.Framework; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -using OpenSim.Tests.Common; - -namespace Robust.Tests -{ - [TestFixture] - public class InventoryClient - { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - - private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333"); - private UUID m_rootFolderID; - private UUID m_notecardsFolder; - private UUID m_objectsFolder; - - [Test] - public void Inventory_001_CreateInventory() - { - TestHelpers.InMethod(); - XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); - - // Create an inventory that looks like this: - // - // /My Inventory - // - // /Objects - // Some Object - // /Notecards - // Notecard 1 - // Notecard 2 - // /Test Folder - // Link to notecard -> /Notecards/Notecard 2 - // Link to Objects folder -> /Objects - - bool success = m_Connector.CreateUserInventory(m_userID); - Assert.IsTrue(success, "Failed to create user inventory"); - - m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID; - Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero"); - - InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, FolderType.Object); - Assert.IsNotNull(of, "Failed to retrieve Objects folder"); - m_objectsFolder = of.ID; - Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero"); - - // Add an object - InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID); - item.AssetID = UUID.Random(); - item.AssetType = (int)AssetType.Object; - item.Folder = m_objectsFolder; - item.Name = "Some Object"; - item.Description = string.Empty; - success = m_Connector.AddItem(item); - Assert.IsTrue(success, "Failed to add object to inventory"); - - InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, FolderType.Notecard); - Assert.IsNotNull(of, "Failed to retrieve Notecards folder"); - m_notecardsFolder = ncf.ID; - Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero"); - m_notecardsFolder = ncf.ID; - - // Add a notecard - item = new InventoryItemBase(new UUID("10000000-0000-0000-0000-000000000001"), m_userID); - item.AssetID = UUID.Random(); - item.AssetType = (int)AssetType.Notecard; - item.Folder = m_notecardsFolder; - item.Name = "Test Notecard 1"; - item.Description = string.Empty; - success = m_Connector.AddItem(item); - Assert.IsTrue(success, "Failed to add Notecard 1 to inventory"); - // Add another notecard - item.ID = new UUID("20000000-0000-0000-0000-000000000002"); - item.AssetID = new UUID("a0000000-0000-0000-0000-00000000000a"); - item.Name = "Test Notecard 2"; - item.Description = string.Empty; - success = m_Connector.AddItem(item); - Assert.IsTrue(success, "Failed to add Notecard 2 to inventory"); - - // Add a folder - InventoryFolderBase folder = new InventoryFolderBase(new UUID("f0000000-0000-0000-0000-00000000000f"), "Test Folder", m_userID, m_rootFolderID); - folder.Type = (int)FolderType.None; - success = m_Connector.AddFolder(folder); - Assert.IsTrue(success, "Failed to add Test Folder to inventory"); - - // Add a link to notecard 2 in Test Folder - item.AssetID = item.ID; // use item ID of notecard 2 - item.ID = new UUID("40000000-0000-0000-0000-000000000004"); - item.AssetType = (int)AssetType.Link; - item.Folder = folder.ID; - item.Name = "Link to notecard"; - item.Description = string.Empty; - success = m_Connector.AddItem(item); - Assert.IsTrue(success, "Failed to add link to notecard to inventory"); - - // Add a link to the Objects folder in Test Folder - item.AssetID = m_Connector.GetFolderForType(m_userID, FolderType.Object).ID; // use item ID of Objects folder - item.ID = new UUID("50000000-0000-0000-0000-000000000005"); - item.AssetType = (int)AssetType.LinkFolder; - item.Folder = folder.ID; - item.Name = "Link to Objects folder"; - item.Description = string.Empty; - success = m_Connector.AddItem(item); - Assert.IsTrue(success, "Failed to add link to objects folder to inventory"); - - InventoryCollection coll = m_Connector.GetFolderContent(m_userID, m_rootFolderID); - Assert.IsNotNull(coll, "Failed to retrieve contents of root folder"); - Assert.Greater(coll.Folders.Count, 0, "Root folder does not have any subfolders"); - - coll = m_Connector.GetFolderContent(m_userID, folder.ID); - Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder"); - Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside"); - - } - - [Test] - public void Inventory_002_MultipleItemsRequest() - { - TestHelpers.InMethod(); - XInventoryServicesConnector m_Connector = new XInventoryServicesConnector(DemonServer.Address); - - // Prefetch Notecard 1, will be cached from here on - InventoryItemBase item = m_Connector.GetItem(m_userID, new UUID("10000000-0000-0000-0000-000000000001")); - Assert.NotNull(item, "Failed to get Notecard 1"); - Assert.AreEqual("Test Notecard 1", item.Name, "Wrong name for Notecard 1"); - - UUID[] uuids = new UUID[2]; - uuids[0] = item.ID; - uuids[1] = new UUID("20000000-0000-0000-0000-000000000002"); - - InventoryItemBase[] items = m_Connector.GetMultipleItems(m_userID, uuids); - Assert.NotNull(items, "Failed to get multiple items"); - Assert.IsTrue(items.Length == 2, "Requested 2 items, but didn't receive 2 items"); - - // Now they should both be cached - items = m_Connector.GetMultipleItems(m_userID, uuids); - Assert.NotNull(items, "(Repeat) Failed to get multiple items"); - Assert.IsTrue(items.Length == 2, "(Repeat) Requested 2 items, but didn't receive 2 items"); - - // This item doesn't exist, but [0] does, and it's cached. - uuids[1] = new UUID("bb000000-0000-0000-0000-0000000000bb"); - // Fetching should return 2 items, but [1] should be null - items = m_Connector.GetMultipleItems(m_userID, uuids); - Assert.NotNull(items, "(Three times) Failed to get multiple items"); - Assert.IsTrue(items.Length == 2, "(Three times) Requested 2 items, but didn't receive 2 items"); - Assert.AreEqual("Test Notecard 1", items[0].Name, "(Three times) Wrong name for Notecard 1"); - Assert.IsNull(items[1], "(Three times) Expecting 2nd item to be null"); - - // Now both don't exist - uuids[0] = new UUID("aa000000-0000-0000-0000-0000000000aa"); - items = m_Connector.GetMultipleItems(m_userID, uuids); - Assert.Null(items[0], "Request to multiple non-existent items is supposed to return null [0]"); - Assert.Null(items[1], "Request to multiple non-existent items is supposed to return null [1]"); - - // This item exists, and it's not cached - uuids[1] = new UUID("b0000000-0000-0000-0000-00000000000b"); - // Fetching should return 2 items, but [0] should be null - items = m_Connector.GetMultipleItems(m_userID, uuids); - Assert.NotNull(items, "(Four times) Failed to get multiple items"); - Assert.IsTrue(items.Length == 2, "(Four times) Requested 2 items, but didn't receive 2 items"); - Assert.AreEqual("Some Object", items[1].Name, "(Four times) Wrong name for Some Object"); - Assert.IsNull(items[0], "(Four times) Expecting 1st item to be null"); - - } - } -} diff --git a/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs deleted file mode 100644 index 31c8ee96ef2..00000000000 --- a/OpenSim/Tests/Robust/Clients/Presence/PresenceClient.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using System.Reflection; - -using OpenMetaverse; -using NUnit.Framework; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace Robust.Tests -{ - [TestFixture] - public class PresenceClient - { - [Test] - public void Presence_001() - { - PresenceServicesConnector m_Connector = new PresenceServicesConnector(DemonServer.Address); - - UUID user1 = UUID.Random(); - UUID session1 = UUID.Random(); - UUID region1 = UUID.Random(); - - bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero); - Assert.AreEqual(success, true, "Failed to add user session"); - - PresenceInfo pinfo = m_Connector.GetAgent(session1); - Assert.AreNotEqual(pinfo, null, "Unable to retrieve session"); - Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); - Assert.AreNotEqual(pinfo.RegionID, region1, "Retrieved session is unexpectedly in region"); - - success = m_Connector.ReportAgent(session1, region1); - Assert.AreEqual(success, true, "Failed to report session in region 1"); - - pinfo = m_Connector.GetAgent(session1); - Assert.AreNotEqual(pinfo, null, "Unable to session presence"); - Assert.AreEqual(pinfo.UserID, user1.ToString(), "Retrieved session does not match expected userID"); - Assert.AreEqual(pinfo.RegionID, region1, "Retrieved session is not in expected region"); - - success = m_Connector.LogoutAgent(session1); - Assert.AreEqual(success, true, "Failed to remove session"); - - pinfo = m_Connector.GetAgent(session1); - Assert.AreEqual(pinfo, null, "Session is still there, even though it shouldn't"); - - success = m_Connector.ReportAgent(session1, UUID.Random()); - Assert.AreEqual(success, false, "Remove non-existing session should fail"); - } - - } -} diff --git a/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs deleted file mode 100644 index 3238dc9a31c..00000000000 --- a/OpenSim/Tests/Robust/Clients/UserAccounts/UserAccountsClient.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Text; -using System.Reflection; - -using OpenMetaverse; -using NUnit.Framework; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace Robust.Tests -{ - [TestFixture] - public class UserAccountsClient - { - [Test] - public void UserAccounts_001() - { - UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(DemonServer.Address); - - string first = "Completely"; - string last = "Clueless"; - string email = "foo@bar.com"; - - UserAccount account = m_Connector.CreateUser(first, last, "123", email, UUID.Zero); - Assert.IsNotNull(account, "Failed to create account " + first + " " + last); - UUID user1 = account.PrincipalID; - - account = m_Connector.GetUserAccount(UUID.Zero, user1); - Assert.NotNull(account, "Failed to retrieve account for user id " + user1); - Assert.AreEqual(account.FirstName, first, "First name does not match"); - Assert.AreEqual(account.LastName, last, "Last name does not match"); - - account = m_Connector.GetUserAccount(UUID.Zero, first, last); - Assert.IsNotNull(account, "Failed to retrieve account for user " + first + " " + last); - Assert.AreEqual(account.FirstName, first, "First name does not match (bis)"); - Assert.AreEqual(account.LastName, last, "Last name does not match (bis)"); - - account.Email = "user@example.com"; - bool success = m_Connector.StoreUserAccount(account); - Assert.IsTrue(success, "Failed to store existing account"); - - account = m_Connector.GetUserAccount(UUID.Zero, user1); - Assert.NotNull(account, "Failed to retrieve account for user id " + user1); - Assert.AreEqual(account.Email, "user@example.com", "Incorrect email"); - - account = new UserAccount(UUID.Zero, "DoesNot", "Exist", "xxx@xxx.com"); - success = m_Connector.StoreUserAccount(account); - Assert.IsFalse(success, "Storing a non-existing account must fail"); - - account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist"); - Assert.IsNull(account, "Account DoesNot Exist must not be there"); - - } - - } -} diff --git a/OpenSim/Tests/Robust/Robust.Tests.csproj b/OpenSim/Tests/Robust/Robust.Tests.csproj deleted file mode 100644 index d661a6dff06..00000000000 --- a/OpenSim/Tests/Robust/Robust.Tests.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - net48 - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Robust/Server/DemonServer.cs b/OpenSim/Tests/Robust/Server/DemonServer.cs deleted file mode 100644 index 1e0797e1ac9..00000000000 --- a/OpenSim/Tests/Robust/Server/DemonServer.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Threading; - -using Nini.Config; -using log4net; -using NUnit.Framework; - -using OpenSim.Server; - -namespace Robust.Tests -{ - [SetUpFixture] - public class DemonServer : OpenSimServer - { - private Thread m_demon; - - public static string Address = "http://localhost:8888"; - - [SetUp] - public void StartDemon() - { - if (File.Exists("Robust.Tests.log")) - File.Delete("Robust.Tests.log"); - - Console.WriteLine("**** Starting demon Robust server ****"); - m_demon = new Thread( () => Main(new string[] {"-inifile=Robust.Tests.ini"})); - m_demon.Start(); - // Give some time for the server to instantiate all services - Thread.Sleep(3000); - Console.WriteLine("**** Setup Finished ****"); - } - - [TearDown] - public void StopDemon() - { - Console.WriteLine("**** Killing demon Robust Server ****"); - m_Server.Shutdown(); - } - } -} diff --git a/OpenSim/Tests/Stress/OpenSim.Tests.Stress.csproj b/OpenSim/Tests/Stress/OpenSim.Tests.Stress.csproj deleted file mode 100644 index 62b614d12bb..00000000000 --- a/OpenSim/Tests/Stress/OpenSim.Tests.Stress.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - net48 - - - - - - - - - - ..\..\..\bin\Nini.dll - False - - - ..\..\..\bin\OpenMetaverse.dll - False - - - ..\..\..\bin\OpenMetaverse.StructuredData.dll - False - - - ..\..\..\bin\OpenMetaverseTypes.dll - False - - - ..\..\..\bin\XMLRPC.dll - False - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs b/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs deleted file mode 100644 index e9767f3e84a..00000000000 --- a/OpenSim/Tests/Stress/VectorRenderModuleStressTests.cs +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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.Linq; -using System.Reflection; -using System.Threading; -using log4net.Config; -using NUnit.Framework; -using OpenMetaverse; -using OpenMetaverse.Assets; -using OpenSim.Framework; -using OpenSim.Region.CoreModules.Scripting.DynamicTexture; -using OpenSim.Region.CoreModules.Scripting.VectorRender; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Tests.Common; - -namespace OpenSim.Tests.Stress -{ - [TestFixture] - public class VectorRenderModuleStressTests : OpenSimTestCase - { - public Scene Scene { get; private set; } - public DynamicTextureModule Dtm { get; private set; } - public VectorRenderModule Vrm { get; private set; } - - private void SetupScene(bool reuseTextures) - { - Scene = new SceneHelpers().SetupScene(); - - Dtm = new DynamicTextureModule(); - Dtm.ReuseTextures = reuseTextures; - - Vrm = new VectorRenderModule(); - - SceneHelpers.SetupSceneModules(Scene, Dtm, Vrm); - } - - [Test] - public void TestConcurrentRepeatedDraw() - { - int threads = 4; - TestHelpers.InMethod(); - - SetupScene(false); - - List drawers = new List(); - - for (int i = 0; i < threads; i++) - { - Drawer d = new Drawer(this, i); - drawers.Add(d); - Console.WriteLine("Starting drawer {0}", i); - Util.FireAndForget(o => d.Draw(), null, "VectorRenderModuleStressTests.TestConcurrentRepeatedDraw"); - } - - Thread.Sleep(10 * 60 * 1000); - - drawers.ForEach(d => d.Ready = false); - drawers.ForEach(d => Console.WriteLine("Drawer {0} drew {1} textures", d.Number, d.Pass + 1)); - } - - class Drawer - { - public int Number { get; private set; } - public int Pass { get; private set; } - public bool Ready { get; set; } - - private VectorRenderModuleStressTests m_tests; - - public Drawer(VectorRenderModuleStressTests tests, int number) - { - m_tests = tests; - Number = number; - Ready = true; - } - - public void Draw() - { - SceneObjectGroup so = SceneHelpers.AddSceneObject(m_tests.Scene); - - while (Ready) - { - UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; - - // Ensure unique text - string text = string.Format("{0:D2}{1}", Number, Pass); - - m_tests.Dtm.AddDynamicTextureData( - m_tests.Scene.RegionInfo.RegionID, - so.UUID, - m_tests.Vrm.GetContentType(), - string.Format("PenColour BLACK; MoveTo 40,220; FontSize 32; Text {0};", text), - ""); - - Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); - - Pass++; - } - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Tools/Compiler/OpenSim.Tools.lslc.csproj b/OpenSim/Tools/Compiler/OpenSim.Tools.lslc.csproj index 44d282543b0..0e3ce59d801 100644 --- a/OpenSim/Tools/Compiler/OpenSim.Tools.lslc.csproj +++ b/OpenSim/Tools/Compiler/OpenSim.Tools.lslc.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe OpenSim.Tools.lslc http://opensimulator.org diff --git a/OpenSim/Tools/Compiler/Program.cs b/OpenSim/Tools/Compiler/Program.cs deleted file mode 100644 index 9270c96d04a..00000000000 --- a/OpenSim/Tools/Compiler/Program.cs +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project 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 DEVELOPERS ``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 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 Microsoft.CSharp; -using OpenSim.Region.ScriptEngine.Shared.CodeTools; -using System.CodeDom.Compiler; - -namespace OpenSim.Tools.LSL.Compiler -{ - class Program - { -// Commented out because generated warning since m_positionMap could never be anything other than null -// private static Dictionary, KeyValuePair> m_positionMap; - private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); - - static void Main(string[] args) - { - string source = null; - - if (args.Length == 0) - { - Console.WriteLine("No input file specified"); - Environment.Exit(1); - } - - if (!File.Exists(args[0])) - { - Console.WriteLine("Input file does not exist"); - Environment.Exit(1); - } - - try - { - ICodeConverter cvt = (ICodeConverter) new CSCodeGenerator(); - source = cvt.Convert(File.ReadAllText(args[0])); - } - catch(Exception e) - { - Console.WriteLine("Conversion failed:\n"+e.Message); - Environment.Exit(1); - } - - source = CreateCSCompilerScript(source); - - try - { - Console.WriteLine(CompileFromDotNetText(source,"a.out")); - } - catch(Exception e) - { - Console.WriteLine("Conversion failed: "+e.Message); - Environment.Exit(1); - } - - Environment.Exit(0); - } - - private static string CreateCSCompilerScript(string compileScript) - { - compileScript = String.Empty + - "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" + - String.Empty + "namespace SecondLife { " + - String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + - @"public Script() { } " + - compileScript + - "} }\r\n"; - return compileScript; - } - - private static string CompileFromDotNetText(string Script, string asset) - { - - string OutFile = asset; - string disp ="OK"; - - try - { - File.Delete(OutFile); - } - catch (Exception e) // NOTLEGIT - Should be just FileIOException - { - throw new Exception("Unable to delete old existing "+ - "script-file before writing new. Compile aborted: " + - e.ToString()); - } - - // Do actual compile - CompilerParameters parameters = new CompilerParameters(); - - parameters.IncludeDebugInformation = true; - - string rootPath = - Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "OpenSim.Region.ScriptEngine.Shared.dll")); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); - - parameters.GenerateExecutable = false; - parameters.OutputAssembly = OutFile; - parameters.IncludeDebugInformation = true; - parameters.WarningLevel = 1; - parameters.TreatWarningsAsErrors = false; - - CompilerResults results = CScodeProvider.CompileAssemblyFromSource(parameters, Script); - - if (results.Errors.Count > 0) - { - string errtext = String.Empty; - foreach (CompilerError CompErr in results.Errors) - { - string severity = CompErr.IsWarning ? "Warning" : "Error"; - - KeyValuePair lslPos; - - lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); - - string text = CompErr.ErrorText; - - text = ReplaceTypes(CompErr.ErrorText); - - // The Second Life viewer's script editor begins - // countingn lines and columns at 0, so we subtract 1. - errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", - lslPos.Key - 1, lslPos.Value - 1, - CompErr.ErrorNumber, text, severity); - } - - disp = "Completed with errors"; - - if (!File.Exists(OutFile)) - { - throw new Exception(errtext); - } - } - - if (!File.Exists(OutFile)) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to locate compiled file."; - throw new Exception(errtext); - } - - // Because windows likes to perform exclusive locks, we simply - // write out a textual representation of the file here - // - // Read the binary file into a buffer - // - FileInfo fi = new FileInfo(OutFile); - - if (fi == null) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to stat file."; - throw new Exception(errtext); - } - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to open file."; - throw new Exception(errtext); - } - - // Convert to base64 - // - string filetext = System.Convert.ToBase64String(data); - Byte[] buf = Encoding.ASCII.GetBytes(filetext); - FileStream sfs = File.Create(OutFile + ".text"); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - - string posmap = String.Empty; -// if (m_positionMap != null) -// { -// foreach (KeyValuePair, KeyValuePair> kvp in m_positionMap) -// { -// KeyValuePair k = kvp.Key; -// KeyValuePair v = kvp.Value; -// posmap += String.Format("{0},{1},{2},{3}\n", -// k.Key, k.Value, v.Key, v.Value); -// } -// } - - buf = Encoding.ASCII.GetBytes(posmap); - - FileStream mfs = File.Create(OutFile + ".map"); - mfs.Write(buf, 0, buf.Length); - mfs.Close(); - - return disp; - } - - private static string ReplaceTypes(string message) - { - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString", - "string"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger", - "integer"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat", - "float"); - - message = message.Replace( - "OpenSim.Region.ScriptEngine.Shared.LSL_Types.list", - "list"); - - return message; - } - - private static KeyValuePair FindErrorPosition(int line, int col) - { - //return FindErrorPosition(line, col, m_positionMap); - return FindErrorPosition(line, col, null); - } - - private class kvpSorter : IComparer, KeyValuePair>> - { - public int Compare(KeyValuePair, KeyValuePair> a, - KeyValuePair, KeyValuePair> b) - { - int kc = a.Key.Key.CompareTo(b.Key.Key); - return (kc != 0) ? kc : a.Key.Value.CompareTo(b.Key.Value); - } - } - - public static KeyValuePair FindErrorPosition(int line, - int col, Dictionary, - KeyValuePair> positionMap) - { - if (positionMap == null || positionMap.Count == 0) - return new KeyValuePair(line, col); - - KeyValuePair ret = new KeyValuePair(); - - if (positionMap.TryGetValue(new KeyValuePair(line, col), - out ret)) - return ret; - - var sorted = new List, KeyValuePair>>(positionMap); - - sorted.Sort(new kvpSorter()); - - int l = 1; - int c = 1; - int pl = 1; - - foreach (KeyValuePair, KeyValuePair> posmap in sorted) - { - //m_log.DebugFormat("[Compiler]: Scanning line map {0},{1} --> {2},{3}", posmap.Key.Key, posmap.Key.Value, posmap.Value.Key, posmap.Value.Value); - int nl = posmap.Value.Key + line - posmap.Key.Key; // New, translated LSL line and column. - int nc = posmap.Value.Value + col - posmap.Key.Value; - // Keep going until we find the first point passed line,col. - if (posmap.Key.Key > line) - { - //m_log.DebugFormat("[Compiler]: Line is larger than requested {0},{1}, returning {2},{3}", line, col, l, c); - if (pl < line) - { - //m_log.DebugFormat("[Compiler]: Previous line ({0}) is less than requested line ({1}), setting column to 1.", pl, line); - c = 1; - } - break; - } - if (posmap.Key.Key == line && posmap.Key.Value > col) - { - // Never move l,c backwards. - if (nl > l || (nl == l && nc > c)) - { - //m_log.DebugFormat("[Compiler]: Using offset relative to this: {0} + {1} - {2}, {3} + {4} - {5} = {6}, {7}", - // posmap.Value.Key, line, posmap.Key.Key, posmap.Value.Value, col, posmap.Key.Value, nl, nc); - l = nl; - c = nc; - } - //m_log.DebugFormat("[Compiler]: Column is larger than requested {0},{1}, returning {2},{3}", line, col, l, c); - break; - } - pl = posmap.Key.Key; - l = posmap.Value.Key; - c = posmap.Value.Value; - } - return new KeyValuePair(l, c); - } - } -} diff --git a/OpenSim/Tools/Compiler/Properties/AssemblyInfo.cs b/OpenSim/Tools/Compiler/Properties/AssemblyInfo.cs deleted file mode 100644 index fe29f277914..00000000000 --- a/OpenSim/Tools/Compiler/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +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("OpenSim.Tools.lslc")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("http://opensimulator.org")] -[assembly: AssemblyProduct("OpenSim")] -[assembly: AssemblyCopyright("OpenSimulator developers")] -[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("002864e7-b2a2-41d2-add8-82f653663160")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] - diff --git a/OpenSim/Tools/Configger/OpenSim.Tools.Configger.csproj b/OpenSim/Tools/Configger/OpenSim.Tools.Configger.csproj index 17d46ebbf6f..1352446c92f 100644 --- a/OpenSim/Tools/Configger/OpenSim.Tools.Configger.csproj +++ b/OpenSim/Tools/Configger/OpenSim.Tools.Configger.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe OpenSim.Tools.Configger http://opensimulator.org diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index a14252737d3..2c58a966793 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -650,7 +650,7 @@ public void Objects_NewPrim(object sender, PrimEventArgs args) Primitive prim = args.Prim; - if (prim != null) + if (prim is not null && prim.Textures.DefaultTexture is not null) { lock (m_objects) m_objects[prim.ID] = prim; diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 2b6fbceb07a..56bcb90ca94 100755 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -298,16 +298,29 @@ public void CreateBots(int botcount, IConfig startupConfig) Array.ForEach( startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => m_defaultBehaviourSwitches.Add(b)); - for (int i = 0; i < botcount; i++) + if(botcount == 1) { lock (m_bots) { - string lastName = string.Format("{0}{1}", m_lastNameStem, i + m_fromBotNumber); - CreateBot( this, CreateBehavioursFromAbbreviatedNames(m_defaultBehaviourSwitches), - m_firstName, lastName, m_password, m_loginUri, m_startUri, m_wearSetting); + m_firstName, m_lastNameStem, m_password, m_loginUri, m_startUri, m_wearSetting); + } + } + else + { + for (int i = 0; i < botcount; i++) + { + lock (m_bots) + { + string lastName = string.Format("{0}{1}", m_lastNameStem, i + m_fromBotNumber); + + CreateBot( + this, + CreateBehavioursFromAbbreviatedNames(m_defaultBehaviourSwitches), + m_firstName, lastName, m_password, m_loginUri, m_startUri, m_wearSetting); + } } } } diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index f162f102793..990f5e627b8 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -56,7 +56,7 @@ public class pCampBot [STAThread] public static void Main(string[] args) { - XmlConfigurator.Configure(); + XmlConfigurator.Configure(new System.IO.FileInfo("pCampBot.exe.config")); IConfig commandLineConfig = ParseConfig(args); if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null) diff --git a/OpenSim/Tools/pCampBot/pCampBot.csproj b/OpenSim/Tools/pCampBot/pCampBot.csproj index 591fb0e11dd..527df897189 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.csproj +++ b/OpenSim/Tools/pCampBot/pCampBot.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe pCampBot http://opensimulator.org diff --git a/README.md b/README.md index 930430c3d68..53d94e7a219 100644 --- a/README.md +++ b/README.md @@ -12,29 +12,33 @@ If it breaks, you get to keep *both* pieces. # Compiling OpenSim -Please see BUILDING.md if you downloaded a source distribution and -need to build OpenSim before running it. +Please see BUILDING.md # Running OpenSim on Windows -You will need .NET 4.0 for versions up to 0.9.0.1 and .NET 4.6 for others. +You will need dotnet 8.0 runtime (https://dotnet.microsoft.com/en-us/download/dotnet/8.0) -We recommend that you run OpenSim from a command prompt on Windows in order -to capture any errors. To run OpenSim from a command prompt * cd to the bin/ directory where you unpacked OpenSim * review and change configuration files (.ini) for your needs. see the "Configuring OpenSim" section - * run OpenSim.exe or opensim32.exe for small regions + * run OpenSim.exe -# Running OpenSim on Linux +# Running OpenSim on Linux/Mac -You will need Mono >= 2.10.8.1 up to version 0.9.0.1 and mono > 5.0 on others. On some Linux distributions you -may need to install additional packages. See http://opensimulator.org/wiki/Dependencies -for more information. +You will need + * [dotnet 8.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) + * libgdiplus + + if you have mono 6.x complete, you already have libgdiplus, otherwise you need to install it + using a package manager for your operating system, like apt, brew, macports, etc + for example on debian: + + `apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev` + To run OpenSim, from the unpacked distribution type: * cd bin @@ -101,9 +105,7 @@ mantis"). Useful information to include: * stack trace * OpenSim.log (attach as file) * OpenSim.ini (attach as file) - * if running under mono: run OpenSim.exe with the "--debug" flag: - mono --debug OpenSim.exe # More Information on OpenSim diff --git a/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs b/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs index 57529578789..6eb7b88e565 100644 --- a/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs +++ b/ThirdParty/SmartThreadPool/CanceledWorkItemsGroup.cs @@ -2,7 +2,7 @@ namespace Amib.Threading.Internal { internal class CanceledWorkItemsGroup { - public readonly static CanceledWorkItemsGroup NotCanceledWorkItemsGroup = new CanceledWorkItemsGroup(); + public readonly static CanceledWorkItemsGroup NotCanceledWorkItemsGroup = new(); public CanceledWorkItemsGroup() { diff --git a/ThirdParty/SmartThreadPool/Exceptions.cs b/ThirdParty/SmartThreadPool/Exceptions.cs index 728df853be7..91f88d54b04 100644 --- a/ThirdParty/SmartThreadPool/Exceptions.cs +++ b/ThirdParty/SmartThreadPool/Exceptions.cs @@ -64,43 +64,5 @@ public WorkItemResultException(string message, Exception e) { } } - - - /// - /// Represents an exception in case IWorkItemResult.GetResult has been canceled - /// - [Serializable] - public sealed partial class WorkItemCancelException - { - public WorkItemCancelException(SerializationInfo si, StreamingContext sc) - : base(si, sc) - { - } - } - - /// - /// Represents an exception in case IWorkItemResult.GetResult has been timed out - /// - [Serializable] - public sealed partial class WorkItemTimeoutException - { - public WorkItemTimeoutException(SerializationInfo si, StreamingContext sc) - : base(si, sc) - { - } - } - - /// - /// Represents an exception in case IWorkItemResult.GetResult has been timed out - /// - [Serializable] - public sealed partial class WorkItemResultException - { - public WorkItemResultException(SerializationInfo si, StreamingContext sc) - : base(si, sc) - { - } - } - #endregion } diff --git a/ThirdParty/SmartThreadPool/STPEventWaitHandle.cs b/ThirdParty/SmartThreadPool/STPEventWaitHandle.cs index 9ddb3ccf6ab..fe9645aace4 100644 --- a/ThirdParty/SmartThreadPool/STPEventWaitHandle.cs +++ b/ThirdParty/SmartThreadPool/STPEventWaitHandle.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Threading; namespace Amib.Threading.Internal @@ -7,25 +8,25 @@ internal static class STPEventWaitHandle { public const int WaitTimeout = Timeout.Infinite; - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) { return WaitHandle.WaitAll(waitHandles, millisecondsTimeout, exitContext); } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int WaitAny(WaitHandle[] waitHandles) { return WaitHandle.WaitAny(waitHandles); } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) { return WaitHandle.WaitAny(waitHandles, millisecondsTimeout, exitContext); } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext) { return waitHandle.WaitOne(millisecondsTimeout, exitContext); diff --git a/ThirdParty/SmartThreadPool/STPPerformanceCounter.cs b/ThirdParty/SmartThreadPool/STPPerformanceCounter.cs deleted file mode 100644 index 64d738e8150..00000000000 --- a/ThirdParty/SmartThreadPool/STPPerformanceCounter.cs +++ /dev/null @@ -1,446 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading; - -namespace Amib.Threading -{ - public interface ISTPPerformanceCountersReader - { - long InUseThreads { get; } - long ActiveThreads { get; } - long WorkItemsQueued { get; } - long WorkItemsProcessed { get; } - } -} - -namespace Amib.Threading.Internal -{ - internal interface ISTPInstancePerformanceCounters : IDisposable - { - void Close(); - void SampleThreads(long activeThreads, long inUseThreads); - void SampleWorkItems(long workItemsQueued, long workItemsProcessed); - void SampleWorkItemsWaitTime(TimeSpan workItemWaitTime); - void SampleWorkItemsProcessTime(TimeSpan workItemProcessTime); - } - - internal enum STPPerformanceCounterType - { - // Fields - ActiveThreads = 0, - InUseThreads = 1, - OverheadThreads = 2, - OverheadThreadsPercent = 3, - OverheadThreadsPercentBase = 4, - - WorkItems = 5, - WorkItemsInQueue = 6, - WorkItemsProcessed = 7, - - WorkItemsQueuedPerSecond = 8, - WorkItemsProcessedPerSecond = 9, - - AvgWorkItemWaitTime = 10, - AvgWorkItemWaitTimeBase = 11, - - AvgWorkItemProcessTime = 12, - AvgWorkItemProcessTimeBase = 13, - - WorkItemsGroups = 14, - - LastCounter = 14, - } - - - /// - /// Summary description for STPPerformanceCounter. - /// - internal class STPPerformanceCounter - { - // Fields - private readonly PerformanceCounterType _pcType; - protected string _counterHelp; - protected string _counterName; - - // Methods - public STPPerformanceCounter( - string counterName, - string counterHelp, - PerformanceCounterType pcType) - { - _counterName = counterName; - _counterHelp = counterHelp; - _pcType = pcType; - } - - public void AddCounterToCollection(CounterCreationDataCollection counterData) - { - CounterCreationData counterCreationData = new CounterCreationData( - _counterName, - _counterHelp, - _pcType); - - counterData.Add(counterCreationData); - } - - // Properties - public string Name - { - get - { - return _counterName; - } - } - } - - internal class STPPerformanceCounters - { - // Fields - internal STPPerformanceCounter[] _stpPerformanceCounters; - private static readonly STPPerformanceCounters _instance; - internal const string _stpCategoryHelp = "SmartThreadPool performance counters"; - internal const string _stpCategoryName = "SmartThreadPool"; - - // Methods - static STPPerformanceCounters() - { - _instance = new STPPerformanceCounters(); - } - - private STPPerformanceCounters() - { - STPPerformanceCounter[] stpPerformanceCounters = new STPPerformanceCounter[] - { - new STPPerformanceCounter("Active threads", "The current number of available in the thread pool.", PerformanceCounterType.NumberOfItems32), - new STPPerformanceCounter("In use threads", "The current number of threads that execute a work item.", PerformanceCounterType.NumberOfItems32), - new STPPerformanceCounter("Overhead threads", "The current number of threads that are active, but are not in use.", PerformanceCounterType.NumberOfItems32), - new STPPerformanceCounter("% overhead threads", "The current number of threads that are active, but are not in use in percents.", PerformanceCounterType.RawFraction), - new STPPerformanceCounter("% overhead threads base", "The current number of threads that are active, but are not in use in percents.", PerformanceCounterType.RawBase), - - new STPPerformanceCounter("Work Items", "The number of work items in the Smart Thread Pool. Both queued and processed.", PerformanceCounterType.NumberOfItems32), - new STPPerformanceCounter("Work Items in queue", "The current number of work items in the queue", PerformanceCounterType.NumberOfItems32), - new STPPerformanceCounter("Work Items processed", "The number of work items already processed", PerformanceCounterType.NumberOfItems32), - - new STPPerformanceCounter("Work Items queued/sec", "The number of work items queued per second", PerformanceCounterType.RateOfCountsPerSecond32), - new STPPerformanceCounter("Work Items processed/sec", "The number of work items processed per second", PerformanceCounterType.RateOfCountsPerSecond32), - - new STPPerformanceCounter("Avg. Work Item wait time/sec", "The average time a work item supends in the queue waiting for its turn to execute.", PerformanceCounterType.AverageCount64), - new STPPerformanceCounter("Avg. Work Item wait time base", "The average time a work item supends in the queue waiting for its turn to execute.", PerformanceCounterType.AverageBase), - - new STPPerformanceCounter("Avg. Work Item process time/sec", "The average time it takes to process a work item.", PerformanceCounterType.AverageCount64), - new STPPerformanceCounter("Avg. Work Item process time base", "The average time it takes to process a work item.", PerformanceCounterType.AverageBase), - - new STPPerformanceCounter("Work Items Groups", "The current number of work item groups associated with the Smart Thread Pool.", PerformanceCounterType.NumberOfItems32), - }; - - _stpPerformanceCounters = stpPerformanceCounters; - SetupCategory(); - } - - private void SetupCategory() - { - if (!PerformanceCounterCategory.Exists(_stpCategoryName)) - { - CounterCreationDataCollection counters = new CounterCreationDataCollection(); - - for (int i = 0; i < _stpPerformanceCounters.Length; i++) - { - _stpPerformanceCounters[i].AddCounterToCollection(counters); - } - - PerformanceCounterCategory.Create( - _stpCategoryName, - _stpCategoryHelp, - PerformanceCounterCategoryType.MultiInstance, - counters); - - } - } - - // Properties - public static STPPerformanceCounters Instance - { - get - { - return _instance; - } - } - } - - internal class STPInstancePerformanceCounter : IDisposable - { - // Fields - private bool _isDisposed; - private PerformanceCounter _pcs; - - // Methods - protected STPInstancePerformanceCounter() - { - _isDisposed = false; - } - - public STPInstancePerformanceCounter( - string instance, - STPPerformanceCounterType spcType) : this() - { - STPPerformanceCounters counters = STPPerformanceCounters.Instance; - _pcs = new PerformanceCounter( - STPPerformanceCounters._stpCategoryName, - counters._stpPerformanceCounters[(int) spcType].Name, - instance, - false); - _pcs.RawValue = _pcs.RawValue; - } - - - public void Close() - { - if (_pcs != null) - { - _pcs.RemoveInstance(); - _pcs.Close(); - _pcs = null; - } - } - - public void Dispose() - { - Dispose(true); - } - - public virtual void Dispose(bool disposing) - { - if (!_isDisposed) - { - if (disposing) - { - Close(); - } - } - _isDisposed = true; - } - - public virtual void Increment() - { - _pcs.Increment(); - } - - public virtual void IncrementBy(long val) - { - _pcs.IncrementBy(val); - } - - public virtual void Set(long val) - { - _pcs.RawValue = val; - } - } - - internal class STPInstanceNullPerformanceCounter : STPInstancePerformanceCounter - { - // Methods - public override void Increment() {} - public override void IncrementBy(long value) {} - public override void Set(long val) {} - } - - - - internal class STPInstancePerformanceCounters : ISTPInstancePerformanceCounters - { - private bool _isDisposed; - // Fields - private STPInstancePerformanceCounter[] _pcs; - private static readonly STPInstancePerformanceCounter _stpInstanceNullPerformanceCounter; - - // Methods - static STPInstancePerformanceCounters() - { - _stpInstanceNullPerformanceCounter = new STPInstanceNullPerformanceCounter(); - } - - public STPInstancePerformanceCounters(string instance) - { - _isDisposed = false; - _pcs = new STPInstancePerformanceCounter[(int)STPPerformanceCounterType.LastCounter]; - - // Call the STPPerformanceCounters.Instance so the static constructor will - // intialize the STPPerformanceCounters singleton. - STPPerformanceCounters.Instance.GetHashCode(); - - for (int i = 0; i < _pcs.Length; i++) - { - if (instance != null) - { - _pcs[i] = new STPInstancePerformanceCounter( - instance, - (STPPerformanceCounterType) i); - } - else - { - _pcs[i] = _stpInstanceNullPerformanceCounter; - } - } - } - - - public void Close() - { - if (null != _pcs) - { - for (int i = 0; i < _pcs.Length; i++) - { - if (null != _pcs[i]) - { - _pcs[i].Dispose(); - } - } - _pcs = null; - } - } - - public void Dispose() - { - Dispose(true); - } - - public virtual void Dispose(bool disposing) - { - if (!_isDisposed) - { - if (disposing) - { - Close(); - } - } - _isDisposed = true; - } - - private STPInstancePerformanceCounter GetCounter(STPPerformanceCounterType spcType) - { - return _pcs[(int) spcType]; - } - - public void SampleThreads(long activeThreads, long inUseThreads) - { - GetCounter(STPPerformanceCounterType.ActiveThreads).Set(activeThreads); - GetCounter(STPPerformanceCounterType.InUseThreads).Set(inUseThreads); - GetCounter(STPPerformanceCounterType.OverheadThreads).Set(activeThreads-inUseThreads); - - GetCounter(STPPerformanceCounterType.OverheadThreadsPercentBase).Set(activeThreads-inUseThreads); - GetCounter(STPPerformanceCounterType.OverheadThreadsPercent).Set(inUseThreads); - } - - public void SampleWorkItems(long workItemsQueued, long workItemsProcessed) - { - GetCounter(STPPerformanceCounterType.WorkItems).Set(workItemsQueued+workItemsProcessed); - GetCounter(STPPerformanceCounterType.WorkItemsInQueue).Set(workItemsQueued); - GetCounter(STPPerformanceCounterType.WorkItemsProcessed).Set(workItemsProcessed); - - GetCounter(STPPerformanceCounterType.WorkItemsQueuedPerSecond).Set(workItemsQueued); - GetCounter(STPPerformanceCounterType.WorkItemsProcessedPerSecond).Set(workItemsProcessed); - } - - public void SampleWorkItemsWaitTime(TimeSpan workItemWaitTime) - { - GetCounter(STPPerformanceCounterType.AvgWorkItemWaitTime).IncrementBy((long)workItemWaitTime.TotalMilliseconds); - GetCounter(STPPerformanceCounterType.AvgWorkItemWaitTimeBase).Increment(); - } - - public void SampleWorkItemsProcessTime(TimeSpan workItemProcessTime) - { - GetCounter(STPPerformanceCounterType.AvgWorkItemProcessTime).IncrementBy((long)workItemProcessTime.TotalMilliseconds); - GetCounter(STPPerformanceCounterType.AvgWorkItemProcessTimeBase).Increment(); - } - } - - internal class NullSTPInstancePerformanceCounters : ISTPInstancePerformanceCounters, ISTPPerformanceCountersReader - { - private static readonly NullSTPInstancePerformanceCounters _instance = new NullSTPInstancePerformanceCounters(); - - public static NullSTPInstancePerformanceCounters Instance - { - get { return _instance; } - } - - public void Close() {} - public void Dispose() {} - - public void SampleThreads(long activeThreads, long inUseThreads) {} - public void SampleWorkItems(long workItemsQueued, long workItemsProcessed) {} - public void SampleWorkItemsWaitTime(TimeSpan workItemWaitTime) {} - public void SampleWorkItemsProcessTime(TimeSpan workItemProcessTime) {} - public long InUseThreads - { - get { return 0; } - } - - public long ActiveThreads - { - get { return 0; } - } - - public long WorkItemsQueued - { - get { return 0; } - } - - public long WorkItemsProcessed - { - get { return 0; } - } - } - - internal class LocalSTPInstancePerformanceCounters : ISTPInstancePerformanceCounters, ISTPPerformanceCountersReader - { - public void Close() { } - public void Dispose() { } - - private long _activeThreads; - private long _inUseThreads; - private long _workItemsQueued; - private long _workItemsProcessed; - - public long InUseThreads - { - get { return _inUseThreads; } - } - - public long ActiveThreads - { - get { return _activeThreads; } - } - - public long WorkItemsQueued - { - get { return _workItemsQueued; } - } - - public long WorkItemsProcessed - { - get { return _workItemsProcessed; } - } - - public void SampleThreads(long activeThreads, long inUseThreads) - { - _activeThreads = activeThreads; - _inUseThreads = inUseThreads; - } - - public void SampleWorkItems(long workItemsQueued, long workItemsProcessed) - { - _workItemsQueued = workItemsQueued; - _workItemsProcessed = workItemsProcessed; - } - - public void SampleWorkItemsWaitTime(TimeSpan workItemWaitTime) - { - // Not supported - } - - public void SampleWorkItemsProcessTime(TimeSpan workItemProcessTime) - { - // Not supported - } - } -} diff --git a/ThirdParty/SmartThreadPool/STPStartInfo.cs b/ThirdParty/SmartThreadPool/STPStartInfo.cs index cb3573133c7..bf116ce1785 100644 --- a/ThirdParty/SmartThreadPool/STPStartInfo.cs +++ b/ThirdParty/SmartThreadPool/STPStartInfo.cs @@ -12,16 +12,13 @@ public class STPStartInfo : WIGStartInfo private int _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads; private int _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority; - private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground; - private bool _enableLocalPerformanceCounters; private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName; private int? _maxStackSize = SmartThreadPool.DefaultMaxStackSize; private bool _supressflow = false; public STPStartInfo() { - _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; _threadPriority = SmartThreadPool.DefaultThreadPriority; _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; _idleTimeout = SmartThreadPool.DefaultIdleTimeout; @@ -35,8 +32,6 @@ public STPStartInfo(STPStartInfo stpStartInfo) _minWorkerThreads = stpStartInfo.MinWorkerThreads; _maxWorkerThreads = stpStartInfo.MaxWorkerThreads; _threadPriority = stpStartInfo.ThreadPriority; - _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName; - _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters; _threadPoolName = stpStartInfo._threadPoolName; _areThreadsBackground = stpStartInfo.AreThreadsBackground; _apartmentState = stpStartInfo._apartmentState; @@ -110,36 +105,6 @@ public virtual string ThreadPoolName } } - /// - /// Get/Set the performance counter instance name of this SmartThreadPool - /// The default is null which indicate not to use performance counters at all. - /// - public virtual string PerformanceCounterInstanceName - { - get { return _performanceCounterInstanceName; } - set - { - ThrowIfReadOnly(); - _performanceCounterInstanceName = value; - } - } - - /// - /// Enable/Disable the local performance counter. - /// This enables the user to get some performance information about the SmartThreadPool - /// without using Windows performance counters. (Useful on WindowsCE, Silverlight, etc.) - /// The default is false. - /// - public virtual bool EnableLocalPerformanceCounters - { - get { return _enableLocalPerformanceCounters; } - set - { - ThrowIfReadOnly(); - _enableLocalPerformanceCounters = value; - } - } - /// /// Get/Set backgroundness of thread in thread pool. /// diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.cs b/ThirdParty/SmartThreadPool/SmartThreadPool.cs index 836cdef571b..40708bc6d4a 100644 --- a/ThirdParty/SmartThreadPool/SmartThreadPool.cs +++ b/ThirdParty/SmartThreadPool/SmartThreadPool.cs @@ -98,7 +98,6 @@ using System; using System.Security; using System.Threading; -using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; @@ -203,105 +202,95 @@ public partial class SmartThreadPool : WorkItemsGroupBase, IDisposable /// /// Dictionary of all the threads in the thread pool. /// - private readonly ConcurrentDictionary _workerThreads = new ConcurrentDictionary(); - private readonly object _workerThreadsLock = new object(); + private readonly ConcurrentDictionary m_workerThreads = new(); + private readonly object m_workerThreadsLock = new(); /// /// Queue of work items. /// - private readonly WorkItemsQueue _workItemsQueue = new WorkItemsQueue(); + private readonly WorkItemsQueue m_workItemsQueue = new(); /// /// Count the work items handled. /// Used by the performance counter. /// - private int _workItemsProcessed; + private int m_workItemsProcessed; /// /// Number of threads that currently work (not idle). /// - private int _inUseWorkerThreads; + private int m_inUseWorkerThreads; /// /// Stores a copy of the original STPStartInfo. /// It is used to change the MinThread and MaxThreads /// - private STPStartInfo _stpStartInfo; + private readonly STPStartInfo m_stpStartInfo; /// /// Total number of work items that are stored in the work items queue /// plus the work items that the threads in the pool are working on. /// - private int _currentWorkItemsCount; + private int m_currentWorkItemsCount; /// /// Signaled when the thread pool is idle, i.e. no thread is busy /// and the work items queue is empty /// - private ManualResetEvent _isIdleWaitHandle = new ManualResetEvent(true); + private ManualResetEvent m_isIdleWaitHandle = new(true); /// /// An event to signal all the threads to quit immediately. /// - private ManualResetEvent _shuttingDownEvent = new ManualResetEvent(false); + private ManualResetEvent m_shuttingDownEvent = new(false); /// /// A flag to indicate if the Smart Thread Pool is now suspended. /// - private bool _isSuspended; + private bool m_isSuspended; /// /// A flag to indicate the threads to quit. /// - private bool _shutdown; + private bool m_shutdown; /// /// Counts the threads created in the pool. /// It is used to name the threads. /// - private int _threadCounter; + private int m_threadCounter; /// /// Indicate that the SmartThreadPool has been disposed /// - private bool _isDisposed; + private bool m_isDisposed; - private static long _lastThreadCreateTS = long.MinValue; + private static long m_lastThreadCreateTS = long.MinValue; /// /// Holds all the WorkItemsGroup instaces that have at least one /// work item int the SmartThreadPool /// This variable is used in case of Shutdown /// - private readonly ConcurrentDictionary _workItemsGroups = new ConcurrentDictionary(); + private readonly ConcurrentDictionary m_workItemsGroups = new(); /// /// A common object for all the work items int the STP /// so we can mark them to cancel in O(1) /// - private CanceledWorkItemsGroup _canceledSmartThreadPool = new CanceledWorkItemsGroup(); - - /// - /// Windows STP performance counters - /// - private ISTPInstancePerformanceCounters _windowsPCs = NullSTPInstancePerformanceCounters.Instance; - - /// - /// Local STP performance counters - /// - private ISTPInstancePerformanceCounters _localPCs = NullSTPInstancePerformanceCounters.Instance; + private CanceledWorkItemsGroup m_canceledSmartThreadPool = new(); /// /// An event to call after a thread is created, but before /// it's first use. /// - private event ThreadInitializationHandler _onThreadInitialization; + private event ThreadInitializationHandler m_onThreadInitialization; /// /// An event to call when a thread is about to exit, after /// it is no longer belong to the pool. /// - private event ThreadTerminationHandler _onThreadTermination; + private event ThreadTerminationHandler m_onThreadTermination; #endregion @@ -323,7 +312,7 @@ public partial class SmartThreadPool : WorkItemsGroupBase, IDisposable ///
public SmartThreadPool() { - _stpStartInfo = new STPStartInfo(); + m_stpStartInfo = new STPStartInfo(); Initialize(); } @@ -333,7 +322,7 @@ public SmartThreadPool() /// Idle timeout in milliseconds public SmartThreadPool(int idleTimeout) { - _stpStartInfo = new STPStartInfo + m_stpStartInfo = new STPStartInfo { IdleTimeout = idleTimeout, }; @@ -345,11 +334,9 @@ public SmartThreadPool(int idleTimeout) ///
/// Idle timeout in milliseconds /// Upper limit of threads in the pool - public SmartThreadPool( - int idleTimeout, - int maxWorkerThreads) + public SmartThreadPool(int idleTimeout, int maxWorkerThreads) { - _stpStartInfo = new STPStartInfo + m_stpStartInfo = new STPStartInfo { IdleTimeout = idleTimeout, MaxWorkerThreads = maxWorkerThreads, @@ -363,12 +350,9 @@ public SmartThreadPool( /// Idle timeout in milliseconds /// Upper limit of threads in the pool /// Lower limit of threads in the pool - public SmartThreadPool( - int idleTimeout, - int maxWorkerThreads, - int minWorkerThreads) + public SmartThreadPool(int idleTimeout, int maxWorkerThreads, int minWorkerThreads) { - _stpStartInfo = new STPStartInfo + m_stpStartInfo = new STPStartInfo { IdleTimeout = idleTimeout, MaxWorkerThreads = maxWorkerThreads, @@ -383,40 +367,22 @@ public SmartThreadPool( /// A SmartThreadPool configuration that overrides the default behavior public SmartThreadPool(STPStartInfo stpStartInfo) { - _stpStartInfo = new STPStartInfo(stpStartInfo); + m_stpStartInfo = new STPStartInfo(stpStartInfo); Initialize(); } private void Initialize() { - Name = _stpStartInfo.ThreadPoolName; + Name = m_stpStartInfo.ThreadPoolName; ValidateSTPStartInfo(); // _stpStartInfoRW stores a read/write copy of the STPStartInfo. // Actually only MaxWorkerThreads and MinWorkerThreads are overwritten - _isSuspended = _stpStartInfo.StartSuspended; - - if (null != _stpStartInfo.PerformanceCounterInstanceName) - { - try - { - _windowsPCs = new STPInstancePerformanceCounters(_stpStartInfo.PerformanceCounterInstanceName); - } - catch (Exception e) - { - Debug.WriteLine("Unable to create Performance Counters: " + e); - _windowsPCs = NullSTPInstancePerformanceCounters.Instance; - } - } - - if (_stpStartInfo.EnableLocalPerformanceCounters) - { - _localPCs = new LocalSTPInstancePerformanceCounters(); - } + m_isSuspended = m_stpStartInfo.StartSuspended; // If the STP is not started suspended then start the threads. - if (!_isSuspended) + if (!m_isSuspended) { StartOptimalNumberOfThreads(); } @@ -425,35 +391,35 @@ private void Initialize() private void StartOptimalNumberOfThreads() { int threadsCount; - lock (_workerThreadsLock) + lock (m_workerThreadsLock) { - threadsCount = _workItemsQueue.Count; - if (threadsCount == _stpStartInfo.MinWorkerThreads) + threadsCount = m_workItemsQueue.Count; + if (threadsCount == m_stpStartInfo.MinWorkerThreads) return; - if (threadsCount < _stpStartInfo.MinWorkerThreads) - threadsCount = _stpStartInfo.MinWorkerThreads; - else if (threadsCount > _stpStartInfo.MaxWorkerThreads) - threadsCount = _stpStartInfo.MaxWorkerThreads; - threadsCount -= _workerThreads.Count; + if (threadsCount < m_stpStartInfo.MinWorkerThreads) + threadsCount = m_stpStartInfo.MinWorkerThreads; + else if (threadsCount > m_stpStartInfo.MaxWorkerThreads) + threadsCount = m_stpStartInfo.MaxWorkerThreads; + threadsCount -= m_workerThreads.Count; } StartThreads(threadsCount); } private void ValidateSTPStartInfo() { - if (_stpStartInfo.MinWorkerThreads < 0) + if (m_stpStartInfo.MinWorkerThreads < 0) { throw new ArgumentOutOfRangeException( "MinWorkerThreads", "MinWorkerThreads cannot be negative"); } - if (_stpStartInfo.MaxWorkerThreads <= 0) + if (m_stpStartInfo.MaxWorkerThreads <= 0) { throw new ArgumentOutOfRangeException( "MaxWorkerThreads", "MaxWorkerThreads must be greater than zero"); } - if (_stpStartInfo.MinWorkerThreads > _stpStartInfo.MaxWorkerThreads) + if (m_stpStartInfo.MinWorkerThreads > m_stpStartInfo.MaxWorkerThreads) { throw new ArgumentOutOfRangeException( "MinWorkerThreads, maxWorkerThreads", @@ -461,14 +427,6 @@ private void ValidateSTPStartInfo() } } - private static void ValidateCallback(Delegate callback) - { - if (callback.GetInvocationList().Length > 1) - { - throw new NotSupportedException("SmartThreadPool doesn't support delegates chains"); - } - } - #endregion #region Thread Processing @@ -481,10 +439,7 @@ private static void ValidateCallback(Delegate callback) /// private WorkItem Dequeue() { - WorkItem workItem = - _workItemsQueue.DequeueWorkItem(_stpStartInfo.IdleTimeout, _shuttingDownEvent); - - return workItem; + return m_workItemsQueue.DequeueWorkItem(m_stpStartInfo.IdleTimeout, m_shuttingDownEvent); } /// @@ -494,16 +449,16 @@ private WorkItem Dequeue() internal override void Enqueue(WorkItem workItem) { // Make sure the workItem is not null - Debug.Assert(null != workItem); + Debug.Assert(workItem is not null); IncrementWorkItemsCount(); - workItem.CanceledSmartThreadPool = _canceledSmartThreadPool; + workItem.CanceledSmartThreadPool = m_canceledSmartThreadPool; workItem.WorkItemIsQueued(); - _workItemsQueue.EnqueueWorkItem(workItem); + m_workItemsQueue.EnqueueWorkItem(workItem); // If all the threads are busy then try to create a new one - if (_currentWorkItemsCount > _workerThreads.Count) + if (m_currentWorkItemsCount > m_workerThreads.Count) { StartThreads(1); } @@ -511,53 +466,42 @@ internal override void Enqueue(WorkItem workItem) private void IncrementWorkItemsCount() { - _windowsPCs.SampleWorkItems(_workItemsQueue.Count, _workItemsProcessed); - _localPCs.SampleWorkItems(_workItemsQueue.Count, _workItemsProcessed); - - int count = Interlocked.Increment(ref _currentWorkItemsCount); + int count = Interlocked.Increment(ref m_currentWorkItemsCount); //Trace.WriteLine("WorkItemsCount = " + _currentWorkItemsCount.ToString()); if (count == 1) { IsIdle = false; - _isIdleWaitHandle.Reset(); + m_isIdleWaitHandle.Reset(); } } private void DecrementWorkItemsCount() { - int count = Interlocked.Decrement(ref _currentWorkItemsCount); + int count = Interlocked.Decrement(ref m_currentWorkItemsCount); //Trace.WriteLine("WorkItemsCount = " + _currentWorkItemsCount.ToString()); if (count == 0) { IsIdle = true; - _isIdleWaitHandle.Set(); - } - - Interlocked.Increment(ref _workItemsProcessed); - - if (!_shutdown) - { - // The counter counts even if the work item was cancelled - _windowsPCs.SampleWorkItems(_workItemsQueue.Count, _workItemsProcessed); - _localPCs.SampleWorkItems(_workItemsQueue.Count, _workItemsProcessed); + m_isIdleWaitHandle.Set(); } + Interlocked.Increment(ref m_workItemsProcessed); } private int baseWorkIDs = Environment.TickCount; internal void RegisterWorkItemsGroup(IWorkItemsGroup workItemsGroup) { int localID = Interlocked.Increment(ref baseWorkIDs); - while (_workItemsGroups.ContainsKey(localID)) + while (m_workItemsGroups.ContainsKey(localID)) localID = Interlocked.Increment(ref baseWorkIDs); workItemsGroup.localID = localID; - _workItemsGroups[localID] = workItemsGroup; + m_workItemsGroups[localID] = (WorkItemsGroup)workItemsGroup; } internal void UnregisterWorkItemsGroup(IWorkItemsGroup workItemsGroup) { - _workItemsGroups.TryRemove(workItemsGroup.localID, out IWorkItemsGroup dummy); + m_workItemsGroups.TryRemove(workItemsGroup.localID, out WorkItemsGroup _); } /// @@ -566,14 +510,9 @@ internal void UnregisterWorkItemsGroup(IWorkItemsGroup workItemsGroup) /// private void InformCompleted() { - // There is no need to lock the two methods together - // since only the current thread removes itself - // and the _workerThreads is a synchronized dictionary - if (_workerThreads.TryRemove(Thread.CurrentThread.ManagedThreadId, out ThreadEntry te)) + if (m_workerThreads.TryRemove(Environment.CurrentManagedThreadId, out ThreadEntry te)) { te.Clean(); - _windowsPCs.SampleThreads(_workerThreads.Count, _inUseWorkerThreads); - _localPCs.SampleThreads(_workerThreads.Count, _inUseWorkerThreads); } } @@ -583,24 +522,24 @@ private void InformCompleted() /// The number of threads to start private void StartThreads(int threadsCount) { - if (_isSuspended) + if (m_isSuspended) return; - lock (_workerThreadsLock) + lock (m_workerThreadsLock) { // Don't start threads on shut down - if (_shutdown) + if (m_shutdown) return; - int tmpcount = _workerThreads.Count; - if(tmpcount > _stpStartInfo.MinWorkerThreads) + int tmpcount = m_workerThreads.Count; + if(tmpcount > m_stpStartInfo.MinWorkerThreads) { - long last = Interlocked.Read(ref _lastThreadCreateTS); + long last = Interlocked.Read(ref m_lastThreadCreateTS); if (DateTime.UtcNow.Ticks - last < 50 * TimeSpan.TicksPerMillisecond) return; } - tmpcount = _stpStartInfo.MaxWorkerThreads - tmpcount; + tmpcount = m_stpStartInfo.MaxWorkerThreads - tmpcount; if (threadsCount > tmpcount) threadsCount = tmpcount; @@ -608,45 +547,41 @@ private void StartThreads(int threadsCount) { // Create a new thread Thread workerThread; - if(_stpStartInfo.SuppressFlow) + if(m_stpStartInfo.SuppressFlow) { using(ExecutionContext.SuppressFlow()) { workerThread = - _stpStartInfo.MaxStackSize.HasValue - ? new Thread(ProcessQueuedItems, _stpStartInfo.MaxStackSize.Value) + m_stpStartInfo.MaxStackSize.HasValue + ? new Thread(ProcessQueuedItems, m_stpStartInfo.MaxStackSize.Value) : new Thread(ProcessQueuedItems); } } else { workerThread = - _stpStartInfo.MaxStackSize.HasValue - ? new Thread(ProcessQueuedItems, _stpStartInfo.MaxStackSize.Value) + m_stpStartInfo.MaxStackSize.HasValue + ? new Thread(ProcessQueuedItems, m_stpStartInfo.MaxStackSize.Value) : new Thread(ProcessQueuedItems); } // Configure the new thread and start it - workerThread.IsBackground = _stpStartInfo.AreThreadsBackground; + workerThread.IsBackground = m_stpStartInfo.AreThreadsBackground; - if (_stpStartInfo.ApartmentState != ApartmentState.Unknown) - workerThread.SetApartmentState(_stpStartInfo.ApartmentState); + if (m_stpStartInfo.ApartmentState != ApartmentState.Unknown) + workerThread.SetApartmentState(m_stpStartInfo.ApartmentState); - workerThread.Priority = _stpStartInfo.ThreadPriority; + workerThread.Priority = m_stpStartInfo.ThreadPriority; + workerThread.Name = $"STP:{Name}:{m_threadCounter}"; - workerThread.Name = string.Format("STP:{0}:{1}", Name, _threadCounter); - - Interlocked.Exchange(ref _lastThreadCreateTS, DateTime.UtcNow.Ticks); - ++_threadCounter; + Interlocked.Exchange(ref m_lastThreadCreateTS, DateTime.UtcNow.Ticks); + ++m_threadCounter; --threadsCount; // Add it to the dictionary and update its creation time. - _workerThreads[workerThread.ManagedThreadId] = new ThreadEntry(this, workerThread); + m_workerThreads[workerThread.ManagedThreadId] = new ThreadEntry(this, workerThread); workerThread.Start(); - - _windowsPCs.SampleThreads(_workerThreads.Count, _inUseWorkerThreads); - _localPCs.SampleThreads(_workerThreads.Count, _inUseWorkerThreads); } } } @@ -658,7 +593,7 @@ private void ProcessQueuedItems() { // Keep the entry of the dictionary as thread's variable to avoid the synchronization locks // of the dictionary. - CurrentThreadEntry = _workerThreads[Thread.CurrentThread.ManagedThreadId]; + CurrentThreadEntry = m_workerThreads[Environment.CurrentManagedThreadId]; bool informedCompleted = false; FireOnThreadInitialization(); @@ -666,20 +601,20 @@ private void ProcessQueuedItems() try { bool bInUseWorkerThreadsWasIncremented = false; - int maxworkers = _stpStartInfo.MaxWorkerThreads; - int minworkers = _stpStartInfo.MinWorkerThreads; + int maxworkers = m_stpStartInfo.MaxWorkerThreads; + int minworkers = m_stpStartInfo.MinWorkerThreads; // Process until shutdown. - while (!_shutdown) + while (!m_shutdown) { // The following block handles the when the MaxWorkerThreads has been // incremented by the user at run-time. // Double lock for quit. - if (_workerThreads.Count > maxworkers) + if (m_workerThreads.Count > maxworkers) { - lock (_workerThreadsLock) + lock (m_workerThreadsLock) { - if (_workerThreads.Count > maxworkers) + if (m_workerThreads.Count > maxworkers) { // Inform that the thread is quiting and then quit. // This method must be called within this lock or else @@ -698,14 +633,14 @@ private void ProcessQueuedItems() WorkItem workItem = Dequeue(); // On timeout or shut down. - if (workItem == null) + if (workItem is null) { // Double lock for quit. - if (_workerThreads.Count > minworkers) + if (m_workerThreads.Count > minworkers) { - lock (_workerThreadsLock) + lock (m_workerThreadsLock) { - if (_workerThreads.Count > minworkers) + if (m_workerThreads.Count > minworkers) { // Inform that the thread is quiting and then quit. // This method must be called within this lock or else @@ -754,9 +689,7 @@ private void ProcessQueuedItems() // Execute the callback. Make sure to accurately // record how many callbacks are currently executing. - int inUseWorkerThreads = Interlocked.Increment(ref _inUseWorkerThreads); - _windowsPCs.SampleThreads(_workerThreads.Count, inUseWorkerThreads); - _localPCs.SampleThreads(_workerThreads.Count, inUseWorkerThreads); + int inUseWorkerThreads = Interlocked.Increment(ref m_inUseWorkerThreads); // Mark that the _inUseWorkerThreads incremented, so in the finally{} // statement we will decrement it correctly. @@ -784,9 +717,7 @@ private void ProcessQueuedItems() // increment _inUseWorkerThreads. if (bInUseWorkerThreadsWasIncremented) { - int inUseWorkerThreads = Interlocked.Decrement(ref _inUseWorkerThreads); - _windowsPCs.SampleThreads(_workerThreads.Count, inUseWorkerThreads); - _localPCs.SampleThreads(_workerThreads.Count, inUseWorkerThreads); + int inUseWorkerThreads = Interlocked.Decrement(ref m_inUseWorkerThreads); } // Notify that the work item has been completed. @@ -799,38 +730,36 @@ private void ProcessQueuedItems() } } } + /* catch (ThreadAbortException tae) { - tae.GetHashCode(); + //tae.GetHashCode(); // Handle the abort exception gracfully. - Thread.ResetAbort(); + //Thread.ResetAbort(); } + */ catch (Exception e) { - Debug.Assert(null != e); + Debug.Assert(e is not null); } finally { if(!informedCompleted) InformCompleted(); FireOnThreadTermination(); - _workItemsQueue.CloseThreadWaiter(); + m_workItemsQueue.CloseThreadWaiter(); CurrentThreadEntry = null; } } - private void ExecuteWorkItem(WorkItem workItem) + private static void ExecuteWorkItem(WorkItem workItem) { - _windowsPCs.SampleWorkItemsWaitTime(workItem.WaitingTime); - _localPCs.SampleWorkItemsWaitTime(workItem.WaitingTime); try { workItem.Execute(); } finally { - _windowsPCs.SampleWorkItemsProcessTime(workItem.ProcessTime); - _localPCs.SampleWorkItemsProcessTime(workItem.ProcessTime); } } @@ -841,7 +770,7 @@ private void ExecuteWorkItem(WorkItem workItem) private void ValidateWaitForIdle() { - if (null != CurrentThreadEntry && CurrentThreadEntry.AssociatedSmartThreadPool == this) + if (CurrentThreadEntry is not null && CurrentThreadEntry.AssociatedSmartThreadPool == this) { throw new NotSupportedException( "WaitForIdle cannot be called from a thread on its SmartThreadPool, it causes a deadlock"); @@ -850,15 +779,15 @@ private void ValidateWaitForIdle() internal static void ValidateWorkItemsGroupWaitForIdle(IWorkItemsGroup workItemsGroup) { - if (CurrentThreadEntry != null) + if (CurrentThreadEntry is not null) ValidateWorkItemsGroupWaitForIdleImpl(workItemsGroup, CurrentThreadEntry.CurrentWorkItem); } [MethodImpl(MethodImplOptions.NoInlining)] private static void ValidateWorkItemsGroupWaitForIdleImpl(IWorkItemsGroup workItemsGroup, WorkItem workItem) { - if ((null != workItemsGroup) && - (null != workItem) && + if ((workItemsGroup is not null) && + (workItem is not null) && workItem.WasQueuedBy(workItemsGroup)) { throw new NotSupportedException("WaitForIdle cannot be called from a thread on its SmartThreadPool, it causes a deadlock"); @@ -870,110 +799,77 @@ private static void ValidateWorkItemsGroupWaitForIdleImpl(IWorkItemsGroup workIt /// public void Shutdown() { - Shutdown(true, 0); + Shutdown(0); } /// /// Force the SmartThreadPool to shutdown with timeout /// - public void Shutdown(bool forceAbort, TimeSpan timeout) + public void Shutdown(TimeSpan timeout) { - Shutdown(forceAbort, (int)timeout.TotalMilliseconds); + Shutdown((int)timeout.TotalMilliseconds); } /// /// Empties the queue of work items and abort the threads in the pool. /// - public void Shutdown(bool forceAbort, int millisecondsTimeout) + public void Shutdown(int millisecondsTimeout) { ValidateNotDisposed(); - ISTPInstancePerformanceCounters pcs = _windowsPCs; - - if (NullSTPInstancePerformanceCounters.Instance != _windowsPCs) - { - // Set the _pcs to "null" to stop updating the performance - // counters - _windowsPCs = NullSTPInstancePerformanceCounters.Instance; - - pcs.Dispose(); - } - ThreadEntry[] threadEntries; - lock (_workerThreadsLock) + lock (m_workerThreadsLock) { // Shutdown the work items queue - _workItemsQueue.Dispose(); + m_workItemsQueue.Dispose(); // Signal the threads to exit - _shutdown = true; - _shuttingDownEvent.Set(); + m_shutdown = true; + m_shuttingDownEvent.Set(); // Make a copy of the threads' references in the pool - threadEntries = new ThreadEntry[_workerThreads.Count]; - _workerThreads.Values.CopyTo(threadEntries, 0); - _workerThreads.Clear(); + threadEntries = new ThreadEntry[m_workerThreads.Count]; + m_workerThreads.Values.CopyTo(threadEntries, 0); + m_workerThreads.Clear(); } int millisecondsLeft = millisecondsTimeout; Stopwatch stopwatch = Stopwatch.StartNew(); - //DateTime start = DateTime.UtcNow; - bool waitInfinitely = (Timeout.Infinite == millisecondsTimeout); - bool timeout = false; - - // Each iteration we update the time left for the timeout. - foreach (ThreadEntry te in threadEntries) + if (millisecondsLeft >= Timeout.Infinite) { - Thread thread = te.WorkThread; - - // Join don't work with negative numbers - if (!waitInfinitely && (millisecondsLeft < 0)) + foreach (ThreadEntry te in threadEntries) { - timeout = true; - break; - } + if (te is null) + continue; - // Wait for the thread to terminate - bool success = thread.Join(millisecondsLeft); - if (!success) - { - timeout = true; - break; - } + Thread thread = te.WorkThread; + if(thread is null) + continue; - if (!waitInfinitely) - { - // Update the time left to wait - //TimeSpan ts = DateTime.UtcNow - start; - millisecondsLeft = millisecondsTimeout - (int)stopwatch.ElapsedMilliseconds; + if (thread.IsAlive) + { + // Wait for the thread to terminate + _ = thread.Join(millisecondsLeft); + + if (millisecondsLeft > 0) + { + // Update the time left to wait + millisecondsLeft = millisecondsTimeout - (int)stopwatch.ElapsedMilliseconds; + if (millisecondsLeft < 0) + millisecondsLeft= 0; + } + } + te.WorkThread = null; } - te.WorkThread = null; } - - if (timeout && forceAbort) + else { - // Abort the threads in the pool + // there is no Abort in dotnet > 5, so we can't do anything foreach (ThreadEntry te in threadEntries) { - Thread thread = te.WorkThread; - if ((thread != null) && thread.IsAlive ) - { - try - { - thread.Abort(); // Shutdown - te.WorkThread = null; - } - catch (SecurityException e) - { - e.GetHashCode(); - } - catch (ThreadStateException ex) - { - ex.GetHashCode(); - // In case the thread has been terminated - // after the check if it is alive. - } - } + if (te is null) + continue; + te.WorkThread = null; } } } @@ -1146,7 +1042,7 @@ public static int WaitAny( IWaitableResult[] waitableResults, int millisecondsTi /// A reference to the WorkItemsGroup public IWorkItemsGroup CreateWorkItemsGroup(int concurrency) { - IWorkItemsGroup workItemsGroup = new WorkItemsGroup(this, concurrency, _stpStartInfo); + IWorkItemsGroup workItemsGroup = new WorkItemsGroup(this, concurrency, m_stpStartInfo); return workItemsGroup; } @@ -1166,9 +1062,9 @@ public IWorkItemsGroup CreateWorkItemsGroup(int concurrency, WIGStartInfo wigSta private void FireOnThreadInitialization() { - if (null != _onThreadInitialization) + if (null != m_onThreadInitialization) { - foreach (ThreadInitializationHandler tih in _onThreadInitialization.GetInvocationList()) + foreach (ThreadInitializationHandler tih in m_onThreadInitialization.GetInvocationList()) { try { @@ -1185,9 +1081,9 @@ private void FireOnThreadInitialization() private void FireOnThreadTermination() { - if (null != _onThreadTermination) + if (null != m_onThreadTermination) { - foreach (ThreadTerminationHandler tth in _onThreadTermination.GetInvocationList()) + foreach (ThreadTerminationHandler tth in m_onThreadTermination.GetInvocationList()) { try { @@ -1210,8 +1106,8 @@ private void FireOnThreadTermination() /// public event ThreadInitializationHandler OnThreadInitialization { - add { _onThreadInitialization += value; } - remove { _onThreadInitialization -= value; } + add { m_onThreadInitialization += value; } + remove { m_onThreadInitialization -= value; } } /// @@ -1220,14 +1116,14 @@ public event ThreadInitializationHandler OnThreadInitialization /// public event ThreadTerminationHandler OnThreadTermination { - add { _onThreadTermination += value; } - remove { _onThreadTermination -= value; } + add { m_onThreadTermination += value; } + remove { m_onThreadTermination -= value; } } internal void CancelAbortWorkItemsGroup(WorkItemsGroup wig) { - foreach (ThreadEntry threadEntry in _workerThreads.Values) + foreach (ThreadEntry threadEntry in m_workerThreads.Values) { WorkItem workItem = threadEntry.CurrentWorkItem; if (null != workItem && !workItem.IsCanceled && workItem.WasQueuedBy(wig)) @@ -1249,17 +1145,17 @@ public int MinThreads get { ValidateNotDisposed(); - return _stpStartInfo.MinWorkerThreads; + return m_stpStartInfo.MinWorkerThreads; } set { Debug.Assert(value >= 0); - Debug.Assert(value <= _stpStartInfo.MaxWorkerThreads); - if (_stpStartInfo.MaxWorkerThreads < value) + Debug.Assert(value <= m_stpStartInfo.MaxWorkerThreads); + if (m_stpStartInfo.MaxWorkerThreads < value) { - _stpStartInfo.MaxWorkerThreads = value; + m_stpStartInfo.MaxWorkerThreads = value; } - _stpStartInfo.MinWorkerThreads = value; + m_stpStartInfo.MinWorkerThreads = value; StartOptimalNumberOfThreads(); } } @@ -1272,18 +1168,18 @@ public int MaxThreads get { ValidateNotDisposed(); - return _stpStartInfo.MaxWorkerThreads; + return m_stpStartInfo.MaxWorkerThreads; } set { Debug.Assert(value > 0); - Debug.Assert(value >= _stpStartInfo.MinWorkerThreads); - if (_stpStartInfo.MinWorkerThreads > value) + Debug.Assert(value >= m_stpStartInfo.MinWorkerThreads); + if (m_stpStartInfo.MinWorkerThreads > value) { - _stpStartInfo.MinWorkerThreads = value; + m_stpStartInfo.MinWorkerThreads = value; } - _stpStartInfo.MaxWorkerThreads = value; + m_stpStartInfo.MaxWorkerThreads = value; StartOptimalNumberOfThreads(); } } @@ -1296,7 +1192,7 @@ public int ActiveThreads get { ValidateNotDisposed(); - return _workerThreads.Count; + return m_workerThreads.Count; } } @@ -1308,7 +1204,7 @@ public int InUseThreads get { ValidateNotDisposed(); - return _inUseWorkerThreads; + return m_inUseWorkerThreads; } } @@ -1334,7 +1230,7 @@ public static void AbortOnWorkItemCancel() { if (IsWorkItemCanceled) { - Thread.CurrentThread.Abort(); + //Thread.CurrentThread.Abort(); } } @@ -1345,22 +1241,13 @@ public STPStartInfo STPStartInfo { get { - return _stpStartInfo.AsReadOnly(); + return m_stpStartInfo.AsReadOnly(); } } public bool IsShuttingdown { - get { return _shutdown; } - } - - /// - /// Return the local calculated performance counters - /// Available only if STPStartInfo.EnableLocalPerformanceCounters is true. - /// - public ISTPPerformanceCountersReader PerformanceCountersReader - { - get { return (ISTPPerformanceCountersReader)_localPCs; } + get { return m_shutdown; } } #endregion @@ -1375,36 +1262,33 @@ public void Dispose() protected void Dispose(bool disposing) { - if (!_isDisposed) + if (!m_isDisposed) { - if (!_shutdown) + if (!m_shutdown) { Shutdown(); } - if (null != _shuttingDownEvent) + if (m_shuttingDownEvent is not null) { - _shuttingDownEvent.Close(); - _shuttingDownEvent = null; + m_shuttingDownEvent.Close(); + m_shuttingDownEvent = null; } - _workerThreads.Clear(); + m_workerThreads.Clear(); - if (null != _isIdleWaitHandle) + if (m_isIdleWaitHandle is not null) { - _isIdleWaitHandle.Close(); - _isIdleWaitHandle = null; + m_isIdleWaitHandle.Close(); + m_isIdleWaitHandle = null; } - if (_stpStartInfo.EnableLocalPerformanceCounters) - _localPCs.Dispose(); - - _isDisposed = true; + m_isDisposed = true; } } private void ValidateNotDisposed() { - if (_isDisposed) + if (m_isDisposed) { throw new ObjectDisposedException(GetType().ToString(), "The SmartThreadPool has been shutdown"); } @@ -1430,7 +1314,7 @@ public override int WaitingCallbacks get { ValidateNotDisposed(); - return _workItemsQueue.Count; + return m_workItemsQueue.Count; } } @@ -1440,7 +1324,7 @@ public override int WaitingCallbacks /// public override object[] GetStates() { - object[] states = _workItemsQueue.GetStates(); + object[] states = m_workItemsQueue.GetStates(); return states; } @@ -1449,7 +1333,7 @@ public override object[] GetStates() /// public override WIGStartInfo WIGStartInfo { - get { return _stpStartInfo.AsReadOnly(); } + get { return m_stpStartInfo.AsReadOnly(); } } /// @@ -1458,15 +1342,15 @@ public override WIGStartInfo WIGStartInfo /// public override void Start() { - if (!_isSuspended) + if (!m_isSuspended) { return; } - _isSuspended = false; + m_isSuspended = false; - foreach (WorkItemsGroup workItemsGroup in _workItemsGroups.Values) + foreach (WorkItemsGroup workItemsGroup in m_workItemsGroups.Values) { - workItemsGroup.OnSTPIsStarting(); + workItemsGroup?.OnSTPIsStarting(); } StartOptimalNumberOfThreads(); @@ -1478,22 +1362,22 @@ public override void Start() /// True to stop work items by raising ThreadAbortException public override void Cancel(bool abortExecution) { - _canceledSmartThreadPool.IsCanceled = true; - _canceledSmartThreadPool = new CanceledWorkItemsGroup(); + m_canceledSmartThreadPool.IsCanceled = true; + m_canceledSmartThreadPool = new CanceledWorkItemsGroup(); - foreach (WorkItemsGroup workItemsGroup in _workItemsGroups.Values) + foreach (WorkItemsGroup workItemsGroup in m_workItemsGroups.Values) { - workItemsGroup.Cancel(abortExecution); + workItemsGroup?.Cancel(abortExecution); } if (abortExecution) { - foreach (ThreadEntry threadEntry in _workerThreads.Values) + foreach (ThreadEntry threadEntry in m_workerThreads.Values) { if(threadEntry.AssociatedSmartThreadPool == this) { WorkItem workItem = threadEntry.CurrentWorkItem; - if (null != workItem && !workItem.IsCanceled) + if (workItem is not null && !workItem.IsCanceled) { threadEntry.CurrentWorkItem.GetWorkItemResult().Cancel(true); } @@ -1508,7 +1392,7 @@ public override void Cancel(bool abortExecution) public override bool WaitForIdle(int millisecondsTimeout) { ValidateWaitForIdle(); - return STPEventWaitHandle.WaitOne(_isIdleWaitHandle, millisecondsTimeout, false); + return STPEventWaitHandle.WaitOne(m_isIdleWaitHandle, millisecondsTimeout, false); } /// @@ -1545,7 +1429,7 @@ internal override void PreQueueWorkItem() /// Actions to execute public void Join(IEnumerable actions) { - WIGStartInfo wigStartInfo = new WIGStartInfo { StartSuspended = true }; + WIGStartInfo wigStartInfo = new() { StartSuspended = true }; IWorkItemsGroup workItemsGroup = CreateWorkItemsGroup(int.MaxValue, wigStartInfo); foreach (Action action in actions) { @@ -1577,12 +1461,12 @@ private class ChoiceIndex /// Actions to execute public int Choice(IEnumerable actions) { - WIGStartInfo wigStartInfo = new WIGStartInfo { StartSuspended = true }; + WIGStartInfo wigStartInfo = new() { StartSuspended = true }; IWorkItemsGroup workItemsGroup = CreateWorkItemsGroup(int.MaxValue, wigStartInfo); - ManualResetEvent anActionCompleted = new ManualResetEvent(false); + ManualResetEvent anActionCompleted = new(false); - ChoiceIndex choiceIndex = new ChoiceIndex(); + ChoiceIndex choiceIndex = new(); int i = 0; foreach (Action action in actions) @@ -1617,7 +1501,7 @@ public int Choice(params Action[] actions) /// Actions to execute in the order they should run public void Pipe(T pipeState, IEnumerable> actions) { - WIGStartInfo wigStartInfo = new WIGStartInfo { StartSuspended = true }; + WIGStartInfo wigStartInfo = new() { StartSuspended = true }; IWorkItemsGroup workItemsGroup = CreateWorkItemsGroup(1, wigStartInfo); foreach (Action action in actions) { diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.csproj b/ThirdParty/SmartThreadPool/SmartThreadPool.csproj index 7a38cbd3e20..ca82f8193dc 100644 --- a/ThirdParty/SmartThreadPool/SmartThreadPool.csproj +++ b/ThirdParty/SmartThreadPool/SmartThreadPool.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Amib.Threading Amib.Threading Smart Thread Pool diff --git a/ThirdParty/SmartThreadPool/WorkItem.WorkItemResult.cs b/ThirdParty/SmartThreadPool/WorkItem.WorkItemResult.cs index 2d2ac61bfab..6374d94ed62 100644 --- a/ThirdParty/SmartThreadPool/WorkItem.WorkItemResult.cs +++ b/ThirdParty/SmartThreadPool/WorkItem.WorkItemResult.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading; namespace Amib.Threading.Internal @@ -108,7 +106,7 @@ public object State { get { - return _workItem._state; + return _workItem.m_state; } } @@ -127,7 +125,7 @@ public object Result /// public object Exception { - get { return _workItem._exception; } + get { return _workItem.m_exception; } } #endregion diff --git a/ThirdParty/SmartThreadPool/WorkItem.cs b/ThirdParty/SmartThreadPool/WorkItem.cs index db54a15714e..db78b1019f2 100644 --- a/ThirdParty/SmartThreadPool/WorkItem.cs +++ b/ThirdParty/SmartThreadPool/WorkItem.cs @@ -1,6 +1,6 @@ using System; -using System.Threading; using System.Diagnostics; +using System.Threading; namespace Amib.Threading.Internal { @@ -54,92 +54,92 @@ private static bool IsValidStatesTransition(WorkItemState currentState, WorkItem /// /// Callback delegate for the callback. /// - private WorkItemCallback _callback; - private WaitCallback _callbackNoResult; + private WorkItemCallback m_callback; + private WaitCallback m_callbackNoResult; /// /// State with which to call the callback delegate. /// - private object _state; + private object m_state; /// /// Stores the caller's context /// - private ExecutionContext _callerContext = null; + private ExecutionContext m_callerContext = null; /// /// Holds the result of the mehtod /// - private object _result; + private object m_result; /// /// Hold the exception if the method threw it /// - private Exception _exception; + private Exception m_exception; /// /// Hold the state of the work item /// - private WorkItemState _workItemState; + private WorkItemState m_workItemState; /// /// A ManualResetEvent to indicate that the result is ready /// - private ManualResetEvent _workItemCompleted; + private ManualResetEvent m_workItemCompleted; /// /// A reference count to the _workItemCompleted. /// When it reaches to zero _workItemCompleted is Closed /// - private int _workItemCompletedRefCount; + private int m_workItemCompletedRefCount; /// /// Represents the result state of the work item /// - private readonly WorkItemResult _workItemResult; + private readonly WorkItemResult m_workItemResult; /// /// Work item info /// - private readonly WorkItemInfo _workItemInfo; + private readonly WorkItemInfo m_workItemInfo; /// /// Called when the WorkItem starts /// - private event WorkItemStateCallback _workItemStartedEvent; + private event WorkItemStateCallback m_workItemStartedEvent; /// /// Called when the WorkItem completes /// - private event WorkItemStateCallback _workItemCompletedEvent; + private event WorkItemStateCallback m_workItemCompletedEvent; /// /// A reference to an object that indicates whatever the /// WorkItemsGroup has been canceled /// - private CanceledWorkItemsGroup _canceledWorkItemsGroup = CanceledWorkItemsGroup.NotCanceledWorkItemsGroup; + private CanceledWorkItemsGroup m_canceledWorkItemsGroup = CanceledWorkItemsGroup.NotCanceledWorkItemsGroup; /// /// A reference to an object that indicates whatever the /// SmartThreadPool has been canceled /// - private CanceledWorkItemsGroup _canceledSmartThreadPool = CanceledWorkItemsGroup.NotCanceledWorkItemsGroup; + private CanceledWorkItemsGroup m_canceledSmartThreadPool = CanceledWorkItemsGroup.NotCanceledWorkItemsGroup; /// /// The work item group this work item belong to. /// - private readonly IWorkItemsGroup _workItemsGroup; + private readonly IWorkItemsGroup m_workItemsGroup; /// /// The thread that executes this workitem. /// This field is available for the period when the work item is executed, before and after it is null. /// - private Thread _executingThread; + private Thread m_executingThread; /// /// The absulote time when the work item will be timeout /// - private long _expirationTime; + private long m_expirationTime; #region Performance Counter fields @@ -179,7 +179,7 @@ internal WorkItemInfo WorkItemInfo { get { - return _workItemInfo; + return m_workItemInfo; } } @@ -199,42 +199,46 @@ internal WorkItemInfo WorkItemInfo /// that meant to run the callback public WorkItem(IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { - _workItemsGroup = workItemsGroup; - _workItemInfo = workItemInfo; + m_workItemsGroup = workItemsGroup; + m_workItemInfo = workItemInfo; - if (_workItemInfo.UseCallerCallContext && !ExecutionContext.IsFlowSuppressed()) + if (m_workItemInfo.UseCallerCallContext && !ExecutionContext.IsFlowSuppressed()) { ExecutionContext ec = ExecutionContext.Capture(); - if (ec != null) - _callerContext = ec.CreateCopy(); - ec.Dispose(); - ec = null; + if (ec is not null) + { + m_callerContext = ec.CreateCopy(); + ec.Dispose(); + ec = null; + } } - _callback = callback; - _callbackNoResult = null; - _state = state; - _workItemResult = new WorkItemResult(this); + m_callback = callback; + m_callbackNoResult = null; + m_state = state; + m_workItemResult = new WorkItemResult(this); Initialize(); } public WorkItem(IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WaitCallback callback, object state) { - _workItemsGroup = workItemsGroup; - _workItemInfo = workItemInfo; + m_workItemsGroup = workItemsGroup; + m_workItemInfo = workItemInfo; - if (_workItemInfo.UseCallerCallContext && !ExecutionContext.IsFlowSuppressed()) + if (m_workItemInfo.UseCallerCallContext && !ExecutionContext.IsFlowSuppressed()) { ExecutionContext ec = ExecutionContext.Capture(); - if (ec != null) - _callerContext = ec.CreateCopy(); - ec.Dispose(); - ec = null; + if (ec is not null) + { + m_callerContext = ec.CreateCopy(); + ec.Dispose(); + ec = null; + } } - _callbackNoResult = callback; - _state = state; - _workItemResult = new WorkItemResult(this); + m_callbackNoResult = callback; + m_state = state; + m_workItemResult = new WorkItemResult(this); Initialize(); } @@ -242,18 +246,18 @@ internal void Initialize() { // The _workItemState is changed directly instead of using the SetWorkItemState // method since we don't want to go throught IsValidStateTransition. - _workItemState = WorkItemState.InQueue; + m_workItemState = WorkItemState.InQueue; - _workItemCompleted = null; - _workItemCompletedRefCount = 0; + m_workItemCompleted = null; + m_workItemCompletedRefCount = 0; _waitingOnQueueStopwatch = new Stopwatch(); _processingStopwatch = new Stopwatch(); - _expirationTime = _workItemInfo.Timeout > 0 ? DateTime.UtcNow.Ticks + _workItemInfo.Timeout * TimeSpan.TicksPerMillisecond : long.MaxValue; + m_expirationTime = m_workItemInfo.Timeout > 0 ? DateTime.UtcNow.Ticks + m_workItemInfo.Timeout * TimeSpan.TicksPerMillisecond : long.MaxValue; } internal bool WasQueuedBy(IWorkItemsGroup workItemsGroup) { - return (workItemsGroup == _workItemsGroup); + return (workItemsGroup == m_workItemsGroup); } @@ -263,14 +267,14 @@ internal bool WasQueuedBy(IWorkItemsGroup workItemsGroup) internal CanceledWorkItemsGroup CanceledWorkItemsGroup { - get { return _canceledWorkItemsGroup; } - set { _canceledWorkItemsGroup = value; } + get { return m_canceledWorkItemsGroup; } + set { m_canceledWorkItemsGroup = value; } } internal CanceledWorkItemsGroup CanceledSmartThreadPool { - get { return _canceledSmartThreadPool; } - set { _canceledSmartThreadPool = value; } + get { return m_canceledSmartThreadPool; } + set { m_canceledSmartThreadPool = value; } } /// @@ -289,8 +293,8 @@ public bool StartingWorkItem() { if (IsCanceled) { - if ((_workItemInfo.PostExecuteWorkItemCallback != null) && - ((_workItemInfo.CallToPostExecute & CallToPostExecute.WhenWorkItemCanceled) == CallToPostExecute.WhenWorkItemCanceled)) + if ((m_workItemInfo.PostExecuteWorkItemCallback is not null) && + ((m_workItemInfo.CallToPostExecute & CallToPostExecute.WhenWorkItemCanceled) == CallToPostExecute.WhenWorkItemCanceled)) { return true; } @@ -301,7 +305,7 @@ public bool StartingWorkItem() Debug.Assert(WorkItemState.InQueue == GetWorkItemState()); // No need for a lock yet, only after the state has changed to InProgress - _executingThread = Thread.CurrentThread; + m_executingThread = Thread.CurrentThread; SetWorkItemState(WorkItemState.InProgress); } @@ -332,7 +336,7 @@ public void Execute() } // Run the post execute as needed - if ((currentCallToPostExecute & _workItemInfo.CallToPostExecute) != 0) + if ((currentCallToPostExecute & m_workItemInfo.CallToPostExecute) != 0) { PostExecute(); } @@ -344,7 +348,7 @@ internal void FireWorkItemCompleted() { try { - _workItemCompletedEvent?.Invoke(this); + m_workItemCompletedEvent?.Invoke(this); } catch // Suppress exceptions { } @@ -354,7 +358,7 @@ internal void FireWorkItemStarted() { try { - _workItemStartedEvent?.Invoke(this); + m_workItemStartedEvent?.Invoke(this); } catch // Suppress exceptions { } @@ -372,32 +376,24 @@ private void ExecuteWorkItem() { try { - if(_callbackNoResult == null) + if(m_callbackNoResult is null) { - if(_callerContext == null) - result = _callback(_state); + if(m_callerContext is null) + result = m_callback(m_state); else { - ContextCallback _ccb = new ContextCallback( o => - { - result =_callback(o); - }); - - ExecutionContext.Run(_callerContext, _ccb, _state); + ContextCallback _ccb = new( o => { result =m_callback(o); }); + ExecutionContext.Run(m_callerContext, _ccb, m_state); } } else { - if (_callerContext == null) - _callbackNoResult(_state); + if (m_callerContext is null) + m_callbackNoResult(m_state); else { - ContextCallback _ccb = new ContextCallback(o => - { - _callbackNoResult(o); - }); - - ExecutionContext.Run(_callerContext, _ccb, _state); + ContextCallback _ccb = new(o => { m_callbackNoResult(o); }); + ExecutionContext.Run(m_callerContext, _ccb, m_state); } } } @@ -410,9 +406,9 @@ private void ExecuteWorkItem() // Remove the value of the execution thread, so it will be impossible to cancel the work item, // since it is already completed. // Cancelling a work item that already completed may cause the abortion of the next work item!!! - Thread executionThread = Interlocked.CompareExchange(ref _executingThread, null, _executingThread); + Thread executionThread = Interlocked.CompareExchange(ref m_executingThread, null, m_executingThread); - if (null == executionThread) + if (executionThread is null) { // Oops! we are going to be aborted..., Wait here so we can catch the ThreadAbortException Thread.Sleep(60 * 1000); @@ -427,12 +423,11 @@ private void ExecuteWorkItem() // If we got a ThreadAbortException and the STP is not shutting down, it means the // work items was cancelled. tae.GetHashCode(); - if (!SmartThreadPool.CurrentThreadEntry.AssociatedSmartThreadPool.IsShuttingdown) - { - Thread.ResetAbort(); - } + //if (!SmartThreadPool.CurrentThreadEntry.AssociatedSmartThreadPool.IsShuttingdown) + //{ + // Thread.ResetAbort(); + //} } - if (!SmartThreadPool.IsWorkItemCanceled) { SetResult(result, exception); @@ -444,15 +439,15 @@ private void ExecuteWorkItem() /// private void PostExecute() { - if (null != _workItemInfo.PostExecuteWorkItemCallback) + if (m_workItemInfo.PostExecuteWorkItemCallback is not null) { try { - _workItemInfo.PostExecuteWorkItemCallback(_workItemResult); + m_workItemInfo.PostExecuteWorkItemCallback(m_workItemResult); } catch (Exception e) { - Debug.Assert(null != e); + Debug.Assert(e is not null); } } } @@ -465,8 +460,8 @@ private void PostExecute() /// if there was no exception. internal void SetResult(object result, Exception exception) { - _result = result; - _exception = exception; + m_result = result; + m_exception = exception; SignalComplete(false); } @@ -476,7 +471,7 @@ internal void SetResult(object result, Exception exception) /// The work item result internal IWorkItemResult GetWorkItemResult() { - return _workItemResult; + return m_workItemResult; } /// @@ -503,7 +498,7 @@ internal static bool WaitAll( IWaitableResult[] waitableResults, int millisecond WaitHandle[] waitHandles = new WaitHandle[waitableResults.Length]; GetWaitHandles(waitableResults, waitHandles); - if ((null == cancelWaitHandle) && (waitHandles.Length <= 64)) + if ((cancelWaitHandle is null) && (waitHandles.Length <= 64)) { success = STPEventWaitHandle.WaitAll(waitHandles, millisecondsTimeout, exitContext); } @@ -513,15 +508,9 @@ internal static bool WaitAll( IWaitableResult[] waitableResults, int millisecond int millisecondsLeft = millisecondsTimeout; Stopwatch stopwatch = Stopwatch.StartNew(); - WaitHandle[] whs; - if (null != cancelWaitHandle) - { - whs = new WaitHandle[] { null, cancelWaitHandle }; - } - else - { - whs = new WaitHandle[] { null }; - } + WaitHandle[] whs = cancelWaitHandle is null ? + new WaitHandle[] { null } : + new WaitHandle[] { null, cancelWaitHandle }; bool waitInfinitely = (Timeout.Infinite == millisecondsTimeout); // Iterate over the wait handles and wait for each one to complete. @@ -570,15 +559,11 @@ internal static bool WaitAll( IWaitableResult[] waitableResults, int millisecond /// /// The array index of the work item result that satisfied the wait, or WaitTimeout if no work item result satisfied the wait and a time interval equivalent to millisecondsTimeout has passed or the work item has been canceled. /// - internal static int WaitAny( - IWaitableResult[] waitableResults, - int millisecondsTimeout, - bool exitContext, - WaitHandle cancelWaitHandle) + internal static int WaitAny( IWaitableResult[] waitableResults, int millisecondsTimeout, + bool exitContext, WaitHandle cancelWaitHandle) { WaitHandle[] waitHandles; - - if (null != cancelWaitHandle) + if (cancelWaitHandle is not null) { waitHandles = new WaitHandle[waitableResults.Length + 1]; GetWaitHandles(waitableResults, waitHandles); @@ -593,7 +578,7 @@ internal static int WaitAny( int result = STPEventWaitHandle.WaitAny(waitHandles, millisecondsTimeout, exitContext); // Treat cancel as timeout - if (null != cancelWaitHandle) + if (cancelWaitHandle is not null) { if (result == waitableResults.Length) { @@ -611,14 +596,13 @@ internal static int WaitAny( /// /// An array of work item results /// An array of wait handles to fill - private static void GetWaitHandles( - IWaitableResult[] waitableResults, + private static void GetWaitHandles(IWaitableResult[] waitableResults, WaitHandle[] waitHandles) { for (int i = 0; i < waitableResults.Length; ++i) { WorkItemResult wir = waitableResults[i].GetWorkItemResult() as WorkItemResult; - Debug.Assert(null != wir, "All waitableResults must be WorkItemResult objects"); + Debug.Assert(wir is not null, "All waitableResults must be WorkItemResult objects"); waitHandles[i] = wir.GetWorkItem().GetWaitHandle(); } @@ -646,23 +630,23 @@ private WorkItemState GetWorkItemState() { lock (this) { - if (WorkItemState.Completed == _workItemState) + if (WorkItemState.Completed == m_workItemState) { - return _workItemState; + return m_workItemState; } - if (WorkItemState.Canceled != _workItemState && DateTime.UtcNow.Ticks > _expirationTime) + if (WorkItemState.Canceled != m_workItemState && DateTime.UtcNow.Ticks > m_expirationTime) { - _workItemState = WorkItemState.Canceled; - return _workItemState; + m_workItemState = WorkItemState.Canceled; + return m_workItemState; } - if(WorkItemState.InProgress != _workItemState) + if(WorkItemState.InProgress != m_workItemState) { if (CanceledSmartThreadPool.IsCanceled || CanceledWorkItemsGroup.IsCanceled) { return WorkItemState.Canceled; } } - return _workItemState; + return m_workItemState; } } @@ -675,9 +659,9 @@ private void SetWorkItemState(WorkItemState workItemState) { lock (this) { - if (IsValidStatesTransition(_workItemState, workItemState)) + if (IsValidStatesTransition(m_workItemState, workItemState)) { - _workItemState = workItemState; + m_workItemState = workItemState; } } } @@ -692,10 +676,7 @@ private void SignalComplete(bool canceled) lock (this) { // If someone is waiting then signal. - if (null != _workItemCompleted) - { - _workItemCompleted.Set(); - } + m_workItemCompleted?.Set(); } } @@ -725,10 +706,10 @@ private bool Cancel(bool abortExecution) //Debug.WriteLine("Work item already canceled"); if (abortExecution) { - Thread executionThread = Interlocked.CompareExchange(ref _executingThread, null, _executingThread); - if (null != executionThread) + Thread executionThread = Interlocked.CompareExchange(ref m_executingThread, null, m_executingThread); + if (executionThread is not null) { - executionThread.Abort(); // "Cancel" + //executionThread.Abort(); // "Cancel" // No need to signalComplete, because we already cancelled this work item // so it already signaled its completion. //signalComplete = true; @@ -742,10 +723,10 @@ private bool Cancel(bool abortExecution) case WorkItemState.InProgress: if (abortExecution) { - Thread executionThread = Interlocked.CompareExchange(ref _executingThread, null, _executingThread); - if (null != executionThread) + Thread executionThread = Interlocked.CompareExchange(ref m_executingThread, null, m_executingThread); + if (executionThread is not null) { - executionThread.Abort(); // "Cancel" + //executionThread.Abort(); // "Cancel" success = true; signalComplete = true; } @@ -790,14 +771,11 @@ private bool Cancel(bool abortExecution) /// In case of error the method throws and exception /// /// The result of the work item - private object GetResult( - int millisecondsTimeout, - bool exitContext, + private object GetResult(int millisecondsTimeout, bool exitContext, WaitHandle cancelWaitHandle) { - Exception e; - object result = GetResult(millisecondsTimeout, exitContext, cancelWaitHandle, out e); - if (null != e) + object result = GetResult(millisecondsTimeout, exitContext, cancelWaitHandle, out Exception e); + if (e is not null) { throw new WorkItemResultException("The work item caused an excpetion, see the inner exception for details", e); } @@ -810,11 +788,8 @@ private object GetResult( /// In case of error the e argument is filled with the exception /// /// The result of the work item - private object GetResult( - int millisecondsTimeout, - bool exitContext, - WaitHandle cancelWaitHandle, - out Exception e) + private object GetResult( int millisecondsTimeout, bool exitContext, + WaitHandle cancelWaitHandle, out Exception e) { e = null; @@ -827,12 +802,12 @@ private object GetResult( // Check for completion if (IsCompleted) { - e = _exception; - return _result; + e = m_exception; + return m_result; } // If no cancelWaitHandle is provided - if (null == cancelWaitHandle) + if (cancelWaitHandle is null) { WaitHandle wh = GetWaitHandle(); @@ -876,10 +851,10 @@ private object GetResult( Debug.Assert(IsCompleted); - e = _exception; + e = m_exception; // Return the result - return _result; + return m_result; } /// @@ -889,26 +864,26 @@ private WaitHandle GetWaitHandle() { lock (this) { - if (null == _workItemCompleted) + if (m_workItemCompleted is null) { - _workItemCompleted = new ManualResetEvent(IsCompleted); + m_workItemCompleted = new ManualResetEvent(IsCompleted); } - ++_workItemCompletedRefCount; + ++m_workItemCompletedRefCount; } - return _workItemCompleted; + return m_workItemCompleted; } private void ReleaseWaitHandle() { lock (this) { - if (null != _workItemCompleted) + if (m_workItemCompleted is not null) { - --_workItemCompletedRefCount; - if (0 == _workItemCompletedRefCount) + --m_workItemCompletedRefCount; + if (0 == m_workItemCompletedRefCount) { - _workItemCompleted.Close(); - _workItemCompleted = null; + m_workItemCompleted.Close(); + m_workItemCompleted = null; } } } @@ -950,11 +925,11 @@ internal event WorkItemStateCallback OnWorkItemStarted { add { - _workItemStartedEvent += value; + m_workItemStartedEvent += value; } remove { - _workItemStartedEvent -= value; + m_workItemStartedEvent -= value; } } @@ -962,39 +937,38 @@ internal event WorkItemStateCallback OnWorkItemCompleted { add { - _workItemCompletedEvent += value; + m_workItemCompletedEvent += value; } remove { - _workItemCompletedEvent -= value; + m_workItemCompletedEvent -= value; } } public void DisposeOfState() { - if(_callerContext != null) + if(m_callerContext is not null) { - _callerContext.Dispose(); - _callerContext = null; + m_callerContext.Dispose(); + m_callerContext = null; } - if(_workItemCompleted != null) + if(m_workItemCompleted is not null) { - _workItemCompleted.Dispose(); - _workItemCompleted = null; + m_workItemCompleted.Dispose(); + m_workItemCompleted = null; } - if (_workItemInfo.DisposeOfStateObjects) + if (m_workItemInfo.DisposeOfStateObjects) { - IDisposable disp = _state as IDisposable; - if (null != disp) + if (m_state is IDisposable disp) { disp.Dispose(); - _state = null; + m_state = null; } } - _callback = null; - _callbackNoResult = null; + m_callback = null; + m_callbackNoResult = null; } } } diff --git a/ThirdParty/SmartThreadPool/WorkItemFactory.cs b/ThirdParty/SmartThreadPool/WorkItemFactory.cs index 8f177064826..539ae58ec8b 100644 --- a/ThirdParty/SmartThreadPool/WorkItemFactory.cs +++ b/ThirdParty/SmartThreadPool/WorkItemFactory.cs @@ -1,5 +1,7 @@ using System; using System.Threading; +using System.Runtime.CompilerServices; + namespace Amib.Threading.Internal { @@ -13,14 +15,8 @@ public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartIn { ValidateCallback(callback); ValidateCallback(workItemInfo.PostExecuteWorkItemCallback); + return new WorkItem(workItemsGroup, new WorkItemInfo(workItemInfo), callback, state); - WorkItem workItem = new WorkItem( - workItemsGroup, - new WorkItemInfo(workItemInfo), - callback, - state); - - return workItem; } public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, @@ -28,7 +24,7 @@ public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartIn { ValidateCallback(callback); - WorkItemInfo workItemInfo = new WorkItemInfo() + WorkItemInfo workItemInfo = new() { UseCallerCallContext = wigStartInfo.UseCallerCallContext, PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback, @@ -36,12 +32,7 @@ public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartIn DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects, }; - WorkItem workItem = new WorkItem( - workItemsGroup, - workItemInfo, - callback, - state); - return workItem; + return new WorkItem(workItemsGroup, workItemInfo, callback, state); } /// @@ -51,6 +42,7 @@ public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartIn /// Work item group start information /// A callback to execute /// Returns a work item + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemCallback callback) { return CreateWorkItem(workItemsGroup, wigStartInfo, callback, null); @@ -64,15 +56,11 @@ public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartI /// Work item info /// A callback to execute /// Returns a work item + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemInfo workItemInfo, WorkItemCallback callback) { - return CreateWorkItem( - workItemsGroup, - wigStartInfo, - workItemInfo, - callback, - null); + return CreateWorkItem(workItemsGroup, wigStartInfo, workItemInfo, callback, null); } /// @@ -85,12 +73,13 @@ public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartI /// The context object of the work item. Used for passing arguments to the work item. /// /// Returns a work item + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemCallback callback, object state) { ValidateCallback(callback); - WorkItemInfo workItemInfo = new WorkItemInfo() + WorkItemInfo workItemInfo = new() { UseCallerCallContext = wigStartInfo.UseCallerCallContext, PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback, @@ -98,12 +87,7 @@ public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartI DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects, }; - WorkItem workItem = new WorkItem( - workItemsGroup, - workItemInfo, - callback, - state); - return workItem; + return new WorkItem( workItemsGroup, workItemInfo, callback, state); } /// @@ -117,13 +101,14 @@ public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartI /// The context object of the work item. Used for passing arguments to the work item. /// /// Returns a work item + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { ValidateCallback(callback); ValidateCallback(workItemInfo.PostExecuteWorkItemCallback); - WorkItem workItem = new WorkItem( + WorkItem workItem = new( workItemsGroup, new WorkItemInfo(workItemInfo), callback, @@ -145,29 +130,22 @@ public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartI /// A delegate to call after the callback completion /// /// Returns a work item - public static WorkItem CreateWorkItem( - IWorkItemsGroup workItemsGroup, - WIGStartInfo wigStartInfo, - WorkItemCallback callback, - object state, - PostExecuteWorkItemCallback postExecuteWorkItemCallback) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, + WorkItemCallback callback, object state,PostExecuteWorkItemCallback postExecuteWorkItemCallback) { ValidateCallback(callback); ValidateCallback(postExecuteWorkItemCallback); - WorkItemInfo workItemInfo = new WorkItemInfo(); - workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; - workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; - workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; - - WorkItem workItem = new WorkItem( - workItemsGroup, - workItemInfo, - callback, - state); + WorkItemInfo workItemInfo = new() + { + UseCallerCallContext = wigStartInfo.UseCallerCallContext, + PostExecuteWorkItemCallback = postExecuteWorkItemCallback, + CallToPostExecute = wigStartInfo.CallToPostExecute, + DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects + }; - return workItem; + return new WorkItem( workItemsGroup, workItemInfo, callback, state); } /// @@ -184,35 +162,29 @@ public static WorkItem CreateWorkItem( /// /// Indicates on which cases to call to the post execute callback /// Returns a work item - public static WorkItem CreateWorkItem( - IWorkItemsGroup workItemsGroup, - WIGStartInfo wigStartInfo, - WorkItemCallback callback, - object state, - PostExecuteWorkItemCallback postExecuteWorkItemCallback, - CallToPostExecute callToPostExecute) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup,WIGStartInfo wigStartInfo, + WorkItemCallback callback, object state, + PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute) { ValidateCallback(callback); ValidateCallback(postExecuteWorkItemCallback); - WorkItemInfo workItemInfo = new WorkItemInfo(); - workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; - workItemInfo.CallToPostExecute = callToPostExecute; - workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; - - WorkItem workItem = new WorkItem( - workItemsGroup, - workItemInfo, - callback, - state); + WorkItemInfo workItemInfo = new() + { + UseCallerCallContext = wigStartInfo.UseCallerCallContext, + PostExecuteWorkItemCallback = postExecuteWorkItemCallback, + CallToPostExecute = callToPostExecute, + DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects + }; - return workItem; + return new WorkItem(workItemsGroup, workItemInfo, callback, state); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void ValidateCallback(Delegate callback) { - if (callback != null && callback.GetInvocationList().Length > 1) + if (callback is not null && callback.GetInvocationList().Length > 1) { throw new NotSupportedException("SmartThreadPool doesn't support delegates chains"); } diff --git a/ThirdParty/SmartThreadPool/WorkItemsGroup.cs b/ThirdParty/SmartThreadPool/WorkItemsGroup.cs index 5321bb62a7b..e22756313e1 100644 --- a/ThirdParty/SmartThreadPool/WorkItemsGroup.cs +++ b/ThirdParty/SmartThreadPool/WorkItemsGroup.cs @@ -16,7 +16,7 @@ public class WorkItemsGroup : WorkItemsGroupBase { #region Private members - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// A reference to the SmartThreadPool instance that created this @@ -67,22 +67,19 @@ public class WorkItemsGroup : WorkItemsGroupBase /// /// Signaled when all of the WorkItemsGroup's work item completed. /// - private readonly ManualResetEvent _isIdleWaitHandle = new ManualResetEvent(true); + private readonly ManualResetEvent _isIdleWaitHandle = new(true); /// /// A common object for all the work items that this work items group /// generate so we can mark them to cancel in O(1) /// - private CanceledWorkItemsGroup _canceledWorkItemsGroup = new CanceledWorkItemsGroup(); + private CanceledWorkItemsGroup _canceledWorkItemsGroup = new(); #endregion #region Construction - public WorkItemsGroup( - SmartThreadPool stp, - int concurrency, - WIGStartInfo wigStartInfo) + public WorkItemsGroup(SmartThreadPool stp, int concurrency, WIGStartInfo wigStartInfo) { if (concurrency <= 0) { @@ -236,10 +233,8 @@ private object FireOnIdle(object state) [MethodImpl(MethodImplOptions.NoInlining)] private void FireOnIdleImpl(WorkItemsGroupIdleHandler onIdle) { - if(null == onIdle) - { + if(onIdle is null) return; - } Delegate[] delegates = onIdle.GetInvocationList(); foreach(WorkItemsGroupIdleHandler eh in delegates) @@ -298,7 +293,7 @@ private void EnqueueToSTPNextWorkItem(WorkItem workItem, bool decrementWorkItems } // If the work item is not null then enqueue it - if (null != workItem) + if (workItem is not null) { workItem.CanceledWorkItemsGroup = _canceledWorkItemsGroup; @@ -323,7 +318,7 @@ private void EnqueueToSTPNextWorkItem(WorkItem workItem, bool decrementWorkItems _stp.UnregisterWorkItemsGroup(this); IsIdle = true; _isIdleWaitHandle.Set(); - if (decrementWorkItemsInStpQueue && _onIdle != null && _onIdle.GetInvocationList().Length > 0) + if (decrementWorkItemsInStpQueue && _onIdle is not null && _onIdle.GetInvocationList().Length > 0) { _stp.QueueWorkItem(new WorkItemCallback(FireOnIdle)); } diff --git a/ThirdParty/SmartThreadPool/WorkItemsQueue.cs b/ThirdParty/SmartThreadPool/WorkItemsQueue.cs index f7a031ae3c1..38bed47d8a1 100644 --- a/ThirdParty/SmartThreadPool/WorkItemsQueue.cs +++ b/ThirdParty/SmartThreadPool/WorkItemsQueue.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading; +using System.Runtime.CompilerServices; namespace Amib.Threading.Internal { @@ -16,7 +17,7 @@ public class WorkItemsQueue : IDisposable /// /// Waiters queue (implemented as stack). /// - private readonly WaiterEntry _headWaiterEntry = new WaiterEntry(); + private readonly WaiterEntry _headWaiterEntry = new(); /// /// Waiters count @@ -26,7 +27,7 @@ public class WorkItemsQueue : IDisposable /// /// Work items queue /// - private readonly Queue _workItems = new Queue(); + private readonly Queue _workItems = new(); /// /// Indicate that work items are allowed to be queued @@ -79,7 +80,7 @@ public bool EnqueueWorkItem(WorkItem workItem) { // A work item cannot be null, since null is used in the // WaitForWorkItem() method to indicate timeout or cancel - if (workItem == null) + if (workItem is null) { throw new ArgumentNullException("workItem", "workItem cannot be null"); } @@ -112,7 +113,7 @@ public bool EnqueueWorkItem(WorkItem workItem) public void CloseThreadWaiter() { - if(_waiterEntry != null) + if(_waiterEntry is not null) { _waiterEntry.Close(); _waiterEntry = null; @@ -187,8 +188,7 @@ public WorkItem DequeueWorkItem( int millisecondsTimeout, WaitHandle cancelEvent // On success return the work item WorkItem workItem = waiterEntry.WorkItem; - if (workItem == null) - workItem = _workItems.Dequeue(); + workItem ??= _workItems.Dequeue(); return workItem; } @@ -262,7 +262,7 @@ public object[] GetStates() /// objects each thread has its own WaiterEntry object. private static WaiterEntry GetThreadWaiterEntry() { - if (_waiterEntry == null) + if (_waiterEntry is null) { _waiterEntry = new WaiterEntry(); } @@ -284,7 +284,7 @@ public void PushWaiter(WaiterEntry newWaiterEntry) RemoveWaiter(newWaiterEntry, false); // If the stack is empty then newWaiterEntry is the new head of the stack - if (null == _headWaiterEntry._nextWaiterEntry) + if (_headWaiterEntry._nextWaiterEntry is null) { _headWaiterEntry._nextWaiterEntry = newWaiterEntry; newWaiterEntry._prevWaiterEntry = _headWaiterEntry; @@ -325,7 +325,7 @@ private WaiterEntry PopWaiter() // Update the new stack head _headWaiterEntry._nextWaiterEntry = newHeadWaiterEntry; - if (newHeadWaiterEntry != null) + if (newHeadWaiterEntry is not null) { newHeadWaiterEntry._prevWaiterEntry = _headWaiterEntry; } @@ -357,7 +357,7 @@ private void RemoveWaiter(WaiterEntry waiterEntry, bool popDecrement) // If the waiter entry had a prev link then update it. // It also means that the waiter is already in the list and we // need to decrement the waiters count. - if (prevWaiterEntry != null) + if (prevWaiterEntry is not null) { prevWaiterEntry._nextWaiterEntry = nextWaiterEntry; popDecrement = true; @@ -366,7 +366,7 @@ private void RemoveWaiter(WaiterEntry waiterEntry, bool popDecrement) // If the waiter entry had a next link then update it. // It also means that the waiter is already in the list and we // need to decrement the waiters count. - if (nextWaiterEntry != null) + if (nextWaiterEntry is not null) { nextWaiterEntry._prevWaiterEntry = prevWaiterEntry; popDecrement = true; @@ -391,7 +391,7 @@ public sealed class WaiterEntry : IDisposable /// /// Event to signal the waiter that it got the work item. /// - private AutoResetEvent _waitHandle = new AutoResetEvent(false); + private AutoResetEvent _waitHandle = new(false); /// /// Flag to know if this waiter already quited from the queue @@ -450,15 +450,14 @@ public bool Signal(WorkItem workItem) { lock (this) { - if (!_isTimedout) - { - _workItem = workItem; - _isSignaled = true; - _waitHandle.Set(); - return true; - } + if (_isTimedout) + return false; + + _workItem = workItem; + _isSignaled = true; + _waitHandle.Set(); + return true; } - return false; } /// @@ -472,15 +471,14 @@ public bool Timeout() { // Time out can happen only if the waiter wasn't marked as // signaled - if (!_isSignaled) - { - // We don't remove the waiter from the queue, the DequeueWorkItem - // method skips _waiters that were timed out. - _isTimedout = true; - return true; - } + if (_isSignaled) + return false; + + // We don't remove the waiter from the queue, the DequeueWorkItem + // method skips _waiters that were timed out. + _isTimedout = true; + return true; } - return false; } /// @@ -500,7 +498,7 @@ public void Reset() public void Close() { _workItem = null; - if (null != _waitHandle) + if (_waitHandle is not null) { _waitHandle.Close(); _waitHandle = null; @@ -546,6 +544,7 @@ protected virtual void Dispose(bool disposing) } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidateNotDisposed() { if (_isDisposed) diff --git a/addon-modules/Gloebit/GloebitMoneyModule/Gloebit.csproj b/addon-modules/Gloebit/GloebitMoneyModule/Gloebit.csproj index 3f1b5c5c7a2..ec6eeabee51 100644 --- a/addon-modules/Gloebit/GloebitMoneyModule/Gloebit.csproj +++ b/addon-modules/Gloebit/GloebitMoneyModule/Gloebit.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 @@ -64,6 +64,7 @@ + \ No newline at end of file diff --git a/addon-modules/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData.csproj b/addon-modules/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData.csproj index 1cd26b1d009..8e43b852acc 100644 --- a/addon-modules/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData.csproj +++ b/addon-modules/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData/OpenSim.Data.MySQL.MoneyData.csproj @@ -1,7 +1,7 @@ Local - net48 + net8.0 OpenSim.Data.MySQL.MoneyData OpenSim OpenSim.Data.MySQL.MoneyData @@ -9,6 +9,7 @@ + diff --git a/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/NSLCertificateTools.cs b/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/NSLCertificateTools.cs index e2b59caa267..10807d5232e 100644 --- a/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/NSLCertificateTools.cs +++ b/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/NSLCertificateTools.cs @@ -3,20 +3,12 @@ * */ -#pragma warning disable S1128 // Unused "using" should be removed using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Xml; using System.Net; using System.Net.Security; -using System.Text; using System.Reflection; using System.Security.Cryptography.X509Certificates; using log4net; -#pragma warning restore S1128 // Unused "using" should be removed - namespace NSL.Certificate.Tools { @@ -237,33 +229,33 @@ public bool ValidateClientCertificate(object obj, X509Certificate certificate, X } - /// - /// class NSL Certificate Policy - /// - public class NSLCertificatePolicy : ICertificatePolicy - { - /// - /// Check Validation Result - /// - /// - /// - /// - /// - /// - public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) - { - if (certificateProblem == 0 || //normal - certificateProblem == -2146762487 || //Not trusted? - certificateProblem == -2146762495 || //Expired - certificateProblem == -2146762481) - { //Incorrect name? - return true; - } - else - { - return false; - } - } - } + // /// + // /// class NSL Certificate Policy + // /// + // public class NSLCertificatePolicy : ICertificatePolicy + // { + // /// + // /// Check Validation Result + // /// + // /// + // /// + // /// + // /// + // /// + // public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) + // { + // if (certificateProblem == 0 || //normal + // certificateProblem == -2146762487 || //Not trusted? + // certificateProblem == -2146762495 || //Expired + // certificateProblem == -2146762481) + // { //Incorrect name? + // return true; + // } + // else + // { + // return false; + // } + // } + // } } diff --git a/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency.csproj b/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency.csproj index 61dceb94165..c4b8df2547e 100644 --- a/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency.csproj +++ b/addon-modules/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency/OpenSim.Region.OptionalModules.Currency.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 OpenSim.Region.OptionalModules.Currency OpenSim DTL/NSL Group @@ -8,10 +8,11 @@ + - ..\..\..\bin\lib\NET\Mono.Security.dll + ..\..\..\bin\Mono.Security.dll False diff --git a/addon-modules/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer.csproj b/addon-modules/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer.csproj index 96394630860..3cf5d79d0f6 100644 --- a/addon-modules/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer.csproj +++ b/addon-modules/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer/OpenSim.Server.MoneyServer.csproj @@ -1,6 +1,6 @@ - net48 + net8.0 Exe OpenSim.Server.MoneyServer OpenSim @@ -54,5 +54,6 @@ + diff --git a/addon-modules/OpenSimMutelist/Modules/OpenSimMutelist.Modules.csproj b/addon-modules/OpenSimMutelist/Modules/OpenSimMutelist.Modules.csproj index 7db38a574d1..3abb3545065 100644 --- a/addon-modules/OpenSimMutelist/Modules/OpenSimMutelist.Modules.csproj +++ b/addon-modules/OpenSimMutelist/Modules/OpenSimMutelist.Modules.csproj @@ -1,12 +1,13 @@ - net48 + net8.0 OpenSimMuteList.Modules OpenSim + diff --git a/addon-modules/OpenSimSearch/Modules/OpenSimSearch.Modules.csproj b/addon-modules/OpenSimSearch/Modules/OpenSimSearch.Modules.csproj index da4f3ab3740..c3c97fbe689 100644 --- a/addon-modules/OpenSimSearch/Modules/OpenSimSearch.Modules.csproj +++ b/addon-modules/OpenSimSearch/Modules/OpenSimSearch.Modules.csproj @@ -1,13 +1,14 @@ - net48 - net48 + net8.0 + net8.0 OpenSimSearch.Modules OpenSim + diff --git a/bin/BouncyCastle.Cryptography.dll b/bin/BouncyCastle.Cryptography.dll new file mode 100644 index 00000000000..80581a40a9b Binary files /dev/null and b/bin/BouncyCastle.Cryptography.dll differ diff --git a/bin/CSJ2K.dll b/bin/CSJ2K.dll index 88347fc3aa8..3da9675dc1b 100755 Binary files a/bin/CSJ2K.dll and b/bin/CSJ2K.dll differ diff --git a/bin/Mono.Data.SqliteClient.dll.config b/bin/Mono.Data.SqliteClient.dll.config new file mode 100644 index 00000000000..7eb54480738 --- /dev/null +++ b/bin/Mono.Data.SqliteClient.dll.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bin/lib/NET/Mono.Security.dll b/bin/Mono.Security.dll similarity index 100% rename from bin/lib/NET/Mono.Security.dll rename to bin/Mono.Security.dll diff --git a/bin/Nini.dll b/bin/Nini.dll index 1d89f93fd8c..f36b8db756f 100755 Binary files a/bin/Nini.dll and b/bin/Nini.dll differ diff --git a/bin/OpenMetaverse.Rendering.Meshmerizer.dll b/bin/OpenMetaverse.Rendering.Meshmerizer.dll index 94e4c76544a..e691bac9106 100755 Binary files a/bin/OpenMetaverse.Rendering.Meshmerizer.dll and b/bin/OpenMetaverse.Rendering.Meshmerizer.dll differ diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index 68d4556339d..4577b0d8309 100755 Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll index 09639ade123..009e97c09d4 100755 Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ diff --git a/bin/OpenMetaverse.dll.config b/bin/OpenMetaverse.dll.config index a06109b49c4..9af7d502493 100644 --- a/bin/OpenMetaverse.dll.config +++ b/bin/OpenMetaverse.dll.config @@ -1,10 +1,8 @@ - - - - - - - - + + + + + + diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll index c4e6955fca7..93c91e35990 100755 Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ diff --git a/bin/OpenSim.Region.PhysicsModule.BulletS.dll.config b/bin/OpenSim.Region.PhysicsModule.BulletS.dll.config index 605ad6563fd..20914e54260 100755 --- a/bin/OpenSim.Region.PhysicsModule.BulletS.dll.config +++ b/bin/OpenSim.Region.PhysicsModule.BulletS.dll.config @@ -1,9 +1,6 @@ - - - - - - - + + + + diff --git a/bin/OpenSim.Region.PhysicsModule.Ode.dll.config b/bin/OpenSim.Region.PhysicsModule.Ode.dll.config deleted file mode 100644 index d71fd7dc6e8..00000000000 --- a/bin/OpenSim.Region.PhysicsModule.Ode.dll.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/bin/OpenSim.Region.PhysicsModule.ubOde.dll.config b/bin/OpenSim.Region.PhysicsModule.ubOde.dll.config index d71fd7dc6e8..029ff0633f0 100644 --- a/bin/OpenSim.Region.PhysicsModule.ubOde.dll.config +++ b/bin/OpenSim.Region.PhysicsModule.ubOde.dll.config @@ -1,5 +1,6 @@ + - - + + diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index e2114ca3ae7..b5e8afe43b6 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -108,7 +108,6 @@ ;; However, this will only log crashes within OpenSimulator that cause the ;; entire program to exit ;; It will not log crashes caused by virtual machine failures, which - ;; includes mono and ODE failures. ;; You will need to capture these native stack traces by recording the ;; session log itself. ; save_crashes = false @@ -242,10 +241,6 @@ ;; Select a mesher here. ;; - ;; Meshmerizer properly handles complex prims by using triangle meshes. - ;; Note that only the ODE physics engine currently deals with meshed - ;; prims in a satisfactory way. - ;# {meshing} {} {Select mesher} {Meshmerizer ZeroMesher} Meshmerizer ;; ZeroMesher is faster but leaves the physics engine to model the mesh ;; using the basic shapes that it supports. @@ -264,14 +259,13 @@ ;; It continues to provide a workable physics implementation. It does not currently support varregions. ;; basicphysics effectively does not model physics at all, making all objects phantom. ;; Default is BulletSim - ; physics = OpenDynamicsEngine ; physics = BulletSim ; physics = basicphysics ; physics = POS ;; alternative OpenDynamicsEngine engine. ubODEMeshmerizer meshing above MUST be selected also ; physics = ubODE - ; ubODE and OpenDynamicsEngine does allocate a lot of memory on stack. On linux you may need to increase its limit + ; ubODE does allocate a lot of memory on stack. On linux you may need to increase its limit ; script opensim-ode-sh starts opensim setting that limit. You may need to increase it even more on large regions ; edit the line ulimit -s 262144, and change this last value @@ -647,6 +641,8 @@ ;# {ExternalHostNameForLSL} {} {Hostname to use for HTTP-IN URLs. This should be reachable from the internet.} {} ;; Hostname to use in llRequestURL/llRequestSecureURL ;; if not defined - llRequestURL/llRequestSecureURL are disabled + ;; this should be reachable from internet and point this machine + ;; for standalones it can be ExternalHostNameForLSL = ${Const|BaseHostname} ;# {shard} {} {Name to use for X-Secondlife-Shard header? (press enter if unsure)} {} OpenSim @@ -801,14 +797,6 @@ AvatarToAvatarCollisionsByDefault = true -[ODEPhysicsSettings] - ;# {mesh_sculpted_prim} {[Startup]physics:OpenDynamicsEngine} {Mesh sculpties so they collide as they look?} {true false} true - ;; Do we want to mesh sculpted prim to collide like they look? - ;; If you are seeing sculpt texture decode problems - ;; (messages such as "Decoded image with unhandled number of components: 0 shortly followed by a physcs exception") - ;; then you might want to try setting this to false. - ; mesh_sculpted_prim = true - [RemoteAdmin] ;; This is the remote admin module, which uses XMLRPC requests to ;; manage regions from a web interface. diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index c03850a6548..7e2fdc80aa3 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -269,16 +269,15 @@ ; Select a mesher here. ; - ; Meshmerizer properly handles complex prims by using triangle meshes. - ; Note that only the ODE physics engine currently deals with meshed prims in a satisfactory way ; ; ZeroMesher is faster but leaves the physics engine to model the mesh using the basic shapes that it supports ; Usually this is only a box ; select ubODEMeshmerizer with and only with ubOde physics engine ; meshing = ubODEMeshmerizer - meshing = Meshmerizer ;meshing = ZeroMesher + ;; select ubODEMeshmerizer only with ubOde physics engine + ; meshing = ubODEMeshmerizer ; Path to decoded sculpty maps ; Defaults to "j2kDecodeCache @@ -299,10 +298,8 @@ ;; Default is BulletSim physics = BulletSim ;physics = modified_BulletX - ;physics = OpenDynamicsEngine ;physics = basicphysics ;physics = POS - ; alternative OpenDynamicsEngine engine. ubODEMeshmerizer meshing above MUST be selected also ; physics = ubODE ; ## @@ -1036,20 +1033,12 @@ ; more steps may increase CPU load. No real gain in changing world_solver_iterations = 10 - ;Spaces level settings. Affects memory consumption vs Collider CPU time for avatar and physical prim - ; defines spaces partition cells min and max sizes == 2^value - world_hashspace_level_low = -5 - world_hashSpace_level_high = 12 - - meters_in_small_space = 29.9 ; ## ; ## Contact properties. (the stuff that happens when things come in contact with each other) ; ## - ; surface layer around geometries other geometries can sink into before generating a contact - world_contact_surface_layer = 0.001 ; Filtering collisions helps keep things stable physics wise, but sometimes ; it can be overzealous. If you notice bouncing, chances are it's that. @@ -1073,27 +1062,6 @@ objectcontact_friction = 250.0 objectcontact_bounce = 0.2 - ; ## - ; ## Avatar Control - ; ## - - ; PID Controller Settings. These affect the math that causes the avatar to reach the - ; desired velocity - ; See http://en.wikipedia.org/wiki/PID_controller - - av_pid_derivative = 2200.0 - av_pid_proportional = 900.0 - - ;girth of the avatar. Adds radius to the height also - av_capsule_radius = 0.37 - - ; Max force permissible to use to keep the avatar standing up straight - av_capsule_standup_tensor = 550000 - - ; specifies if the capsule should be tilted (=true; old compatibility mode) - ; or straight up-and-down (=false; better and more consistent physics behavior) - av_capsule_tilted = false - ; used to calculate mass of avatar. ; float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); ; av_density * AVvolume; @@ -1111,18 +1079,6 @@ ; speed of movement with Always Run on av_movement_divisor_run = 0.8 - ; When the avatar flies, it will be moved up by this amount off the ground (in meters) - minimum_ground_flight_offset = 3.0 - - ; Plant avatar. This reduces the effect of physical contacts with the avatar. - ; If you have a group of unruly and rude visitors that bump each other, turn this on to make that less attractive. - ; The avatar still allows a small movement based on the PID settings above. Stronger PID settings AND this active - ; will lock the avatar in place - av_planted = false - - ; No Avatar Avatar Collissions. This causes avatar to be able to walk through each other as if they're ghosts but still interact with the environment - av_av_collisions_off = false - ; ## ; ## Object options ; ## @@ -1133,16 +1089,6 @@ ; amount of ODE steps where object is non moving for ODE to automatically put it to sleep body_frames_auto_disable = 20 - ; used to control llMove2Target - body_pid_derivative = 35 - body_pid_gain = 25 - - ; maximum number of contact points to generate per collision - contacts_per_collision = 80 - - ; start throttling the object updates if object comes in contact with 3 or more other objects - geom_contactpoints_start_throttling = 3 - ; send 1 update for every x updates below when throttled geom_updates_before_throttled_update = 15 @@ -2234,7 +2180,7 @@ [ServerReleaseNotes] ;; Comment or set to "" to disable - ServerReleaseNotesURL = "http://opensimulator.org/wiki/0.9.2.2_Release" + ServerReleaseNotesURL = "http://opensimulator.org/wiki/0.9.3.0_Release" [Modules] Include-modules = "addon-modules/*/config/*.ini" diff --git a/bin/Prebuild.exe b/bin/Prebuild.exe deleted file mode 100755 index 3a050f088a5..00000000000 Binary files a/bin/Prebuild.exe and /dev/null differ diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index f15b8fc13ee..d3bc92fca74 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -656,6 +656,10 @@ ; a RSS page for grid status ;GridStatusRSS = ${Const|BaseURL}:${Const|PublicPort}/GridStatusRSS + ; optional web page for profiles + ;[AGENT_NAME] will be converted to Firstname.LastName by viewers + ; web_profile_url = http://webprofilesurl:ItsPort?name=[AGENT_NAME] + [GatekeeperService] LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService" ;; for the service @@ -817,6 +821,8 @@ [Messaging] ; OfflineIM OfflineIMService = "OpenSim.Addons.OfflineIM.dll:OfflineIMService" + ; maximum number of offline ims per user, default 25 + ;MaxOfflineIMs = 25; [Groups] diff --git a/bin/Robust.Tests.dll.config b/bin/Robust.Tests.dll.config deleted file mode 100644 index a4c43e75d04..00000000000 --- a/bin/Robust.Tests.dll.config +++ /dev/null @@ -1,43 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bin/Robust.Tests.ini b/bin/Robust.Tests.ini deleted file mode 100644 index bf7263304d2..00000000000 --- a/bin/Robust.Tests.ini +++ /dev/null @@ -1,468 +0,0 @@ -; * FOR TESTS ONLY -- DO NOT USE THIS FILE -[Const] - - ; The URL of the Robust server - BaseURL = "http://127.0.0.1" - - ; The public port of the Robust server - PublicPort = "8888" - - ; The private port of the Robust server, same for testing - PrivatePort = "8888" - - -; * The startup section lists all the connectors to start up in this server -; * instance. This may be only one, or it may be the entire server suite. -; * Multiple connectors should be separated by commas. -; * -; * These are the IN connectors the server uses, the in connectors -; * read this config file and load the needed service and database connectors -; * -; * The full syntax of a connector string is: -; * [[@]/][:] -; * -[Startup] - ; Place to create a PID file - ; If no path if specified then a PID file is not created. - ; PIDFile = "/tmp/Robust.exe.pid" - - ; Plugin Registry Location - ; Set path to directory for plugin registry. Information - ; about the registered repositories and installed plugins - ; will be stored here - ; The Robust.exe process must have R/W access to the location - RegistryLocation = "." - - ; Modular configurations - ; Set path to directory for modular ini files... - ; The Robust.exe process must have R/W access to the location - ConfigDirectory = "." - - console = "rest" - - ; Console commands can be saved to a file, so the command history persists after a restart. (default is true) - ConsoleHistoryFileEnabled = false - - ; The history file can be just a filename (relative to OpenSim's bin/ directory - ; or it can be a full path to somewhere else. (default is OpenSimConsoleHistory.txt in bin/) - ConsoleHistoryFile = "RobustConsoleHistory.txt" - - ; How many lines of command history should we keep? (default is 100) - ConsoleHistoryFileLines = 100 - -[ServiceList] - GridServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:GridServiceConnector" - PresenceServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:PresenceServiceConnector" - InstantMessageServerConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:InstantMessageServerConnector" - UserAccountServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:UserAccountServiceConnector" - InventoryInConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:XInventoryInConnector" - - ;; Uncomment as more tests are added - ;AssetServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:AssetServiceConnector" - ;GridInfoServerInConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:GridInfoServerInConnector" - ;AuthenticationServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector" - ;OpenIdServerConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:OpenIdServerConnector" - ;AvatarServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:AvatarServiceConnector" - ;LLLoginServiceInConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector" - ;GridUserServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:GridUserServiceConnector" - ;FriendsServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:FriendsServiceConnector" - ;MapAddServiceConnector = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:MapAddServiceConnector" - ;MapGetServiceConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:MapGetServiceConnector" - ;OfflineIMServiceConnector = "${Const|PrivatePort}/OpenSim.Addons.OfflineIM.dll:OfflineIMServiceRobustConnector" - ;GroupsServiceConnector = "${Const|PrivatePort}/OpenSim.Addons.Groups.dll:GroupsServiceRobustConnector" - ;BakedTextureService = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:XBakesConnector" - ;UserProfilesServiceConnector = "${Const|PublicPort}/OpenSim.Server.Handlers.dll:UserProfilesConnector" - ;EstateDataService = "${Const|PrivatePort}/OpenSim.Server.Handlers.dll:EstateDataRobustConnector" - -; * This is common for all services, it's the network setup for the entire -; * server instance, if none is specified above -; * -[Network] - port = ${Const|PrivatePort} - - ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. - ;; Use this if your central services in port ${Const|PrivatePort} need to be accessible on the Internet - ;; but you want to protect them from unauthorized access. - ; AuthType = "BasicHttpAuthentication" - ; HttpAuthUsername = "some_username" - ; HttpAuthPassword = "some_password" - ;; - ;; AuthType above can be overriden in any of the service sections below by - ; AuthType = "None" - ;; This is useful in cases where you want to protect most of the services, - ;; but unprotect individual services. Username and Password can also be - ;; overriden if you want to use different credentials for the different services. - - ;; By default, scripts are not allowed to call private services via llHttpRequest() - ;; Such calls are detected by the X-SecondLife-Shared HTTP header - ;; If you allow such calls you must be sure that they are restricted to very trusted scripters - ;; (remember scripts can also be in visiting avatar attachments). - ;; This can be overriden in individual private service sections if necessary - AllowllHTTPRequestIn = false - - ; * The following are for the remote console - ; * They have no effect for the local or basic console types - ; * Leave commented to diable logins to the console - ;ConsoleUser = Test - ;ConsolePass = secret - ;ConsolePort = 0 - - -[DatabaseService] - ; PGSQL - ; Uncomment these lines if you want to use PGSQL storage - ; Change the connection string to your db details - ;StorageProvider = "OpenSim.Data.PGSQL.dll" - ;ConnectionString = "Server=localhost;Database=opensim;User Id=opensim; password=***;" - - ; Null - ; Uncomment these lines if you want to use MySQL storage - ; Change the connection string to your db details - StorageProvider = "OpenSim.Data.Null.dll" - ConnectionString = "" - - -; * As an example, the below configuration precisely mimicks the legacy -; * asset server. It is read by the asset IN connector (defined above) -; * and it then loads the OUT connector (a local database module). That, -; * in turn, reads the asset loader and database connection information -; * -[AssetService] - LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" - DefaultAssetLoader = "" - - ; Allow maptile assets to remotely deleted by remote calls to the asset service. - ; There is no harm in having this as false - it just means that historical maptile assets are not deleted. - ; This only applies to maptiles served via the version 1 viewer mechanisms - ; Default is false - AllowRemoteDelete = false - - ; Allow all assets to be remotely deleted. - ; Only set this to true if you are operating a grid where you control all calls to the asset service - ; (where a necessary condition is that you control all simulators) and you need this for admin purposes. - ; If set to true, AllowRemoteDelete = true is required as well. - ; Default is false. - AllowRemoteDeleteAllTypes = false - - -; * This configuration loads the inventory server modules. It duplicates -; * the function of the legacy inventory server -; * -[InventoryService] - LocalServiceModule = "OpenSim.Services.InventoryService.dll:XInventoryService" - - StorageProvider = "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin" - ConnectionString = "" - - ; Will calls to purge folders (empty trash) and immediately delete/update items or folders (not move to trash first) succeed? - ; If this is set to false then some other arrangement must be made to perform these operations if necessary. - AllowDelete = true - - -; * This is the new style grid service. -; * "Realm" is the table that is used for user lookup. -; * It defaults to "regions", which uses the legacy tables -; * -[GridService] - LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - ; Realm = "regions" - ; AllowDuplicateNames = "True" - - ;; Next, we can specify properties of regions, including default and fallback regions - ;; The syntax is: Region_ = "" - ;; or: Region_ = "" - ;; where can be DefaultRegion, DefaultHGRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut, Reservation, NoMove, Authenticate - ;; - ;; DefaultRegion If a local login cannot be placed in the required region (e.g. home region does not exist, avatar is not allowed entry, etc.) - ;; then this region becomes the destination. Only the first online default region will be used. If no DefaultHGRegion - ;; is specified then this will also be used as the region for hypergrid connections that require it (commonly because they have not specified - ;; an explicit region. - ;; - ;; DefaultHGRegion If an avatar connecting via the hypergrid does not specify a region, then they are placed here. Only the first online - ;; region will be used. - ;; - ;; FallbackRegion If the DefaultRegion is not available for a local login, then any FallbackRegions are tried instead. These are tried in the - ;; order specified. This only applies to local logins at this time, not Hypergrid connections. - ;; - ;; NoDirectLogin A hypergrid user cannot directly connect to this region. This does not apply to local logins. - ;; - ;; Persistent When the simulator is shutdown, the region is signalled as offline but left registered on the grid. - ;; - ;; Example specification: - ; Region_Welcome_Area = "DefaultRegion, FallbackRegion" - ; (replace spaces with underscore) - - ;; Allow supporting viewers to export content - ;; Set to false to prevent export - ExportSupported = true - - - - -; * This is the new style authentication service. Currently, only MySQL -; * is implemented. -; * -[AuthenticationService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - - ;; Allow the service to process HTTP getauthinfo calls. - ;; Default is false. - ; AllowGetAuthInfo = false - - ;; Allow the service to process HTTP setauthinfo calls. - ;; Default is false. - ; AllowSetAuthInfo = false - - ;; Allow the service to process HTTP setpassword calls. - ;; Default is false. - ; AllowSetPassword = false - - -; * This is the new style authentication service. Currently, only MySQL -; * is implemented. "Realm" is the table that is used for user lookup. -; * It defaults to "useraccounts", which uses the new style. -; * Realm = "users" will use the legacy tables as an authentication source -; * -[UserAccountService] - StorageProvider = "OpenSim.Data.Null.dll" - ConnectionString = "" - - ; for the server connector - LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" - ; Realm = "useraccounts" - - ; These are for creating new accounts by the service - ;AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" - GridService = "OpenSim.Services.GridService.dll:GridService" - InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" - ;AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" - ;GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" - - ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 - ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. - ;; Default is false - CreateDefaultAvatarEntries = true - - ;; Allow the service to process HTTP createuser calls. - ;; Default is false. - AllowCreateUser = true - - ;; Allow the service to process HTTP setaccount calls. - ;; Default is false. - AllowSetAccount = true - - -[GridUserService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.UserAccountService.dll:GridUserService" - - -[PresenceService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" - ; Set this to true to allow the use of advanced web services and multiple - ; bots using one account - AllowDuplicatePresences = false; - - -[AvatarService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" - - -[FriendsService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.FriendsService.dll:FriendsService" - -[EstateService] - LocalServiceModule = "OpenSim.Services.EstateService.dll:EstateDataService" - -[LibraryService] - LibraryName = "OpenSim Library" - DefaultLibrary = "./inventory/Libraries.xml" - - -[LoginService] - ; for the server connector - LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" - ; for the service - UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" - GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" - AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" - AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" - GridService = "OpenSim.Services.GridService.dll:GridService" - SimulationService ="OpenSim.Services.Connectors.dll:SimulationServiceConnector" - LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService" - FriendsService = "OpenSim.Services.FriendsService.dll:FriendsService" - - ; The minimum user level required for a user to be able to login. 0 by default - ; If you disable a particular user's account then you can set their login level below this number. - ; You can also change this level from the console though these changes will not be persisted. - ; MinLoginLevel = 0 - - ; Ask co-operative viewers to use a different currency name - ;Currency = "" - - ;; Set minimum fee to publish classified - ; ClassifiedFee = 0 - - WelcomeMessage = "Welcome, Avatar!" - AllowRemoteSetLoginLevel = "false" - - ; For V2 map - MapTileURL = "${Const|BaseURL}:${Const|PublicPort}/"; - - ; Url to search service - ; SearchURL = "${Const|BaseURL}:${Const|PublicPort}/"; - - ; For V3 destination guide - ; DestinationGuide = "${Const|BaseURL}/guide" - - ; For V3 avatar picker (( work in progress )) - ; AvatarPicker = "${Const|BaseURL}/avatars" - - ; If you run this login server behind a proxy, set this to true - ; HasProxy = false - - ;; Regular expressions for controlling which client versions are accepted/denied. - ;; An empty string means nothing is checked. - ;; - ;; Example 1: allow only these 3 types of clients (any version of them) - ;; AllowedClients = "Imprudence|Hippo|Second Life" - ;; - ;; Example 2: allow all clients except these - ;; DeniedClients = "Twisted|Crawler|Cryolife|FuckLife|StreetLife|GreenLife|AntiLife|KORE-Phaze|Synlyfe|Purple Second Life|SecondLi |Emerald" - ;; - ;; Note that these are regular expressions, so every character counts. - ;; Also note that this is very weak security and should not be trusted as a reliable means - ;; for keeping bad clients out; modified clients can fake their identifiers. - ;; - ;; - ;AllowedClients = "" - ;DeniedClients = "" - - ;# {DSTZone} {} {Override Daylight Saving Time rules} {* none local} "America/Los_Angeles;Pacific Standard Time" - ;; Viewers do not listen to timezone sent by the server. They use Pacific Standard Time instead, - ;; but rely on the server to calculate Daylight Saving Time. Sending another DST than US Pacific - ;; would result in time inconsistencies between grids (during summer and around DST transition period) - ;; default let OpenSim calculate US Pacific DST - ;; "none" disable DST (equivallent to "local" with system set to GMT) - ;; "local" force legacy behaviour (using local system time to calculate DST) - ; DSTZone = "America/Los_Angeles;Pacific Standard Time" - - ;# {DSTZone} {} {Override Daylight Saving Time rules} {* none local} "America/Los_Angeles;Pacific Standard Time" - ;; Viewers do not receive timezone information from the server - almost all (?) default to Pacific Standard Time - ;; However, they do rely on the server to tell them whether it's Daylight Saving Time or not. - ;; Hence, calculating DST based on a different timezone can result in a misleading viewer display and inconsistencies between grids. - ;; By default, this setting uses various timezone names to calculate DST with regards to the viewer's standard PST. - ;; Options are - ;; "none" no DST - ;; "local" use the server's only timezone to calculate DST. This is previous OpenSimulator behaviour. - ;; "America/Los_Angeles;Pacific Standard Time" use these timezone names to look up Daylight savings. - ;; 'America/Los_Angeles' is used on Linux/Mac systems whilst 'Pacific Standard Time' is used on Windows - DSTZone = "America/Los_Angeles;Pacific Standard Time" - - ;Basic Login Service Dos Protection Tweaks - ;; - ;; Some Grids/Users use a transparent proxy that makes use of the X-Forwarded-For HTTP Header, If you do, set this to true - ;; If you set this to true and you don't have a transparent proxy, it may allow attackers to put random things in the X-Forwarded-For header to - ;; get around this basic DOS protection. - ;DOSAllowXForwardedForHeader = false - ;; - ;; The protector adds up requests during this rolling period of time, default 10 seconds - ;DOSRequestTimeFrameMS = 10000 - ;; - ;; The amount of requests in the above timeframe from the same endpoint that triggers protection - ;DOSMaxRequestsInTimeFrame = 5 - ;; - ;; The amount of time that a specific endpoint is blocked. Default 2 minutes. - ;DOSForgiveClientAfterMS = 120000 - ;; - ;; To turn off basic dos protection, set the DOSMaxRequestsInTimeFrame to 0. - - -[MapImageService] - LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService" - - ; Set this if you want to change the default - ; TilesStoragePath = "maptiles" - ; - ; If for some reason you have the AddMapTile service outside the firewall (e.g. ${Const|PublicPort}), - ; you may want to set this. Otherwise, don't set it, because it's already protected. - ; GridService = "OpenSim.Services.GridService.dll:GridService" - ; - ; Additionally, if you run this server behind a proxy, set this to true - ; HasProxy = false - - -[Messaging] - ; OfflineIM - OfflineIMService = "" - - -[GridInfoService] - ; These settings are used to return information on a get_grid_info call. - ; Client launcher scripts and third-party clients make use of this to - ; autoconfigure the client and to provide a nice user experience. If you - ; want to facilitate that, you should configure the settings here according - ; to your grid or standalone setup. - ; - ; See http://opensimulator.org/wiki/GridInfo - - ; login uri: for grid this is the login server URI - login = ${Const|BaseURL}:${Const|PublicPort}/ - - ; long grid name: the long name of your grid - gridname = "the lost continent of hippo" - - ; short grid name: the short name of your grid - gridnick = "hippogrid" - - ; login page: optional: if it exists it will be used to tell the client to use - ; this as splash page - ;welcome = ${Const|BaseURL}/welcome - - ; helper uri: optional: if it exists if will be used to tell the client to use - ; this for all economy related things - ;economy = ${Const|BaseURL}:${Const|PublicPort}/ - - ; web page of grid: optional: page providing further information about your grid - ;about = ${Const|BaseURL}/about/ - - ; account creation: optional: page providing further information about obtaining - ; a user account on your grid - ;register = ${Const|BaseURL}/register - - ; help: optional: page providing further assistance for users of your grid - ;help = ${Const|BaseURL}/help - - ; password help: optional: page providing password assistance for users of your grid - ;password = ${Const|BaseURL}/password - - -[UserProfilesService] - LocalServiceModule = "OpenSim.Services.UserProfilesService.dll:UserProfilesService" - Enabled = false - ;; Configure this for separate profiles database - ;; ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=*****;Old Guids=true;" - ;; Realm = UserProfiles - UserAccountService = OpenSim.Services.UserAccountService.dll:UserAccountService - AuthenticationServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - - -[BakedTextureService] - LocalServiceModule = "OpenSim.Server.Handlers.dll:XBakes" - ;; This directory must be writable by the user ROBUST runs as. It will be created automatically. - BaseDirectory = "./bakes" - -[HGInstantMessageService] - LocalServiceModule = "OpenSim.Services.HypergridService.dll:HGInstantMessageService" - GridService = "OpenSim.Services.GridService.dll:GridService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" - UserAgentService = "" - ; This should always be true in the Robust config - InGatekeeper = True diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index a33d4583222..bb8df149a88 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -572,9 +572,15 @@ ; a RSS page for grid status ;GridStatusRSS = ${Const|BaseURL}:${Const|PublicPort}/GridStatusRSS + ; optional web page for profiles + ;[AGENT_NAME] will be converted to Firstname.LastName by viewers + ; web_profile_url = http://webprofilesurl:ItsPort?name=[AGENT_NAME] + [Messaging] ; OfflineIM OfflineIMService = "OpenSim.Addons.OfflineIM.dll:OfflineIMService" + ; maximum number of offline ims per user, default 25 + ;MaxOfflineIMs = 25; [Groups] diff --git a/bin/ScriptSyntax.xml b/bin/ScriptSyntax.xml index 249495ab2fe..bcc1fd2d455 100644 --- a/bin/ScriptSyntax.xml +++ b/bin/ScriptSyntax.xml @@ -1,4 +1,4 @@ -f0eb469c-b2f3-4d64-802a-1ac709cb91e6 +9a2d5a5e-484a-40b0-82bc-092443b08ff7 llsd-lsl-syntax-version2 controls @@ -199,6 +199,15 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 tooltipTriggered when object receives a link message via llMessageLinked function call + linkset_data + arguments + actiontypeinteger + nametypestring + valuetypestring + IDtypekey + + tooltipTriggered when the linksetdata store is modified + listen arguments Channeltypeinteger @@ -828,6 +837,10 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value2 + CLICK_ACTION_DISABLED + typeinteger + value8 + CLICK_ACTION_NONE typeinteger value0 @@ -1292,6 +1305,46 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value-4 + LINKSETDATA_DELETE + typeinteger + value2 + + LINKSETDATA_EMEMORY + typeinteger + value1 + + LINKSETDATA_ENOKEY + typeinteger + value2 + + LINKSETDATA_EPROTECTED + typeinteger + value3 + + LINKSETDATA_MULTIDELETE + typeinteger + value3 + + LINKSETDATA_NOTFOUND + typeinteger + value4 + + LINKSETDATA_NOUPDATE + typeinteger + value5 + + LINKSETDATA_OK + typeinteger + value0 + + LINKSETDATA_RESET + typeinteger + value0 + + LINKSETDATA_UPDATE + typeinteger + value1 + LIST_STAT_GEOMETRIC_MEAN typeinteger value9 @@ -1842,6 +1895,18 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value64 + PARCEL_DETAILS_FLAGS + typeinteger + value12 + + PARCEL_DETAILS_GEOMETRICCENTER + typeinteger + value66 + + PARCEL_DETAILS_GETCLAIMDATE + typeinteger + value65 + PARCEL_DETAILS_GROUP typeinteger value3 @@ -1854,6 +1919,14 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value5 + PARCEL_DETAILS_LANDING_LOOKAT + typeinteger + value10 + + PARCEL_DETAILS_LANDING_POINT + typeinteger + value9 + PARCEL_DETAILS_NAME typeinteger value0 @@ -1862,10 +1935,26 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value2 + PARCEL_DETAILS_PRIM_CAPACITY + typeinteger + value7 + + PARCEL_DETAILS_PRIM_USED + typeinteger + value8 + + PARCEL_DETAILS_SCRIPT_DANGER + typeinteger + value13 + PARCEL_DETAILS_SEE_AVATARS typeinteger value6 + PARCEL_DETAILS_TP_ROUTING + typeinteger + value11 + PARCEL_FLAG_ALLOW_ALL_OBJECT_ENTRY typeinteger value0x8000000 @@ -2212,6 +2301,22 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value25 + PRIM_GLTF_BASE_COLOR + typeinteger + value48 + + PRIM_GLTF_EMISSIVE + typeinteger + value46 + + PRIM_GLTF_METALLIC_ROUGHNESS + typeinteger + value47 + + PRIM_GLTF_NORMAL + typeinteger + value45 + PRIM_HOLE_CIRCLE typeinteger value16 @@ -2408,6 +2513,22 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value42 + PRIM_REFLECTION_PROBE + typeinteger + value44 + + PRIM_REFLECTION_PROBE_BOX + typeinteger + value1 + + PRIM_REFLECTION_PROBE_DYNAMIC + typeinteger + value2 + + PRIM_RENDER_MATERIAL + typeinteger + value49 + PRIM_ROT_LOCAL typeinteger value29 @@ -2421,6 +2542,10 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 value40 tooltipnot supported + PRIM_SCULPT_FLAG_ANIMESH + typeinteger + value0x20 + PRIM_SCULPT_FLAG_INVERT typeinteger value0x40 @@ -2438,6 +2563,10 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 value0x07 tooltipAuxiliar to clear flags keeping scultp type + PRIM_SCULPT_TYPE_MESH + typeinteger + value5 + PRIM_SCULPT_TYPE_PLANE typeinteger value3 @@ -2894,6 +3023,22 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 typeinteger value16 + SOUND_LOOP + typeinteger + value1 + + SOUND_PLAY + typeinteger + value0 + + SOUND_SYNC + typeinteger + value4 + + SOUND_TRIGGER + typeinteger + value2 + SQRT2 typefloat value1.414213538 @@ -4886,6 +5031,13 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 numbertypeinteger + llIsFriend + + returninteger + arguments + agent_idtypekey + + llJson2List returnlist @@ -4925,6 +5077,13 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 idtypekey + llLinear2sRGB + + returnvector + arguments + srctypevector + + llLinkAdjustSoundVolume arguments @@ -4945,6 +5104,108 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 linknumbertypeinteger soundtypestring volumetypefloat + flagstypeinteger + + + llLinkPlaySound + + arguments + linknumbertypeinteger + soundtypestring + volumetypefloat + + + llLinksetDataAvailable + + returninteger + arguments + + llLinksetDataCountFound + + returninteger + arguments + patterntypestring + + + llLinksetDataCountKeys + + returninteger + arguments + + llLinksetDataDelete + + returninteger + arguments + nametypestring + + + llLinksetDataDeleteFound + + returnlist + arguments + patterntypestring + passtypestring + + + llLinksetDataDeleteProtected + + returninteger + arguments + nametypestring + passtypestring + + + llLinksetDataFindKeys + + returnlist + arguments + patterntypestring + starttypeinteger + counttypeinteger + + + llLinksetDataListKeys + + returnlist + arguments + starttypeinteger + counttypeinteger + + + llLinksetDataRead + + returnstring + arguments + nametypestring + + + llLinksetDataReadProtected + + returnstring + arguments + nametypestring + passtypestring + + + llLinksetDataReset + + arguments + + llLinksetDataWrite + + returninteger + arguments + nametypestring + valuetypestring + + + llLinksetDataWriteProtected + + returninteger + arguments + nametypestring + valuetypestring + passtypestring llLinksetDataWrite @@ -5248,6 +5509,17 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 endtypeinteger + llList2ListSlice + + returnlist + arguments + srctypelist + starttypeinteger + endtypeinteger + stridetypeinteger + stride_indextypeinteger + + llList2ListStrided returnlist @@ -5313,6 +5585,17 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 testtypelist + llListFindStrided + + returninteger + arguments + srctypelist + testtypelist + lstarttypeinteger + lendtypeinteger + lstridetypeinteger + + llListInsertList returnlist @@ -5349,6 +5632,16 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 ascendingtypeinteger + llListSortStrided + + returnlist + arguments + srctypelist + stridetypeinteger + stride_indextypeinteger + ascendingtypeinteger + + llListStatistics returnfloat @@ -6489,6 +6782,13 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 ftypefloat + llsRGB2Linear + + returnvector + arguments + srctypevector + + llStartAnimation arguments @@ -6832,8 +7132,8 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returninteger arguments - vatypevector - vbtypevector + ratyperotation + rbtyperotation margintypefloat @@ -6841,17 +7141,17 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returninteger arguments - vatypevector - vbtypevector + atypefloat + btypefloat + margintypefloat osApproxEquals returninteger arguments - atypefloat - btypefloat - margintypefloat + vatypevector + vbtypevector osApproxEquals @@ -6866,8 +7166,8 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returninteger arguments - ratyperotation - rbtyperotation + vatypevector + vbtypevector margintypefloat @@ -7022,8 +7322,6 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returnstring arguments drawListtypestring - startXtypeinteger - startYtypeinteger endXtypeinteger endYtypeinteger @@ -7033,6 +7331,8 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returnstring arguments drawListtypestring + startXtypeinteger + startYtypeinteger endXtypeinteger endYtypeinteger @@ -7171,13 +7471,13 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments avatartypestring + targettypestring osForceOtherSit arguments avatartypestring - targettypestring osFormatString @@ -7323,6 +7623,14 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 itemNameOrIdtypestring + osGetLinkInventoryDesc + + returnstring + arguments + linkNumbertypeinteger + itemNameOrIdtypestring + + osGetInventoryItemKey returnkey @@ -7330,6 +7638,30 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 nametypestring +osGetLinkInventoryAssetKey + + returnkey + arguments + linkNumbertypeinteger + nametypestring + typetypeinteger + + +osGetLinkInventoryItemKey + + returnkey + arguments + linkNumbertypeinteger + nametypestring + + + osGetInventoryItemKeys + + returnlist + arguments + typetypeinteger + + osGetInventoryLastOwner returnkey @@ -7344,6 +7676,61 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 itemIdtypekey + osGetInventoryNames + + returnlist + arguments + typetypeinteger + + + osGetLinkInventoryName + + returnstring + arguments + linkNumbertypeinteger + itemIdtypekey + + + osGetLinkInventoryNames + + returnlist + arguments + linkNumbertypeinteger + typetypeinteger + + + osGetLinkInventoryItemKeys + + returnlist + arguments + linkNumbertypeinteger + typetypeinteger + + + osRemoveLinkInventory + + arguments + linkNumbertypeinteger + nametypeinteger + + + osGiveLinkInventory + + arguments + linkNumbertypeinteger + destinationtypekey + inventorytypestring + + + osGiveLinkInventoryList + + arguments + linkNumbertypeinteger + destinationtypekey + categorytypestring + inventorytypestring + + osGetLastChangedEventKey returnkey @@ -7418,6 +7805,14 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 nametypestring + osGetParcelDetails + + returnlist + arguments + idtypekey + paramtypelist + + osGetParcelDwell returninteger @@ -7425,6 +7820,16 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 postypevector + osGetParcelID + + returnkey + arguments + + osGetParcelIDs + + returnlist + arguments + osGetPhysicsEngineName returnstring @@ -7435,6 +7840,18 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returnstring arguments + osGetPrimCount + + returninteger + arguments + + osGetPrimCount + + returninteger + arguments + object_idtypekey + + osGetPrimitiveParams returnlist @@ -7495,6 +7912,28 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returnfloat arguments + osGetSitTargetPos + + returnvector + arguments + + osGetSitTargetRot + + returnrotation + arguments + + osGetSittingAvatarsCount + + returninteger + arguments + object_idtypekey + + + osGetSittingAvatarsCount + + returninteger + arguments + osGetStandTarget returnvector @@ -7561,15 +8000,15 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osKickAvatar arguments - FirstNametypestring - SurNametypestring + agentIdtypekey alerttypestring osKickAvatar arguments - agentIdtypekey + FirstNametypestring + SurNametypestring alerttypestring @@ -7588,6 +8027,15 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 ascendingtypeinteger + osListSortInPlaceStrided + + arguments + srctypelist + stridetypeinteger + stride_indextypeinteger + ascendingtypeinteger + + osLoadedCreationDate returnstring @@ -7641,14 +8089,14 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments notecardNametypestring - contentstypestring + contentstypelist osMakeNotecard arguments notecardNametypestring - contentstypelist + contentstypestring osMatchString @@ -7809,6 +8257,7 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments npctypekey + channeltypeinteger messagetypestring @@ -7816,7 +8265,6 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments npctypekey - channeltypeinteger messagetypestring @@ -7901,6 +8349,16 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 messagetypestring + osOldList2ListStrided + + returnlist + arguments + srctypelist + starttypeinteger + endtypeinteger + stridetypeinteger + + osOwnerSaveAppearance returnkey @@ -7977,13 +8435,13 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osRegionNotice arguments - agentIDtypekey msgtypestring osRegionNotice arguments + agentIDtypekey msgtypestring @@ -8235,6 +8693,14 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osSetPenColor + + returnstring + arguments + drawListtypestring + colortypevector + + + osSetPenColor returnstring arguments @@ -8242,6 +8708,15 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 colortypestring + osSetPenColor + + returnstring + arguments + drawListtypestring + colortypevector + alphatypefloat + + osSetPenColour returnstring @@ -8274,6 +8749,7 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osSetProjectionParams arguments + linknumbertypeinteger projectiontypeinteger texturetypekey fovtypefloat @@ -8284,7 +8760,6 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osSetProjectionParams arguments - primtypekey projectiontypeinteger texturetypekey fovtypefloat @@ -8295,7 +8770,7 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osSetProjectionParams arguments - linknumbertypeinteger + primtypekey projectiontypeinteger texturetypekey fovtypefloat @@ -8391,19 +8866,19 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osSlerp - returnvector + returnrotation arguments - atypevector - btypevector + atyperotation + btyperotation amounttypefloat osSlerp - returnrotation + returnvector arguments - atyperotation - btyperotation + atypevector + btypevector amounttypefloat @@ -8495,7 +8970,6 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments srctypestring starttypeinteger - lengthtypeinteger osStringSubString @@ -8504,6 +8978,7 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 arguments srctypestring starttypeinteger + lengthtypeinteger osSunGetParam @@ -8560,7 +9035,6 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osTeleportOwner arguments - regionNametypestring positiontypevector lookattypevector @@ -8577,6 +9051,7 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 osTeleportOwner arguments + regionNametypestring positiontypevector lookattypevector @@ -8644,5 +9119,39 @@ f0eb469c-b2f3-4d64-802a-1ac709cb91e6 returnstring arguments + osAESEncrypt + + returnstring + arguments + secrettypestring + plainTexttypestring + + + osAESEncryptTo + + returnstring + arguments + secrettypestring + plainTexttypestring + ivStringtypestring + + + osAESDecrypt + + returnstring + arguments + secrettypestring + encryptedTexttypestring + + + osAESDecryptFrom + + returnstring + arguments + secrettypestring + encryptedTexttypestring + ivStringtypestring + + \ No newline at end of file diff --git a/bin/System.Configuration.ConfigurationManager.dll b/bin/System.Configuration.ConfigurationManager.dll new file mode 100644 index 00000000000..c13d66bd951 Binary files /dev/null and b/bin/System.Configuration.ConfigurationManager.dll differ diff --git a/bin/System.Drawing.Common.dll.linux b/bin/System.Drawing.Common.dll.linux new file mode 100644 index 00000000000..9e26473d197 Binary files /dev/null and b/bin/System.Drawing.Common.dll.linux differ diff --git a/bin/System.Drawing.Common.dll.win b/bin/System.Drawing.Common.dll.win new file mode 100644 index 00000000000..7c9e87b4e18 Binary files /dev/null and b/bin/System.Drawing.Common.dll.win differ diff --git a/bin/System.Runtime.Caching.dll b/bin/System.Runtime.Caching.dll new file mode 100644 index 00000000000..14826eb8967 Binary files /dev/null and b/bin/System.Runtime.Caching.dll differ diff --git a/bin/System.Security.Permissions.dll b/bin/System.Security.Permissions.dll new file mode 100644 index 00000000000..76faf41ec1f Binary files /dev/null and b/bin/System.Security.Permissions.dll differ diff --git a/bin/Warp3D.dll b/bin/Warp3D.dll index a2491c33792..4a025ecc8bb 100755 Binary files a/bin/Warp3D.dll and b/bin/Warp3D.dll differ diff --git a/bin/XMLRPC.dll b/bin/XMLRPC.dll index e6fe0eb3a6f..3655956c31e 100755 Binary files a/bin/XMLRPC.dll and b/bin/XMLRPC.dll differ diff --git a/bin/ZstdNet.dll b/bin/ZstdNet.dll new file mode 100644 index 00000000000..6f68449873c Binary files /dev/null and b/bin/ZstdNet.dll differ diff --git a/bin/assets/AssetSets.xml b/bin/assets/AssetSets.xml index 2fbf660560b..839e709cafd 100644 --- a/bin/assets/AssetSets.xml +++ b/bin/assets/AssetSets.xml @@ -27,6 +27,10 @@
+
+ +
+
diff --git a/bin/assets/MaterialsAssetSet/968cbad0-4dad-d64e-71b5-72bf13ad051a.dat b/bin/assets/MaterialsAssetSet/968cbad0-4dad-d64e-71b5-72bf13ad051a.dat new file mode 100644 index 00000000000..b8ec2b0a452 Binary files /dev/null and b/bin/assets/MaterialsAssetSet/968cbad0-4dad-d64e-71b5-72bf13ad051a.dat differ diff --git a/bin/assets/MaterialsAssetSet/MaterialsAssetSet.xml b/bin/assets/MaterialsAssetSet/MaterialsAssetSet.xml new file mode 100644 index 00000000000..47ae0f1f312 --- /dev/null +++ b/bin/assets/MaterialsAssetSet/MaterialsAssetSet.xml @@ -0,0 +1,10 @@ + +
+ + + + +
+ +
+ diff --git a/bin/assets/SettingsAssetSet/Midday.dat b/bin/assets/SettingsAssetSet/Midday.dat index 300673bbc37..e937376de98 100644 --- a/bin/assets/SettingsAssetSet/Midday.dat +++ b/bin/assets/SettingsAssetSet/Midday.dat @@ -1,2 +1,2 @@ - + {'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.41,r0.41,r0.41],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r1],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.2,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5,r0.001,r-0.48],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r1.05,r1.05,r1.05],'blue_density':[r0.244758,r0.448723,r0.76],'blue_horizon':[r0.495484,r0.495484,r0.64],'density_multiplier':r0.00018,'distance_multiplier':r0.8,'haze_density':r0.7,'haze_horizon':r0.19},'max_y':r1605,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r-0.707107,r0,r-0.707107],'moon_scale':r1,'name':'Midday','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r0,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.707107,r0,r0.707107],'sun_scale':r1,'sunlight_color':[r0.734211,r0.781579,r0.9,r0.3],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/SettingsAssetSet/MiddayNRP.dat b/bin/assets/SettingsAssetSet/MiddayNRP.dat new file mode 100644 index 00000000000..2c6811e4e7c --- /dev/null +++ b/bin/assets/SettingsAssetSet/MiddayNRP.dat @@ -0,0 +1,2 @@ + +{'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.41,r0.41,r0.41],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r1],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.2,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5,r0.001,r-0.48],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r1.05,r1.05,r1.05],'blue_density':[r0.244758,r0.448723,r0.76],'blue_horizon':[r0.495484,r0.495484,r0.64],'density_multiplier':r0.00018,'distance_multiplier':r0.8,'haze_density':r0.7,'haze_horizon':r0.19},'max_y':r1605,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r-0.707107,r0,r-0.707107],'moon_scale':r1,'name':'MiddayNRP','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'reflection_probe_ambiance':r0,'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r0,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.707107,r0,r0.707107],'sun_scale':r1,'sunlight_color':[r0.734211,r0.781579,r0.9,r0.3],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/SettingsAssetSet/MiddayRP.dat b/bin/assets/SettingsAssetSet/MiddayRP.dat new file mode 100644 index 00000000000..5f881609f38 --- /dev/null +++ b/bin/assets/SettingsAssetSet/MiddayRP.dat @@ -0,0 +1,2 @@ + +{'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.41,r0.41,r0.41],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r1],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.2,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5,r0.001,r-0.48],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r1.05,r1.05,r1.05],'blue_density':[r0.244758,r0.448723,r0.76],'blue_horizon':[r0.495484,r0.495484,r0.64],'density_multiplier':r0.00018,'distance_multiplier':r0.8,'haze_density':r0.7,'haze_horizon':r0.19},'max_y':r1605,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r-0.707107,r0,r-0.707107],'moon_scale':r1,'name':'MiddayRP','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'reflection_probe_ambiance':r1,'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r0,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.707107,r0,r0.707107],'sun_scale':r1,'sunlight_color':[r0.734211,r0.781579,r0.9,r0.3],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/SettingsAssetSet/Midnight.dat b/bin/assets/SettingsAssetSet/Midnight.dat index 5e72733b1c4..3e2859762f0 100644 --- a/bin/assets/SettingsAssetSet/Midnight.dat +++ b/bin/assets/SettingsAssetSet/Midnight.dat @@ -1,2 +1,2 @@ - + {'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.226154,r0.226154,r0.226154],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r0.88],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.4994,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5,r0.001,r-0.48],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r0.20405,r0.242467,r0.33],'blue_density':[r0.45,r0.45,r0.45],'blue_horizon':[r0.24,r0.24,r0.24],'density_multiplier':r0.0003,'distance_multiplier':r0.0001,'haze_density':r4,'haze_horizon':r0},'max_y':r906.2,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r-0.707107,r0,r0.707107],'moon_scale':r1,'name':'Midnight','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r500,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.707107,r0,r-0.707107],'sun_scale':r1,'sunlight_color':[r0.348767,r0.355742,r0.66,r0.22],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/SettingsAssetSet/SettingsAssetSet.xml b/bin/assets/SettingsAssetSet/SettingsAssetSet.xml index 3f8ddef2ff5..526dc661853 100644 --- a/bin/assets/SettingsAssetSet/SettingsAssetSet.xml +++ b/bin/assets/SettingsAssetSet/SettingsAssetSet.xml @@ -30,6 +30,18 @@ +
+ + + + +
+
+ + + + +
diff --git a/bin/assets/SettingsAssetSet/Sunrise.dat b/bin/assets/SettingsAssetSet/Sunrise.dat index dbf9d66c7d8..2370a3b8933 100644 --- a/bin/assets/SettingsAssetSet/Sunrise.dat +++ b/bin/assets/SettingsAssetSet/Sunrise.dat @@ -1,2 +1,2 @@ - + {'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.226166,r0.226166,r0.226166],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r0.88],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.4994,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5.001,r0.001,r-0.480001],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r0.81,r0.462898,r0.63],'blue_density':[r0.157932,r0.434996,r0.87],'blue_horizon':[r0.206732,r0.409883,r0.48],'density_multiplier':r0.00062,'distance_multiplier':r2.69993,'haze_density':r0.54,'haze_horizon':r0.16},'max_y':r563,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r0.99889,r-9.23811e-007,r0.0471065],'moon_scale':r1,'name':'Sunrise','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r0,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.0471064,r0,r0.99889],'sun_scale':r1,'sunlight_color':[r2.37,r2.37,r2.37,r0.79],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/SettingsAssetSet/Sunset.dat b/bin/assets/SettingsAssetSet/Sunset.dat index 381c71e3ea3..cf3d6073830 100644 --- a/bin/assets/SettingsAssetSet/Sunset.dat +++ b/bin/assets/SettingsAssetSet/Sunset.dat @@ -1,2 +1,2 @@ - + {'absorption_config':[{'constant_term':r0,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r25000},{'constant_term':r1,'exp_scale':r0,'exp_term':r0,'linear_term':r0,'width':r0}],'bloom_id':u3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef,'cloud_color':[r0.226154,r0.226154,r0.226154],'cloud_id':u1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b,'cloud_pos_density1':[r1,r0.526097,r0.88],'cloud_pos_density2':[r1,r0.526097,r0.125],'cloud_scale':r0.42,'cloud_scroll_rate':[r0.4994,r0.0109997],'cloud_shadow':r0.27,'cloud_variance':r0,'dome_offset':r0.96,'dome_radius':r15000,'droplet_radius':r800,'gamma':r1,'glow':[r5,r0.001,r-0.48],'halo_id':u12149143-f599-91a7-77ac-b52a3c0f59cd,'ice_level':r0,'legacy_haze':{'ambient':[r1.02,r0.81,r0.81],'blue_density':[r0.145225,r0.399997,r0.800002],'blue_horizon':[r0.107676,r0.213487,r0.25],'density_multiplier':r0.00046,'distance_multiplier':r1,'haze_density':r0.7,'haze_horizon':r0.16},'max_y':r562.5,'mie_config':[{'anisotropy':r0.8,'constant_term':r0,'exp_scale':r-0.000833333,'exp_term':r1,'linear_term':r0,'width':r0}],'moisture_level':r0,'moon_brightness':r0.5,'moon_id':uec4b9f0b-d008-45c6-96a4-01dd947ac621,'moon_rotation':[r0,r0.0376899,r4.36181e-008,r0.99929],'moon_scale':r1,'name':'Sunset','planet_radius':r6360,'rainbow_id':u11b4c57c-56b3-04ed-1f82-2004363882e4,'rayleigh_config':[{'constant_term':r0,'exp_scale':r-0.000125,'exp_term':r1,'linear_term':r0,'width':r0}],'sky_bottom_radius':r6360,'sky_top_radius':r6420,'star_brightness':r0,'sun_arc_radians':r0.00045,'sun_id':u00000000-0000-0000-0000-000000000000,'sun_rotation':[r0,r-0.99929,r0,r0.03769],'sun_scale':r1,'sunlight_color':[r2.83857,r2.83857,r2.83857,r1],'type':'sky'} \ No newline at end of file diff --git a/bin/assets/TexturesAssetSet/5b53359e-59dd-d8a2-04c3-9e65134da47a.jp2 b/bin/assets/TexturesAssetSet/5b53359e-59dd-d8a2-04c3-9e65134da47a.jp2 new file mode 100644 index 00000000000..25ad750fa85 Binary files /dev/null and b/bin/assets/TexturesAssetSet/5b53359e-59dd-d8a2-04c3-9e65134da47a.jp2 differ diff --git a/bin/assets/TexturesAssetSet/85f28839-7a1c-b4e3-d71d-967792970a7b.jp2 b/bin/assets/TexturesAssetSet/85f28839-7a1c-b4e3-d71d-967792970a7b.jp2 new file mode 100644 index 00000000000..f6d617dc510 Binary files /dev/null and b/bin/assets/TexturesAssetSet/85f28839-7a1c-b4e3-d71d-967792970a7b.jp2 differ diff --git a/bin/assets/TexturesAssetSet/87e0e8f7-8729-1ea8-cfc9-8915773009db.jp2 b/bin/assets/TexturesAssetSet/87e0e8f7-8729-1ea8-cfc9-8915773009db.jp2 new file mode 100644 index 00000000000..f2647236b79 Binary files /dev/null and b/bin/assets/TexturesAssetSet/87e0e8f7-8729-1ea8-cfc9-8915773009db.jp2 differ diff --git a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml index dfd3c411316..9b115e607ca 100644 --- a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml +++ b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml @@ -610,13 +610,6 @@
-
- - - - -
-
@@ -906,4 +899,28 @@
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ diff --git a/bin/config-include/osslDefaultEnable.ini b/bin/config-include/osslDefaultEnable.ini index 3ecf3c5e528..bac98335d32 100644 --- a/bin/config-include/osslDefaultEnable.ini +++ b/bin/config-include/osslDefaultEnable.ini @@ -110,7 +110,6 @@ Allow_osSetPrimFloatOnWater = true Allow_osSetWindParam = ${OSSL|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER Allow_osTerrainFlush = ESTATE_MANAGER,ESTATE_OWNER - Allow_osUnixTimeToTimestamp = true ; ThreatLevel Low Allow_osAvatarName2Key = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll deleted file mode 100755 index c7138a44726..00000000000 Binary files a/bin/lib32/BulletSim.dll and /dev/null differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so deleted file mode 100755 index 4fb7e3eb118..00000000000 Binary files a/bin/lib32/libBulletSim.so and /dev/null differ diff --git a/bin/lib32/libopenjpeg-dotnet.so b/bin/lib32/libopenjpeg-dotnet.so deleted file mode 100755 index 193eca4b34e..00000000000 Binary files a/bin/lib32/libopenjpeg-dotnet.so and /dev/null differ diff --git a/bin/lib32/libubode.so b/bin/lib32/libubode.so deleted file mode 100755 index 7e5eabf560b..00000000000 Binary files a/bin/lib32/libubode.so and /dev/null differ diff --git a/bin/lib32/ubode.dll b/bin/lib32/ubode.dll deleted file mode 100755 index dc4f9f877d3..00000000000 Binary files a/bin/lib32/ubode.dll and /dev/null differ diff --git a/bin/lib64/BulletSim-2.86-20170903-x86_64.dll b/bin/lib64/BulletSim-2.86-20170903-x86_64.dll new file mode 100755 index 00000000000..58fe6b62a1d Binary files /dev/null and b/bin/lib64/BulletSim-2.86-20170903-x86_64.dll differ diff --git a/bin/lib64/BulletSim-3.26-20231207-x86_64.dll b/bin/lib64/BulletSim-3.26-20231207-x86_64.dll new file mode 100755 index 00000000000..e5817705645 Binary files /dev/null and b/bin/lib64/BulletSim-3.26-20231207-x86_64.dll differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index 58fe6b62a1d..e5817705645 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/BulletSimVersionInfo b/bin/lib64/BulletSimVersionInfo new file mode 100755 index 00000000000..2159be253e0 --- /dev/null +++ b/bin/lib64/BulletSimVersionInfo @@ -0,0 +1,7 @@ +BuildDate=20231207 +BulletSimVersion=1.3 +BulletSimGitVersion=c6dd28b934f844cc5cc5012ad302ad742e6c3785 +BulletSimGitVersionShort=c6dd28b +BulletVersion=3.26 +BulletGitVersion=6bb8d1123d8a55d407b19fd3357c724d0f5c9d3c +BulletGitVersionShort=6bb8d11 diff --git a/bin/lib64/libBulletSim-2.86-20170903-x86_64.so b/bin/lib64/libBulletSim-2.86-20170903-x86_64.so new file mode 100755 index 00000000000..2bf11596fe1 Binary files /dev/null and b/bin/lib64/libBulletSim-2.86-20170903-x86_64.so differ diff --git a/bin/lib64/libBulletSim-3.26-20231207-x86_64.so b/bin/lib64/libBulletSim-3.26-20231207-x86_64.so new file mode 100755 index 00000000000..5633315daae Binary files /dev/null and b/bin/lib64/libBulletSim-3.26-20231207-x86_64.so differ diff --git a/bin/lib64/libBulletSim-aarch64.so b/bin/lib64/libBulletSim-arm64.so old mode 100755 new mode 100644 similarity index 100% rename from bin/lib64/libBulletSim-aarch64.so rename to bin/lib64/libBulletSim-arm64.so diff --git a/bin/lib64/libBulletSim.dylib b/bin/lib64/libBulletSim.dylib old mode 100755 new mode 100644 index ff44a4594a2..dfed9e6a1d9 Binary files a/bin/lib64/libBulletSim.dylib and b/bin/lib64/libBulletSim.dylib differ diff --git a/bin/lib64/libopenjpeg-dotnet-aarch64.so b/bin/lib64/libopenjpeg-dotnet-arm64.so old mode 100755 new mode 100644 similarity index 100% rename from bin/lib64/libopenjpeg-dotnet-aarch64.so rename to bin/lib64/libopenjpeg-dotnet-arm64.so diff --git a/bin/lib64/libopenjpeg-dotnet-x86_64.so b/bin/lib64/libopenjpeg-dotnet-x86_64.so old mode 100755 new mode 100644 diff --git a/bin/lib64/libopenjpeg-dotnet.dylib b/bin/lib64/libopenjpeg-dotnet.dylib index 91f7264fdba..963a5cc6a58 100755 Binary files a/bin/lib64/libopenjpeg-dotnet.dylib and b/bin/lib64/libopenjpeg-dotnet.dylib differ diff --git a/bin/lib64/libubode-arm64.so b/bin/lib64/libubode-arm64.so new file mode 100644 index 00000000000..1365ad42ea1 Binary files /dev/null and b/bin/lib64/libubode-arm64.so differ diff --git a/bin/lib64/libubode.dylib b/bin/lib64/libubode.dylib index a5f528f4220..adc8fc25d09 100755 Binary files a/bin/lib64/libubode.dylib and b/bin/lib64/libubode.dylib differ diff --git a/bin/openjpeg-dotnet-x86_64.dll b/bin/lib64/openjpeg-dotnet-x86_64.dll old mode 100755 new mode 100644 similarity index 100% rename from bin/openjpeg-dotnet-x86_64.dll rename to bin/lib64/openjpeg-dotnet-x86_64.dll diff --git a/bin/lib64/ubode.dll b/bin/lib64/ubode.dll index 13ebcf918c3..5ce2cfeb47b 100755 Binary files a/bin/lib64/ubode.dll and b/bin/lib64/ubode.dll differ diff --git a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-aarch64.so b/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-aarch64.so deleted file mode 100755 index 344febea832..00000000000 Binary files a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-aarch64.so and /dev/null differ diff --git a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so b/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so deleted file mode 100644 index 193eca4b34e..00000000000 Binary files a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-i686.so and /dev/null differ diff --git a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so b/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so deleted file mode 100644 index 7a9bdfcd1dc..00000000000 Binary files a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1-x86_64.so and /dev/null differ diff --git a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib b/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib deleted file mode 100644 index cf095bd1390..00000000000 Binary files a/bin/libopenjpeg-dotnet-2-1.5.0-dotnet-1.dylib and /dev/null differ diff --git a/bin/libzstd.dll b/bin/libzstd.dll new file mode 100644 index 00000000000..cafab633ae5 Binary files /dev/null and b/bin/libzstd.dll differ diff --git a/bin/openjpeg-dotnet.dll b/bin/openjpeg-dotnet.dll deleted file mode 100755 index 6377b8d9702..00000000000 Binary files a/bin/openjpeg-dotnet.dll and /dev/null differ diff --git a/bin/opensim.sh b/bin/opensim.sh index aaa9649b652..e81355d076b 100755 --- a/bin/opensim.sh +++ b/bin/opensim.sh @@ -1,5 +1,3 @@ #!/bin/sh ulimit -s 1048576 -# next option may improve SGen gc (for opensim only) you may also need to increase nursery size on large regions -#export MONO_GC_PARAMS="minor=split,promotion-age=14" -mono --desktop -O=all OpenSim.exe +dotnet OpenSim.dll diff --git a/bin/prebuild.runtimeconfig.json b/bin/prebuild.runtimeconfig.json new file mode 100644 index 00000000000..b0a83d62c1f --- /dev/null +++ b/bin/prebuild.runtimeconfig.json @@ -0,0 +1,14 @@ +{ + "runtimeOptions": { + "tfm": "net8.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "8.0.0" + }, + "configProperties": { + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false, + "System.Runtime.TieredCompilation": false + } + } +} \ No newline at end of file diff --git a/nant-color b/nant-color deleted file mode 100755 index b36898681b1..00000000000 --- a/nant-color +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env ruby - -def main - IO.popen("nant #{ARGV.join(' ')}") { |pipe| - pipe.sync = true - while str = pipe.gets - str.sub!(/\n+/, '') - puts colorize(str) - end - } -end - -def clear - return "\e[0m" -end - -def red(str) - return "\e[31m" + str + clear -end - -def green(str) - return "\e[32m" + str + clear -end - -def yellow(str) - return "\e[33m" + str + clear -end - -def black - return "\e[30m" -end - -def hide - return "\e[8m" -end - -def bright - return "\e[1m" -end - -def colorize(str) - str.sub!(/(error \w+:.*)/, red('\1')) - str.sub!(/(warning \w+:.*)/, yellow('\1')) - - str.sub!(/(Build Succeeded)/i, green('\1')) - str.sub!(/(Compilation succeeded)/, green('\1')) - str.sub!(/(\d+ warning\(s\))/, yellow('\1')) - str.sub!(/(Build Failed)/i, red('\1')) - - str.sub!(/(Tests run: \d+, Failures: 0, Not run: 0,.*)/, green('\1')) - str.sub!(/(Tests run: \d+, Failures: 0, Not run: [1-9].*)/, yellow('\1')) - str.sub!(/(Tests run: \d+, Failures: [1-9].*)/, red('\1')) - str.sub!(/(Test Case Failures:)/, red('\1')) - return str -end - -main()