From 85bdec5e0d30224f66851fe4183eb03e15828fbf Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Mon, 16 Jul 2007 20:10:54 +0000
Subject: * Massive restructuring of RegionApplicationBase, OpenSimMain and
SimpleApp
---
OpenSim/Region/Application/Application.cs | 2 +-
OpenSim/Region/Application/OpenSimMain.cs | 97 +++++++---------------
.../Region/ClientStack/RegionApplicationBase.cs | 40 ++++++++-
OpenSim/Region/Environment/RegionManager.cs | 2 +-
OpenSim/Region/Environment/Scenes/Scene.cs | 2 +-
OpenSim/Region/Examples/SimpleApp/Program.cs | 64 +++++++-------
.../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 31 -------
7 files changed, 106 insertions(+), 132 deletions(-)
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index a47ba48..a64d05f 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -43,7 +43,7 @@ namespace OpenSim
bool sandBoxMode = false;
bool startLoginServer = false;
string physicsEngine = "basicphysics";
- bool allowFlying = false;
+
bool userAccounts = false;
bool gridLocalAsset = false;
bool useConfigFile = false;
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 368af12..18c81a0 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -78,26 +78,16 @@ namespace OpenSim
m_silent = silent;
}
+
///
/// Performs initialisation of the world, such as loading configuration from disk.
///
- public void StartUp()
+ public override void StartUp()
{
- this.m_serversData = new NetworkServersInfo();
-
- this.localConfig = new XmlConfig(m_config);
- this.localConfig.LoadData();
-
- if (this.configFileSetup)
- {
- this.SetupFromConfigFile(this.localConfig);
- }
-
- m_log = new LogBase(m_logFilename, "Region", this, m_silent);
- MainLog.Instance = m_log;
+ base.StartUp();
m_log.Verbose("Main.cs:Startup() - Loading configuration");
- this.m_serversData.InitConfig(this.m_sandbox, this.localConfig);
+ this.m_networkServersInfo.InitConfig(this.m_sandbox, this.localConfig);
this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
ScenePresence.LoadTextureFile("avatar-texture.dat");
@@ -106,19 +96,18 @@ namespace OpenSim
this.SetupHttpListener();
+ m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
+ m_inventoryCache = new InventoryCache();
+
if (m_sandbox)
{
- this.SetupLocalGridServers();
- // this.checkServer = new CheckSumServer(12036);
- // this.checkServer.ServerListener();
+ this.commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer);
}
else
{
- this.SetupRemoteGridServers();
+ this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer );
}
- m_startuptime = DateTime.Now;
-
this.SetupScene();
m_log.Verbose("Main.cs:Startup() - Initialising HTTP server");
@@ -135,44 +124,30 @@ namespace OpenSim
}
- # region Setup methods
- protected void SetupLocalGridServers()
+ protected override void Initialize()
{
- try
- {
- m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.m_serversData.AssetURL, this.m_serversData.AssetSendKey);
- m_inventoryCache = new InventoryCache();
- this.commsManager = new CommunicationsLocal(this.m_serversData, m_httpServer);
- }
- catch (Exception e)
+ this.localConfig = new XmlConfig(m_config);
+ this.localConfig.LoadData();
+
+ if (this.configFileSetup)
{
- m_log.Error(e.Message + "\nSorry, could not setup local cache");
- Environment.Exit(1);
+ this.SetupFromConfigFile(this.localConfig);
}
-
}
- protected void SetupRemoteGridServers()
+ protected override LogBase CreateLog()
{
- try
- {
- m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", this.m_serversData.AssetURL, this.m_serversData.AssetSendKey);
- m_inventoryCache = new InventoryCache();
- this.commsManager = new CommunicationsOGS1(this.m_serversData, m_httpServer);
- }
- catch (Exception e)
- {
- m_log.Error(e.Message + "\nSorry, could not setup remote cache");
- Environment.Exit(1);
- }
+ return new LogBase(m_logFilename, "Region", this, m_silent);
}
+ # region Setup methods
+
protected void SetupScene()
{
IGenericConfig regionConfig;
- Scene scene;
+
UDPServer udpServer;
- RegionInfo regionDat = new RegionInfo();
+ RegionInfo m_regionInfo = new RegionInfo();
AuthenticateSessionsBase authenBase;
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
@@ -194,7 +169,7 @@ namespace OpenSim
for (int i = 0; i < configFiles.Length; i++)
{
- regionDat = new RegionInfo();
+ m_regionInfo = new RegionInfo();
if (m_sandbox)
{
AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
@@ -210,17 +185,17 @@ namespace OpenSim
Console.WriteLine("Loading region config file");
regionConfig = new XmlConfig(configFiles[i]);
regionConfig.LoadData();
- regionDat.InitConfig(this.m_sandbox, regionConfig);
+ m_regionInfo.InitConfig(this.m_sandbox, regionConfig);
regionConfig.Close();
- udpServer = new UDPServer(regionDat.InternalEndPoint.Port, m_assetCache, this.m_inventoryCache, this.m_log, authenBase);
+ udpServer = new UDPServer(m_regionInfo.InternalEndPoint.Port, m_assetCache, this.m_inventoryCache, this.m_log, authenBase);
m_udpServer.Add(udpServer);
- this.m_regionData.Add(regionDat);
+ this.m_regionData.Add(m_regionInfo);
- StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", regionDat.DataStore, regionDat.RegionName);
+ StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", m_regionInfo.DataStore, m_regionInfo.RegionName);
- scene = new Scene( regionDat, authenBase, commsManager, m_assetCache, tmpStoreManager, m_httpServer);
+ Scene scene = new Scene( m_regionInfo, authenBase, commsManager, m_assetCache, tmpStoreManager, m_httpServer);
this.m_localWorld.Add(scene);
udpServer.LocalWorld = scene;
@@ -253,12 +228,9 @@ namespace OpenSim
}
}
- private static PhysicsScene GetPhysicsScene(string physicsEngine)
+ protected override PhysicsScene GetPhysicsScene( )
{
- PhysicsPluginManager physicsPluginManager;
- physicsPluginManager = new PhysicsPluginManager();
- physicsPluginManager.LoadPlugins();
- return physicsPluginManager.GetPhysicsScene( physicsEngine );
+ return GetPhysicsScene( m_physicsEngine );
}
private class SimStatusHandler : IStreamHandler
@@ -286,7 +258,7 @@ namespace OpenSim
protected void SetupHttpListener()
{
- m_httpServer = new BaseHttpServer(this.m_serversData.HttpListenerPort); //regionData[0].IPListenPort);
+ m_httpServer = new BaseHttpServer(this.m_networkServersInfo.HttpListenerPort); //regionData[0].IPListenPort);
if (!this.m_sandbox)
{
@@ -372,16 +344,9 @@ namespace OpenSim
switch (attri)
{
default:
- m_log.Warn("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
- Environment.Exit(1);
- break;
+ throw new ArgumentException(String.Format( "Invalid value [{0}] for PhysicsEngine attribute, terminating", attri ) );
case "":
- this.m_physicsEngine = "basicphysics";
- configData.SetAttribute("PhysicsEngine", "basicphysics");
- ScenePresence.PhysicsEngineFlying = false;
- break;
-
case "basicphysics":
this.m_physicsEngine = "basicphysics";
configData.SetAttribute("PhysicsEngine", "basicphysics");
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index ec7eee4..043659b 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -37,16 +37,17 @@ using OpenSim.Framework.Types;
using OpenSim.Physics.Manager;
using OpenSim.Region.Caches;
using OpenSim.Region.Environment;
+using libsecondlife;
namespace OpenSim.Region.ClientStack
{
- public class RegionApplicationBase
+ public abstract class RegionApplicationBase
{
protected AssetCache m_assetCache;
protected InventoryCache m_inventoryCache;
protected Dictionary m_clientCircuits = new Dictionary();
protected DateTime m_startuptime;
- protected NetworkServersInfo m_serversData;
+ protected NetworkServersInfo m_networkServersInfo;
protected List m_udpServer = new List();
protected List m_regionData = new List();
@@ -58,7 +59,40 @@ namespace OpenSim.Region.ClientStack
public RegionApplicationBase( )
{
-
+ m_startuptime = DateTime.Now;
}
+
+ virtual public void StartUp()
+ {
+ ClientView.TerrainManager = new TerrainManager(new SecondLife());
+ m_networkServersInfo = new NetworkServersInfo();
+ RegionInfo m_regionInfo = new RegionInfo();
+
+ Initialize();
+
+ StartLog();
+
+ }
+
+ protected abstract void Initialize();
+
+ private void StartLog()
+ {
+ LogBase logBase = CreateLog();
+ m_log = logBase;
+ MainLog.Instance = m_log;
+ }
+
+ protected abstract LogBase CreateLog();
+ protected abstract PhysicsScene GetPhysicsScene( );
+
+ protected PhysicsScene GetPhysicsScene(string engine)
+ {
+ PhysicsPluginManager physicsPluginManager;
+ physicsPluginManager = new PhysicsPluginManager();
+ physicsPluginManager.LoadPlugins();
+ return physicsPluginManager.GetPhysicsScene( engine );
+ }
+
}
}
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs
index 92e2766..f951701 100644
--- a/OpenSim/Region/Environment/RegionManager.cs
+++ b/OpenSim/Region/Environment/RegionManager.cs
@@ -8,7 +8,7 @@ using OpenSim.Region.Environment.LandManagement;
namespace OpenSim.Region.Environment
{
- public class RegionManager //needs renaming , but first we need to rename the namespace
+ public class RegionManager
{
protected AuthenticateSessionsBase authenticateHandler;
protected RegionCommsListener regionCommsHost;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 917f6c4..d2bb030 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment.Scenes
return (this.phyScene);
}
}
-
+
private LandManager m_LandManager;
public LandManager LandManager
{
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index a2fdd81..8ff2b77 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -19,24 +19,28 @@ using OpenSim.Framework.Data;
namespace SimpleApp
{
- class Program : conscmd_callback
+ class Program : RegionApplicationBase, conscmd_callback
{
- private LogBase m_log;
AuthenticateSessionsBase m_circuitManager;
- uint m_localId;
- public MyWorld world;
+
+ public MyWorld m_world;
private SceneObject m_sceneObject;
public MyNpcCharacter m_character;
-
- private void Run()
+
+ protected override LogBase CreateLog()
{
- m_log = new LogBase(null, "SimpleApp", this, false);
- MainLog.Instance = m_log;
+ return new LogBase(null, "SimpleApp", this, false);
+ }
- // CheckSumServer checksumServer = new CheckSumServer(12036);
- // checksumServer.ServerListener();
+ protected override void Initialize()
+ {
+ }
+
+ public void Run()
+ {
+ base.StartUp();
- IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
+ MainLog.Instance = m_log;
m_circuitManager = new AuthenticateSessionsBase();
@@ -50,30 +54,27 @@ namespace SimpleApp
ScenePresence.LoadTextureFile("avatar-texture.dat");
ScenePresence.PhysicsEngineFlying = true;
- PhysicsPluginManager physManager = new PhysicsPluginManager();
- physManager.LoadPlugins();
+ IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
PacketServer packetServer = new PacketServer(udpServer);
- ClientView.TerrainManager = new TerrainManager(new SecondLife());
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
- NetworkServersInfo serverInfo = new NetworkServersInfo();
- CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
+ CommunicationsLocal communicationsManager = new CommunicationsLocal(m_networkServersInfo, httpServer);
RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1");
OpenSim.Region.Environment.StorageManager storeMan = new OpenSim.Region.Environment.StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp");
- world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
- world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
+ m_world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
+ m_world.PhysScene = GetPhysicsScene( );
- world.LoadWorldMap();
- world.PhysScene.SetTerrain(world.Terrain.getHeights1D());
- world.performParcelPrimCountUpdate();
+ m_world.LoadWorldMap();
+ m_world.PhysScene.SetTerrain(m_world.Terrain.getHeights1D());
+ m_world.performParcelPrimCountUpdate();
- udpServer.LocalWorld = world;
+ udpServer.LocalWorld = m_world;
httpServer.Start();
udpServer.ServerListener();
@@ -81,27 +82,32 @@ namespace SimpleApp
UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
if (masterAvatar != null)
{
- world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
- world.LandManager.NoLandDataFromStorage();
+ m_world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
+ m_world.LandManager.NoLandDataFromStorage();
}
- world.StartTimer();
+ m_world.StartTimer();
PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
LLVector3 pos = new LLVector3(138, 129, 27);
- m_sceneObject = new MySceneObject(world, world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape);
- world.AddEntity(m_sceneObject);
+ m_sceneObject = new MySceneObject(m_world, m_world.EventManager, LLUUID.Zero, m_world.PrimIDAllocate(), pos, shape);
+ m_world.AddEntity(m_sceneObject);
m_character = new MyNpcCharacter();
- world.AddNewClient(m_character, false);
+ m_world.AddNewClient(m_character, false);
m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
m_log.ReadLine();
}
+ protected override PhysicsScene GetPhysicsScene( )
+ {
+ return GetPhysicsScene("basicphysics");
+ }
+
#region conscmd_callback Members
public void RunCmd(string cmd, string[] cmdparams)
@@ -120,7 +126,7 @@ namespace SimpleApp
{
Program app = new Program();
- app.Run();
+ app.StartUp();
}
}
}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index ec406f1..81e2ea3 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -36,8 +36,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
///
public class BasicPhysicsPlugin : IPhysicsPlugin
{
- private BasicScene _mScene;
-
public BasicPhysicsPlugin()
{
@@ -145,35 +143,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
actor.Position.X = 256;
}
}
- //}
-
-
-
- // This code needs sorting out - border crossings etc
-/* if(actor.Position.X<0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.X = 0;
- actor.Velocity.X = 0;
- }
- if(actor.Position.Y < 0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.Y = 0;
- actor.Velocity.Y = 0;
- }
- if(actor.Position.X > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.X = 255;
- actor.Velocity.X = 0;
- }
- if(actor.Position.Y > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.Y = 255;
- actor.Velocity.X = 0;
- }*/
}
}
--
cgit v1.1