aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim-Source/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim-Source/OpenSim')
-rw-r--r--OpenSim-Source/OpenSim/Application.cs95
-rw-r--r--OpenSim-Source/OpenSim/OpenSim.csproj147
-rw-r--r--OpenSim-Source/OpenSim/OpenSim.csproj.user13
-rw-r--r--OpenSim-Source/OpenSim/OpenSim.exe.build52
-rw-r--r--OpenSim-Source/OpenSim/OpenSimMain.cs533
5 files changed, 840 insertions, 0 deletions
diff --git a/OpenSim-Source/OpenSim/Application.cs b/OpenSim-Source/OpenSim/Application.cs
new file mode 100644
index 0000000..3f9c0ec
--- /dev/null
+++ b/OpenSim-Source/OpenSim/Application.cs
@@ -0,0 +1,95 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.UserServer;
5using OpenSim.Framework.Console;
6
7namespace OpenSim
8{
9 public class Application
10 {
11 //could move our main function into OpenSimMain and kill this class
12 [STAThread]
13 public static void Main(string[] args)
14 {
15 Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
16 Console.WriteLine("Starting...\n");
17
18 bool sandBoxMode = false;
19 bool startLoginServer = false;
20 string physicsEngine = "basicphysics";
21 bool allowFlying = false;
22 bool userAccounts = false;
23 bool gridLocalAsset = false;
24 bool useConfigFile = false;
25 bool silent = false;
26 string configFile = "simconfig.xml";
27
28 for (int i = 0; i < args.Length; i++)
29 {
30 if (args[i] == "-sandbox")
31 {
32 sandBoxMode = true;
33 startLoginServer = true;
34 }
35 /*
36 if (args[i] == "-loginserver")
37 {
38 startLoginServer = true;
39 }*/
40 if (args[i] == "-accounts")
41 {
42 userAccounts = true;
43 }
44 if (args[i] == "-realphysx")
45 {
46 physicsEngine = "RealPhysX";
47 allowFlying = true;
48 }
49 if (args[i] == "-ode")
50 {
51 physicsEngine = "OpenDynamicsEngine";
52 allowFlying = true;
53 }
54 if (args[i] == "-localasset")
55 {
56 gridLocalAsset = true;
57 }
58 if (args[i] == "-configfile")
59 {
60 useConfigFile = true;
61 }
62 if (args[i] == "-noverbose")
63 {
64 silent = true;
65 }
66 if (args[i] == "-config")
67 {
68 try
69 {
70 i++;
71 configFile = args[i];
72 }
73 catch (Exception e)
74 {
75 Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
76 }
77 }
78 }
79
80 OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
81 // OpenSimRoot.Instance.Application = sim;
82 sim.m_sandbox = sandBoxMode;
83 sim.user_accounts = userAccounts;
84 sim.gridLocalAsset = gridLocalAsset;
85 OpenSim.world.Avatar.PhysicsEngineFlying = allowFlying;
86
87 sim.StartUp();
88
89 while (true)
90 {
91 OpenSim.Framework.Console.MainConsole.Instance.MainConsolePrompt();
92 }
93 }
94 }
95}
diff --git a/OpenSim-Source/OpenSim/OpenSim.csproj b/OpenSim-Source/OpenSim/OpenSim.csproj
new file mode 100644
index 0000000..4456fc7
--- /dev/null
+++ b/OpenSim-Source/OpenSim/OpenSim.csproj
@@ -0,0 +1,147 @@
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="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.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="Axiom.MathLib.dll" >
74 <HintPath>..\bin\Axiom.MathLib.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Db4objects.Db4o.dll" >
78 <HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
84 <Name>OpenSim.Terrain.BasicTerrain</Name>
85 <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
90 <Name>OpenSim.Framework</Name>
91 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
96 <Name>OpenSim.Framework.Console</Name>
97 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private>
100 </ProjectReference>
101 <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
102 <Name>OpenSim.Physics.Manager</Name>
103 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private>
106 </ProjectReference>
107 <ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj">
108 <Name>OpenSim.Servers</Name>
109 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 <ProjectReference Include="..\OpenSim.RegionServer\OpenSim.RegionServer.csproj">
114 <Name>OpenSim.RegionServer</Name>
115 <Project>{632E1BFD-0000-0000-0000-000000000000}</Project>
116 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
117 <Private>False</Private>
118 </ProjectReference>
119 <ProjectReference Include="..\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
120 <Name>OpenSim.GenericConfig.Xml</Name>
121 <Project>{E88EF749-0000-0000-0000-000000000000}</Project>
122 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
123 <Private>False</Private>
124 </ProjectReference>
125 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
126 <Name>XMLRPC</Name>
127 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
128 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
129 <Private>False</Private>
130 </ProjectReference>
131 </ItemGroup>
132 <ItemGroup>
133 <Compile Include="Application.cs">
134 <SubType>Code</SubType>
135 </Compile>
136 <Compile Include="OpenSimMain.cs">
137 <SubType>Code</SubType>
138 </Compile>
139 </ItemGroup>
140 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
141 <PropertyGroup>
142 <PreBuildEvent>
143 </PreBuildEvent>
144 <PostBuildEvent>
145 </PostBuildEvent>
146 </PropertyGroup>
147</Project>
diff --git a/OpenSim-Source/OpenSim/OpenSim.csproj.user b/OpenSim-Source/OpenSim/OpenSim.csproj.user
new file mode 100644
index 0000000..1422ebf
--- /dev/null
+++ b/OpenSim-Source/OpenSim/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-07\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-Source/OpenSim/OpenSim.exe.build b/OpenSim-Source/OpenSim/OpenSim.exe.build
new file mode 100644
index 0000000..19d0b28
--- /dev/null
+++ b/OpenSim-Source/OpenSim/OpenSim.exe.build
@@ -0,0 +1,52 @@
1<?xml version="1.0" ?>
2<project name="OpenSim" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="OpenSim" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Application.cs" />
15 <include name="OpenSimMain.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="System.Xml.dll" />
24 <include name="../bin/libsecondlife.dll" />
25 <include name="../bin/Axiom.MathLib.dll" />
26 <include name="../bin/Db4objects.Db4o.dll" />
27 <include name="../bin/OpenSim.Terrain.BasicTerrain.dll" />
28 <include name="../bin/OpenSim.Framework.dll" />
29 <include name="../bin/OpenSim.Framework.Console.dll" />
30 <include name="../bin/OpenSim.Physics.Manager.dll" />
31 <include name="../bin/OpenSim.Servers.dll" />
32 <include name="../bin/OpenSim.RegionServer.dll" />
33 <include name="../bin/OpenSim.GenericConfig.Xml.dll" />
34 <include name="../bin/XMLRPC.dll" />
35 </references>
36 </csc>
37 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
38 <mkdir dir="${project::get-base-directory()}/../bin/"/>
39 <copy todir="${project::get-base-directory()}/../bin/">
40 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
41 <include name="*.dll"/>
42 <include name="*.exe"/>
43 </fileset>
44 </copy>
45 </target>
46 <target name="clean">
47 <delete dir="${bin.dir}" failonerror="false" />
48 <delete dir="${obj.dir}" failonerror="false" />
49 </target>
50 <target name="doc" description="Creates documentation.">
51 </target>
52</project>
diff --git a/OpenSim-Source/OpenSim/OpenSimMain.cs b/OpenSim-Source/OpenSim/OpenSimMain.cs
new file mode 100644
index 0000000..9025316
--- /dev/null
+++ b/OpenSim-Source/OpenSim/OpenSimMain.cs
@@ -0,0 +1,533 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* All rights reserved.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the <organization> nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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.world;
42using OpenSim.Terrain;
43using OpenSim.Framework.Interfaces;
44using OpenSim.Framework.Types;
45using OpenSim.UserServer;
46using OpenSim.Assets;
47using OpenSim.CAPS;
48using OpenSim.Framework.Console;
49using OpenSim.Physics.Manager;
50using Nwc.XmlRpc;
51using OpenSim.Servers;
52using OpenSim.GenericConfig;
53
54namespace OpenSim
55{
56
57 public class OpenSimMain : RegionServerBase, conscmd_callback
58 {
59 private CheckSumServer checkServer;
60
61 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
62 {
63 this.configFileSetup = useConfigFile;
64 m_sandbox = sandBoxMode;
65 m_loginserver = startLoginServer;
66 m_physicsEngine = physicsEngine;
67 m_config = configFile;
68
69 m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent);
70 OpenSim.Framework.Console.MainConsole.Instance = m_console;
71 }
72
73 /// <summary>
74 /// Performs initialisation of the world, such as loading configuration from disk.
75 /// </summary>
76 public override void StartUp()
77 {
78 this.regionData = new RegionInfo();
79 try
80 {
81 this.localConfig = new XmlConfig(m_config);
82 this.localConfig.LoadData();
83 }
84 catch (Exception e)
85 {
86 Console.WriteLine(e.Message);
87 }
88 if (this.configFileSetup)
89 {
90 this.SetupFromConfigFile(this.localConfig);
91 }
92 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
93 this.regionData.InitConfig(this.m_sandbox, this.localConfig);
94 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
95
96 GridServers = new Grid();
97 if (m_sandbox)
98 {
99 this.SetupLocalGridServers();
100 //Authenticate Session Handler
101 AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal();
102 this.AuthenticateSessionsHandler = authen;
103 this.checkServer = new CheckSumServer(12036);
104 this.checkServer.ServerListener();
105 }
106 else
107 {
108 this.SetupRemoteGridServers();
109 //Authenticate Session Handler
110 AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote();
111 this.AuthenticateSessionsHandler = authen;
112 }
113
114 startuptime = DateTime.Now;
115
116 try
117 {
118 AssetCache = new AssetCache(GridServers.AssetServer);
119 InventoryCache = new InventoryCache();
120 }
121 catch (Exception e)
122 {
123 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache");
124 Environment.Exit(1);
125 }
126
127 m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler);
128
129 //should be passing a IGenericConfig object to these so they can read the config data they want from it
130 GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
131 IGridServer gridServer = GridServers.GridServer;
132 gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
133
134 if (!m_sandbox)
135 {
136 this.ConnectToRemoteGridServer();
137 }
138
139 this.SetupLocalWorld();
140
141 if (m_sandbox)
142 {
143 AssetCache.LoadDefaultTextureSet();
144 }
145
146 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
147
148 this.SetupHttpListener();
149
150 //Login server setup
151 LoginServer loginServer = null;
152 LoginServer adminLoginServer = null;
153
154 bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
155 if (sandBoxWithLoginServer)
156 {
157 loginServer = new LoginServer(regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
158 loginServer.Startup();
159 loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler).AddNewSession);
160
161 if (user_accounts)
162 {
163 //sandbox mode with loginserver using accounts
164 this.GridServers.UserServer = loginServer;
165 adminLoginServer = loginServer;
166
167 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
168 }
169 else
170 {
171 //sandbox mode with loginserver not using accounts
172 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
173 }
174 }
175
176 //Web front end setup
177 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
178 adminWebFront.LoadMethods(httpServer);
179
180 //Start http server
181 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
182 httpServer.Start();
183
184 // Start UDP server
185 this.m_udpServer.ServerListener();
186
187 m_heartbeatTimer.Enabled = true;
188 m_heartbeatTimer.Interval = 100;
189 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
190 }
191
192 # region Setup methods
193 protected override void SetupLocalGridServers()
194 {
195 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
196 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
197
198 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
199
200 try
201 {
202 GridServers.Initialise();
203 }
204 catch (Exception e)
205 {
206 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
207 Environment.Exit(1);
208 }
209 }
210
211 protected override void SetupRemoteGridServers()
212 {
213 if (this.gridLocalAsset)
214 {
215 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
216 }
217 else
218 {
219 GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
220 }
221 GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
222
223 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
224
225 try
226 {
227 GridServers.Initialise();
228 }
229 catch (Exception e)
230 {
231 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
232 Environment.Exit(1);
233 }
234 }
235
236 protected override void SetupLocalWorld()
237 {
238 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
239 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
240 m_console.componentname = "Region " + regionData.RegionName;
241
242 m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
243 LocalWorld.InventoryCache = InventoryCache;
244 LocalWorld.AssetCache = AssetCache;
245
246 this.m_udpServer.LocalWorld = LocalWorld;
247 this.m_udpServer.PacketServer.RegisterClientPacketHandlers();
248
249 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
250 this.physManager.LoadPlugins();
251
252 LocalWorld.m_datastore = this.regionData.DataStore;
253
254 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
255 LocalWorld.LoadWorldMap();
256
257 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
258 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
259 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
260 LocalWorld.LoadPrimsFromStorage();
261 }
262
263 protected override void SetupHttpListener()
264 {
265 httpServer = new BaseHttpServer(regionData.IPListenPort);
266
267 if (this.GridServers.GridServer.GetName() == "Remote")
268 {
269
270 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
271 httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser);
272
273 httpServer.AddXmlRPCHandler("agent_crossing",
274 delegate(XmlRpcRequest request)
275 {
276 Hashtable requestData = (Hashtable)request.Params[0];
277 uint circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
278
279 AgentCircuitData agent_data = new AgentCircuitData();
280 agent_data.firstname = (string)requestData["firstname"];
281 agent_data.lastname = (string)requestData["lastname"];
282 agent_data.circuitcode = circuitcode;
283 agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
284
285 AuthenticateSessionsHandler.UpdateAgentData(agent_data);
286
287 return new XmlRpcResponse();
288 });
289
290 httpServer.AddRestHandler("GET", "/simstatus/",
291 delegate(string request, string path, string param)
292 {
293 return "OK";
294 });
295 }
296 }
297
298 protected override void ConnectToRemoteGridServer()
299 {
300 if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
301 {
302 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!");
303 }
304 else
305 {
306 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
307 Shutdown();
308 }
309
310 GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
311
312 // If we are being told to load a file, load it.
313 string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
314
315 if (!String.IsNullOrEmpty(dataUri))
316 {
317 this.LocalWorld.m_datastore = dataUri;
318 }
319
320 if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
321 {
322 // The grid server has told us who we are
323 // We must obey the grid server.
324 try
325 {
326 regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
327 regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
328 regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
329 }
330 catch (Exception e)
331 {
332 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
333 Environment.Exit(1);
334 }
335 }
336 }
337
338 #endregion
339
340 private void SetupFromConfigFile(IGenericConfig configData)
341 {
342 try
343 {
344 // SandBoxMode
345 string attri = "";
346 attri = configData.GetAttribute("SandBox");
347 if ((attri == "") || ((attri != "false") && (attri != "true")))
348 {
349 this.m_sandbox = false;
350 configData.SetAttribute("SandBox", "false");
351 }
352 else
353 {
354 this.m_sandbox = Convert.ToBoolean(attri);
355 }
356
357 // LoginServer
358 attri = "";
359 attri = configData.GetAttribute("LoginServer");
360 if ((attri == "") || ((attri != "false") && (attri != "true")))
361 {
362 this.m_loginserver = false;
363 configData.SetAttribute("LoginServer", "false");
364 }
365 else
366 {
367 this.m_loginserver = Convert.ToBoolean(attri);
368 }
369
370 // Sandbox User accounts
371 attri = "";
372 attri = configData.GetAttribute("UserAccount");
373 if ((attri == "") || ((attri != "false") && (attri != "true")))
374 {
375 this.user_accounts = false;
376 configData.SetAttribute("UserAccounts", "false");
377 }
378 else if (attri == "true")
379 {
380 this.user_accounts = Convert.ToBoolean(attri);
381 }
382
383 // Grid mode hack to use local asset server
384 attri = "";
385 attri = configData.GetAttribute("LocalAssets");
386 if ((attri == "") || ((attri != "false") && (attri != "true")))
387 {
388 this.gridLocalAsset = false;
389 configData.SetAttribute("LocalAssets", "false");
390 }
391 else if (attri == "true")
392 {
393 this.gridLocalAsset = Convert.ToBoolean(attri);
394 }
395
396
397 attri = "";
398 attri = configData.GetAttribute("PhysicsEngine");
399 switch (attri)
400 {
401 default:
402 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
403 Environment.Exit(1);
404 break;
405
406 case "":
407 this.m_physicsEngine = "basicphysics";
408 configData.SetAttribute("PhysicsEngine", "basicphysics");
409 OpenSim.world.Avatar.PhysicsEngineFlying = false;
410 break;
411
412 case "basicphysics":
413 this.m_physicsEngine = "basicphysics";
414 configData.SetAttribute("PhysicsEngine", "basicphysics");
415 OpenSim.world.Avatar.PhysicsEngineFlying = false;
416 break;
417
418 case "RealPhysX":
419 this.m_physicsEngine = "RealPhysX";
420 OpenSim.world.Avatar.PhysicsEngineFlying = true;
421 break;
422
423 case "OpenDynamicsEngine":
424 this.m_physicsEngine = "OpenDynamicsEngine";
425 OpenSim.world.Avatar.PhysicsEngineFlying = true;
426 break;
427 }
428
429 configData.Commit();
430 }
431 catch (Exception e)
432 {
433 Console.WriteLine(e.Message);
434 Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data");
435 Console.WriteLine("Can not continue starting up");
436 Environment.Exit(1);
437 }
438 }
439
440 /// <summary>
441 /// Performs any last-minute sanity checking and shuts down the region server
442 /// </summary>
443 public virtual void Shutdown()
444 {
445 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads");
446 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread");
447 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients");
448 // IMPLEMENT THIS
449 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating");
450 LocalWorld.Close();
451 GridServers.Close();
452 m_console.Close();
453 Environment.Exit(0);
454 }
455
456 /// <summary>
457 /// Performs per-frame updates regularly
458 /// </summary>
459 /// <param name="sender"></param>
460 /// <param name="e"></param>
461 void Heartbeat(object sender, System.EventArgs e)
462 {
463 LocalWorld.Update();
464 }
465
466 #region Console Commands
467 /// <summary>
468 /// Runs commands issued by the server console from the operator
469 /// </summary>
470 /// <param name="command">The first argument of the parameter (the command)</param>
471 /// <param name="cmdparams">Additional arguments passed to the command</param>
472 public void RunCmd(string command, string[] cmdparams)
473 {
474 switch (command)
475 {
476 case "help":
477 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users");
478 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown");
479 break;
480
481 case "show":
482 Show(cmdparams[0]);
483 break;
484
485 case "terrain":
486 string result = "";
487 if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result))
488 {
489 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result);
490 }
491 break;
492
493 case "shutdown":
494 Shutdown();
495 break;
496
497 default:
498 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command");
499 break;
500 }
501 }
502
503 /// <summary>
504 /// Outputs to the console information about the region
505 /// </summary>
506 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
507 public void Show(string ShowWhat)
508 {
509 switch (ShowWhat)
510 {
511 case "uptime":
512 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString());
513 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString());
514 break;
515 case "users":
516 OpenSim.world.Avatar TempAv;
517 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
518 foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
519 {
520 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
521 {
522 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
523 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, 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()));
524 }
525 }
526 break;
527 }
528 }
529 #endregion
530 }
531
532
533} \ No newline at end of file