aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/Application.cs121
-rw-r--r--OpenSim/Region/Application/OpenSim.csproj181
-rw-r--r--OpenSim/Region/Application/OpenSim.csproj.user13
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs476
4 files changed, 791 insertions, 0 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
new file mode 100644
index 0000000..40701b0
--- /dev/null
+++ b/OpenSim/Region/Application/Application.cs
@@ -0,0 +1,121 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Framework.Console;
32
33namespace OpenSim
34{
35 public class Application
36 {
37 //could move our main function into OpenSimMain and kill this class
38 [STAThread]
39 public static void Main(string[] args)
40 {
41 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
42 Console.WriteLine("Starting...\n");
43
44 bool sandBoxMode = false;
45 bool startLoginServer = false;
46 string physicsEngine = "basicphysics";
47 bool allowFlying = false;
48 bool userAccounts = false;
49 bool gridLocalAsset = false;
50 bool useConfigFile = false;
51 bool silent = false;
52 string configFile = "simconfig.xml";
53
54 for (int i = 0; i < args.Length; i++)
55 {
56 if (args[i] == "-sandbox")
57 {
58 sandBoxMode = true;
59 startLoginServer = true;
60 }
61 /*
62 if (args[i] == "-loginserver")
63 {
64 startLoginServer = true;
65 }*/
66 if (args[i] == "-accounts")
67 {
68 userAccounts = true;
69 }
70 if (args[i] == "-realphysx")
71 {
72 physicsEngine = "RealPhysX";
73 allowFlying = true;
74 }
75 if (args[i] == "-ode")
76 {
77 physicsEngine = "OpenDynamicsEngine";
78 allowFlying = true;
79 }
80 if (args[i] == "-localasset")
81 {
82 gridLocalAsset = true;
83 }
84 if (args[i] == "-configfile")
85 {
86 useConfigFile = true;
87 }
88 if (args[i] == "-noverbose")
89 {
90 silent = true;
91 }
92 if (args[i] == "-config")
93 {
94 try
95 {
96 i++;
97 configFile = args[i];
98 }
99 catch (Exception e)
100 {
101 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
102 }
103 }
104 }
105
106 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
107 // OpenSimRoot.Instance.Application = sim;
108 sim.m_sandbox = sandBoxMode;
109 sim.user_accounts = userAccounts;
110 sim.gridLocalAsset = gridLocalAsset;
111 OpenSim.Region.Scenes.ScenePresence.PhysicsEngineFlying = allowFlying;
112
113 sim.StartUp();
114
115 while (true)
116 {
117 OpenSim.Framework.Console.MainLog.Instance.MainLogPrompt();
118 }
119 }
120 }
121}
diff --git a/OpenSim/Region/Application/OpenSim.csproj b/OpenSim/Region/Application/OpenSim.csproj
new file mode 100644
index 0000000..214f2cf
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSim.csproj
@@ -0,0 +1,181 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{438A9556-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Axiom.MathLib.dll" >
62 <HintPath>..\..\..\bin\Axiom.MathLib.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="Db4objects.Db4o.dll" >
66 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="System" >
74 <HintPath>System.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="System.Xml" >
78 <HintPath>System.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="XMLRPC.dll" >
82 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 </ItemGroup>
86 <ItemGroup>
87 <ProjectReference Include="..\..\Framework\General\OpenSim.Framework.csproj">
88 <Name>OpenSim.Framework</Name>
89 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 <ProjectReference Include="..\..\Framework\Communications\OpenSim.Framework.Communications.csproj">
94 <Name>OpenSim.Framework.Communications</Name>
95 <Project>{CB52B7E7-0000-0000-0000-000000000000}</Project>
96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
97 <Private>False</Private>
98 </ProjectReference>
99 <ProjectReference Include="..\..\Framework\Communications.OGS1\OpenSim.Framework.Communications.OGS1.csproj">
100 <Name>OpenSim.Framework.Communications.OGS1</Name>
101 <Project>{6109024D-0000-0000-0000-000000000000}</Project>
102 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
103 <Private>False</Private>
104 </ProjectReference>
105 <ProjectReference Include="..\..\Framework\Console\OpenSim.Framework.Console.csproj">
106 <Name>OpenSim.Framework.Console</Name>
107 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
108 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
109 <Private>False</Private>
110 </ProjectReference>
111 <ProjectReference Include="..\..\Framework\GenericConfig\Xml\OpenSim.Framework.GenericConfig.Xml.csproj">
112 <Name>OpenSim.Framework.GenericConfig.Xml</Name>
113 <Project>{C74E4A30-0000-0000-0000-000000000000}</Project>
114 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
115 <Private>False</Private>
116 </ProjectReference>
117 <ProjectReference Include="..\..\Framework\Servers\OpenSim.Framework.Servers.csproj">
118 <Name>OpenSim.Framework.Servers</Name>
119 <Project>{2CC71860-0000-0000-0000-000000000000}</Project>
120 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
121 <Private>False</Private>
122 </ProjectReference>
123 <ProjectReference Include="..\..\Framework\UserManager\OpenSim.Framework.UserManagement.csproj">
124 <Name>OpenSim.Framework.UserManagement</Name>
125 <Project>{586E2916-0000-0000-0000-000000000000}</Project>
126 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
127 <Private>False</Private>
128 </ProjectReference>
129 <ProjectReference Include="..\Caches\OpenSim.Region.Caches.csproj">
130 <Name>OpenSim.Region.Caches</Name>
131 <Project>{61FCCDB3-0000-0000-0000-000000000000}</Project>
132 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
133 <Private>False</Private>
134 </ProjectReference>
135 <ProjectReference Include="..\ClientStack\OpenSim.Region.ClientStack.csproj">
136 <Name>OpenSim.Region.ClientStack</Name>
137 <Project>{DC3698B2-0000-0000-0000-000000000000}</Project>
138 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
139 <Private>False</Private>
140 </ProjectReference>
141 <ProjectReference Include="..\LocalCommunications\OpenSim.Region.LocalCommunications.csproj">
142 <Name>OpenSim.Region.LocalCommunications</Name>
143 <Project>{EB3A1BA8-0000-0000-0000-000000000000}</Project>
144 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
145 <Private>False</Private>
146 </ProjectReference>
147 <ProjectReference Include="..\Physics\Manager\OpenSim.Region.Physics.Manager.csproj">
148 <Name>OpenSim.Region.Physics.Manager</Name>
149 <Project>{F4FF31EB-0000-0000-0000-000000000000}</Project>
150 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
151 <Private>False</Private>
152 </ProjectReference>
153 <ProjectReference Include="..\Simulation\OpenSim.Region.Simulation.csproj">
154 <Name>OpenSim.Region.Simulation</Name>
155 <Project>{C0DAB338-0000-0000-0000-000000000000}</Project>
156 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
157 <Private>False</Private>
158 </ProjectReference>
159 <ProjectReference Include="..\Terrain.BasicTerrain\OpenSim.Region.Terrain.BasicTerrain.csproj">
160 <Name>OpenSim.Region.Terrain.BasicTerrain</Name>
161 <Project>{C9E0F891-0000-0000-0000-000000000000}</Project>
162 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
163 <Private>False</Private>
164 </ProjectReference>
165 </ItemGroup>
166 <ItemGroup>
167 <Compile Include="Application.cs">
168 <SubType>Code</SubType>
169 </Compile>
170 <Compile Include="OpenSimMain.cs">
171 <SubType>Code</SubType>
172 </Compile>
173 </ItemGroup>
174 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
175 <PropertyGroup>
176 <PreBuildEvent>
177 </PreBuildEvent>
178 <PostBuildEvent>
179 </PostBuildEvent>
180 </PropertyGroup>
181</Project>
diff --git a/OpenSim/Region/Application/OpenSim.csproj.user b/OpenSim/Region/Application/OpenSim.csproj.user
new file mode 100644
index 0000000..2ff1c4c
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSim.csproj.user
@@ -0,0 +1,13 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <StartArguments>-loginserver -sandbox -accounts</StartArguments>
6 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\</ReferencePath>
7 <LastOpenVersion>8.0.50727</LastOpenVersion>
8 <ProjectView>ProjectFiles</ProjectView>
9 <ProjectTrust>0</ProjectTrust>
10 </PropertyGroup>
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
12 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
13</Project>
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
new file mode 100644
index 0000000..7da2263
--- /dev/null
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -0,0 +1,476 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Text;
31using System.IO;
32using System.Threading;
33using System.Net;
34using System.Net.Sockets;
35using System.Timers;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using libsecondlife.Packets;
41using OpenSim.Region;
42using OpenSim.Region.Scenes;
43using OpenSim.Terrain;
44using OpenSim.Framework.Interfaces;
45using OpenSim.Framework.Types;
46using OpenSim.Framework;
47using OpenSim.Assets;
48using OpenSim.Caches;
49using OpenSim.Framework.Console;
50using OpenSim.Physics.Manager;
51using Nwc.XmlRpc;
52using OpenSim.Servers;
53using OpenSim.GenericConfig;
54using OpenGrid.Framework.Communications;
55using OpenSim.LocalCommunications;
56using OpenGrid.Framework.Communications.OGS1;
57
58namespace OpenSim
59{
60
61 public class OpenSimMain : RegionApplicationBase, conscmd_callback
62 {
63 // private CheckSumServer checkServer;
64 protected CommunicationsManager commsManager;
65
66 private bool m_silent;
67 private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
68
69 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
70 {
71 this.configFileSetup = useConfigFile;
72 m_sandbox = sandBoxMode;
73 m_loginserver = startLoginServer;
74 m_physicsEngine = physicsEngine;
75 m_config = configFile;
76 m_silent = silent;
77 }
78
79 /// <summary>
80 /// Performs initialisation of the world, such as loading configuration from disk.
81 /// </summary>
82 public override void StartUp()
83 {
84 this.serversData = new NetworkServersInfo();
85
86 this.localConfig = new XmlConfig(m_config);
87 this.localConfig.LoadData();
88
89 if (this.configFileSetup)
90 {
91 this.SetupFromConfigFile(this.localConfig);
92 }
93
94 m_log = new LogBase(m_logFilename, "Region", this, m_silent);
95 OpenSim.Framework.Console.MainLog.Instance = m_log;
96
97 m_log.Verbose( "Main.cs:Startup() - Loading configuration");
98 this.serversData.InitConfig(this.m_sandbox, this.localConfig);
99 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
100
101 ScenePresence.LoadTextureFile("avatar-texture.dat");
102
103 ClientView.TerrainManager = new TerrainManager(new SecondLife());
104
105 CommunicationsLocal sandboxCommunications = null;
106 if (m_sandbox)
107 {
108 this.SetupLocalGridServers();
109 // this.checkServer = new CheckSumServer(12036);
110 // this.checkServer.ServerListener();
111 sandboxCommunications = new CommunicationsLocal(this.serversData);
112 this.commsManager = sandboxCommunications;
113 }
114 else
115 {
116 this.SetupRemoteGridServers();
117 this.commsManager = new GridCommsManager(this.serversData);
118 }
119
120 startuptime = DateTime.Now;
121
122 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
123 this.physManager.LoadPlugins();
124
125 this.SetupHttpListener();
126
127 this.SetupWorld();
128
129 m_log.Verbose( "Main.cs:Startup() - Initialising HTTP server");
130
131
132
133 if (m_sandbox)
134 {
135 httpServer.AddXmlRPCHandler("login_to_simulator", sandboxCommunications.UserServices.XmlRpcLoginMethod);
136 }
137
138 //Start http server
139 m_log.Verbose( "Main.cs:Startup() - Starting HTTP server");
140 httpServer.Start();
141
142 // Start UDP servers
143 for (int i = 0; i < m_udpServer.Count; i++)
144 {
145 this.m_udpServer[i].ServerListener();
146 }
147
148 }
149
150 # region Setup methods
151 protected override void SetupLocalGridServers()
152 {
153 try
154 {
155 AssetCache = new AssetCache("OpenSim.GridInterfaces.Local.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
156 InventoryCache = new InventoryCache();
157 }
158 catch (Exception e)
159 {
160 m_log.Error( e.Message + "\nSorry, could not setup local cache");
161 Environment.Exit(1);
162 }
163
164 }
165
166 protected override void SetupRemoteGridServers()
167 {
168 try
169 {
170 AssetCache = new AssetCache("OpenSim.GridInterfaces.Remote.dll", this.serversData.AssetURL, this.serversData.AssetSendKey);
171 InventoryCache = new InventoryCache();
172 }
173 catch (Exception e)
174 {
175 m_log.Error( e.Message + "\nSorry, could not setup remote cache");
176 Environment.Exit(1);
177 }
178 }
179
180 protected override void SetupWorld()
181 {
182 IGenericConfig regionConfig;
183 Scene LocalWorld;
184 UDPServer udpServer;
185 RegionInfo regionDat = new RegionInfo();
186 AuthenticateSessionsBase authenBase;
187
188 string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Regions");
189 string[] configFiles = Directory.GetFiles(path, "*.xml");
190
191 if (configFiles.Length == 0)
192 {
193 string path2 = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Regions");
194 string path3 = Path.Combine(path2, "default.xml");
195 Console.WriteLine("Creating default region config file");
196 //TODO create default region
197 IGenericConfig defaultConfig = new XmlConfig(path3);
198 defaultConfig.LoadData();
199 defaultConfig.Commit();
200 defaultConfig.Close();
201 defaultConfig = null;
202 configFiles = Directory.GetFiles(path, "*.xml");
203 }
204
205 for (int i = 0; i < configFiles.Length; i++)
206 {
207 regionDat = new RegionInfo();
208 if (m_sandbox)
209 {
210 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
211 this.AuthenticateSessionsHandler.Add(authen);
212 authenBase = authen;
213 }
214 else
215 {
216 AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); //new AuthenticateSessionsRemote();
217 this.AuthenticateSessionsHandler.Add(authen);
218 authenBase = authen;
219 }
220 Console.WriteLine("Loading region config file");
221 regionConfig = new XmlConfig(configFiles[i]);
222 regionConfig.LoadData();
223 regionDat.InitConfig(this.m_sandbox, regionConfig);
224 regionConfig.Close();
225
226 udpServer = new UDPServer(regionDat.CommsIPListenPort, this.AssetCache, this.InventoryCache, this.m_log, authenBase);
227
228 m_udpServer.Add(udpServer);
229 this.regionData.Add(regionDat);
230
231 /*
232 m_log.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
233 m_log.Verbose( "Initialising world");
234 m_log.componentname = "Region " + regionData.RegionName;
235 */
236
237 LocalWorld = new Scene(udpServer.PacketServer.ClientAPIs, regionDat, authenBase, commsManager, this.AssetCache, httpServer);
238 this.m_localWorld.Add(LocalWorld);
239 //LocalWorld.InventoryCache = InventoryCache;
240 //LocalWorld.AssetCache = AssetCache;
241
242 udpServer.LocalWorld = LocalWorld;
243
244 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
245 LocalWorld.LoadWorldMap();
246
247 m_log.Verbose( "Main.cs:Startup() - Starting up messaging system");
248 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
249 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
250 LocalWorld.LoadPrimsFromStorage();
251 LocalWorld.localStorage.LoadParcels((ILocalStorageParcelReceiver)LocalWorld.parcelManager);
252
253
254 LocalWorld.StartTimer();
255 }
256 }
257
258 protected override void SetupHttpListener()
259 {
260 httpServer = new BaseHttpServer(this.serversData.HttpListenerPort); //regionData[0].IPListenPort);
261
262 if (!this.m_sandbox)
263 {
264
265 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
266
267
268 httpServer.AddRestHandler("GET", "/simstatus/",
269 delegate(string request, string path, string param)
270 {
271 return "OK";
272 });
273 }
274 }
275
276 protected override void ConnectToRemoteGridServer()
277 {
278
279 }
280
281 #endregion
282
283 private void SetupFromConfigFile(IGenericConfig configData)
284 {
285 // Log filename
286 string attri = "";
287 attri = configData.GetAttribute("LogFilename");
288 if (String.IsNullOrEmpty(attri))
289 {
290 }
291 else
292 {
293 m_logFilename = attri;
294 }
295
296 // SandBoxMode
297 attri = "";
298 attri = configData.GetAttribute("SandBox");
299 if ((attri == "") || ((attri != "false") && (attri != "true")))
300 {
301 this.m_sandbox = false;
302 configData.SetAttribute("SandBox", "false");
303 }
304 else
305 {
306 this.m_sandbox = Convert.ToBoolean(attri);
307 }
308
309 // LoginServer
310 attri = "";
311 attri = configData.GetAttribute("LoginServer");
312 if ((attri == "") || ((attri != "false") && (attri != "true")))
313 {
314 this.m_loginserver = false;
315 configData.SetAttribute("LoginServer", "false");
316 }
317 else
318 {
319 this.m_loginserver = Convert.ToBoolean(attri);
320 }
321
322 // Sandbox User accounts
323 attri = "";
324 attri = configData.GetAttribute("UserAccount");
325 if ((attri == "") || ((attri != "false") && (attri != "true")))
326 {
327 this.user_accounts = false;
328 configData.SetAttribute("UserAccounts", "false");
329 }
330 else if (attri == "true")
331 {
332 this.user_accounts = Convert.ToBoolean(attri);
333 }
334
335 // Grid mode hack to use local asset server
336 attri = "";
337 attri = configData.GetAttribute("LocalAssets");
338 if ((attri == "") || ((attri != "false") && (attri != "true")))
339 {
340 this.gridLocalAsset = false;
341 configData.SetAttribute("LocalAssets", "false");
342 }
343 else if (attri == "true")
344 {
345 this.gridLocalAsset = Convert.ToBoolean(attri);
346 }
347
348
349 attri = "";
350 attri = configData.GetAttribute("PhysicsEngine");
351 switch (attri)
352 {
353 default:
354 m_log.Warn( "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
355 Environment.Exit(1);
356 break;
357
358 case "":
359 this.m_physicsEngine = "basicphysics";
360 configData.SetAttribute("PhysicsEngine", "basicphysics");
361 OpenSim.Region.Scenes.ScenePresence.PhysicsEngineFlying = false;
362 break;
363
364 case "basicphysics":
365 this.m_physicsEngine = "basicphysics";
366 configData.SetAttribute("PhysicsEngine", "basicphysics");
367 OpenSim.Region.Scenes.ScenePresence.PhysicsEngineFlying = false;
368 break;
369
370 case "RealPhysX":
371 this.m_physicsEngine = "RealPhysX";
372 OpenSim.Region.Scenes.ScenePresence.PhysicsEngineFlying = true;
373 break;
374
375 case "OpenDynamicsEngine":
376 this.m_physicsEngine = "OpenDynamicsEngine";
377 OpenSim.Region.Scenes.ScenePresence.PhysicsEngineFlying = true;
378 break;
379 }
380
381 configData.Commit();
382
383 }
384
385 /// <summary>
386 /// Performs any last-minute sanity checking and shuts down the region server
387 /// </summary>
388 public virtual void Shutdown()
389 {
390 m_log.Verbose( "Main.cs:Shutdown() - Closing all threads");
391 m_log.Verbose( "Main.cs:Shutdown() - Killing listener thread");
392 m_log.Verbose( "Main.cs:Shutdown() - Killing clients");
393 // IMPLEMENT THIS
394 m_log.Verbose( "Main.cs:Shutdown() - Closing console and terminating");
395 for (int i = 0; i < m_localWorld.Count; i++)
396 {
397 ((Scene)m_localWorld[i]).Close();
398 }
399 m_log.Close();
400 Environment.Exit(0);
401 }
402
403 #region Console Commands
404 /// <summary>
405 /// Runs commands issued by the server console from the operator
406 /// </summary>
407 /// <param name="command">The first argument of the parameter (the command)</param>
408 /// <param name="cmdparams">Additional arguments passed to the command</param>
409 public void RunCmd(string command, string[] cmdparams)
410 {
411 switch (command)
412 {
413 case "help":
414 m_log.Error( "show users - show info about connected users");
415 m_log.Error( "shutdown - disconnect all clients and shutdown");
416 break;
417
418 case "show":
419 if (cmdparams.Length > 0)
420 {
421 Show(cmdparams[0]);
422 }
423 break;
424
425 case "terrain":
426 string result = "";
427 for (int i = 0; i < m_localWorld.Count; i++)
428 {
429 if (!((Scene)m_localWorld[i]).Terrain.RunTerrainCmd(cmdparams, ref result))
430 {
431 m_log.Error(result);
432 }
433 }
434 break;
435
436 case "shutdown":
437 Shutdown();
438 break;
439
440 default:
441 m_log.Error( "Unknown command");
442 break;
443 }
444 }
445
446 /// <summary>
447 /// Outputs to the console information about the region
448 /// </summary>
449 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
450 public void Show(string ShowWhat)
451 {
452 switch (ShowWhat)
453 {
454 case "uptime":
455 m_log.Error( "OpenSim has been running since " + startuptime.ToString());
456 m_log.Error( "That is " + (DateTime.Now - startuptime).ToString());
457 break;
458 case "users":
459 OpenSim.Region.Scenes.ScenePresence TempAv;
460 m_log.Error( String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
461 /* foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
462 {
463 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
464 {
465 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
466 m_log.Error( String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
467 }
468 }*/
469 break;
470 }
471 }
472 #endregion
473 }
474
475
476} \ No newline at end of file