* Massive restructuring of RegionApplicationBase, OpenSimMain and SimpleApp

afrisby
lbsa71 2007-07-16 20:10:54 +00:00
parent 41b9baa054
commit 85bdec5e0d
7 changed files with 113 additions and 139 deletions

View File

@ -43,7 +43,7 @@ namespace OpenSim
bool sandBoxMode = false; bool sandBoxMode = false;
bool startLoginServer = false; bool startLoginServer = false;
string physicsEngine = "basicphysics"; string physicsEngine = "basicphysics";
bool allowFlying = false;
bool userAccounts = false; bool userAccounts = false;
bool gridLocalAsset = false; bool gridLocalAsset = false;
bool useConfigFile = false; bool useConfigFile = false;

View File

@ -78,26 +78,16 @@ namespace OpenSim
m_silent = silent; m_silent = silent;
} }
/// <summary> /// <summary>
/// Performs initialisation of the world, such as loading configuration from disk. /// Performs initialisation of the world, such as loading configuration from disk.
/// </summary> /// </summary>
public void StartUp() public override void StartUp()
{ {
this.m_serversData = new NetworkServersInfo(); base.StartUp();
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;
m_log.Verbose("Main.cs:Startup() - Loading configuration"); 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 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"); ScenePresence.LoadTextureFile("avatar-texture.dat");
@ -106,19 +96,18 @@ namespace OpenSim
this.SetupHttpListener(); this.SetupHttpListener();
m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
m_inventoryCache = new InventoryCache();
if (m_sandbox) if (m_sandbox)
{ {
this.SetupLocalGridServers(); this.commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer);
// this.checkServer = new CheckSumServer(12036);
// this.checkServer.ServerListener();
} }
else else
{ {
this.SetupRemoteGridServers(); this.commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer );
} }
m_startuptime = DateTime.Now;
this.SetupScene(); this.SetupScene();
m_log.Verbose("Main.cs:Startup() - Initialising HTTP server"); m_log.Verbose("Main.cs:Startup() - Initialising HTTP server");
@ -135,44 +124,30 @@ namespace OpenSim
} }
protected override void Initialize()
{
this.localConfig = new XmlConfig(m_config);
this.localConfig.LoadData();
if (this.configFileSetup)
{
this.SetupFromConfigFile(this.localConfig);
}
}
protected override LogBase CreateLog()
{
return new LogBase(m_logFilename, "Region", this, m_silent);
}
# region Setup methods # region Setup methods
protected void SetupLocalGridServers()
{
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)
{
m_log.Error(e.Message + "\nSorry, could not setup local cache");
Environment.Exit(1);
}
}
protected void SetupRemoteGridServers()
{
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);
}
}
protected void SetupScene() protected void SetupScene()
{ {
IGenericConfig regionConfig; IGenericConfig regionConfig;
Scene scene;
UDPServer udpServer; UDPServer udpServer;
RegionInfo regionDat = new RegionInfo(); RegionInfo m_regionInfo = new RegionInfo();
AuthenticateSessionsBase authenBase; AuthenticateSessionsBase authenBase;
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions");
@ -194,7 +169,7 @@ namespace OpenSim
for (int i = 0; i < configFiles.Length; i++) for (int i = 0; i < configFiles.Length; i++)
{ {
regionDat = new RegionInfo(); m_regionInfo = new RegionInfo();
if (m_sandbox) if (m_sandbox)
{ {
AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal(); AuthenticateSessionsBase authen = new AuthenticateSessionsBase(); // new AuthenticateSessionsLocal();
@ -210,17 +185,17 @@ namespace OpenSim
Console.WriteLine("Loading region config file"); Console.WriteLine("Loading region config file");
regionConfig = new XmlConfig(configFiles[i]); regionConfig = new XmlConfig(configFiles[i]);
regionConfig.LoadData(); regionConfig.LoadData();
regionDat.InitConfig(this.m_sandbox, regionConfig); m_regionInfo.InitConfig(this.m_sandbox, regionConfig);
regionConfig.Close(); 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); 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); this.m_localWorld.Add(scene);
udpServer.LocalWorld = scene; udpServer.LocalWorld = scene;
@ -253,12 +228,9 @@ namespace OpenSim
} }
} }
private static PhysicsScene GetPhysicsScene(string physicsEngine) protected override PhysicsScene GetPhysicsScene( )
{ {
PhysicsPluginManager physicsPluginManager; return GetPhysicsScene( m_physicsEngine );
physicsPluginManager = new PhysicsPluginManager();
physicsPluginManager.LoadPlugins();
return physicsPluginManager.GetPhysicsScene( physicsEngine );
} }
private class SimStatusHandler : IStreamHandler private class SimStatusHandler : IStreamHandler
@ -286,7 +258,7 @@ namespace OpenSim
protected void SetupHttpListener() 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) if (!this.m_sandbox)
{ {
@ -372,16 +344,9 @@ namespace OpenSim
switch (attri) switch (attri)
{ {
default: default:
m_log.Warn("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); throw new ArgumentException(String.Format( "Invalid value [{0}] for PhysicsEngine attribute, terminating", attri ) );
Environment.Exit(1);
break;
case "": case "":
this.m_physicsEngine = "basicphysics";
configData.SetAttribute("PhysicsEngine", "basicphysics");
ScenePresence.PhysicsEngineFlying = false;
break;
case "basicphysics": case "basicphysics":
this.m_physicsEngine = "basicphysics"; this.m_physicsEngine = "basicphysics";
configData.SetAttribute("PhysicsEngine", "basicphysics"); configData.SetAttribute("PhysicsEngine", "basicphysics");

View File

@ -37,16 +37,17 @@ using OpenSim.Framework.Types;
using OpenSim.Physics.Manager; using OpenSim.Physics.Manager;
using OpenSim.Region.Caches; using OpenSim.Region.Caches;
using OpenSim.Region.Environment; using OpenSim.Region.Environment;
using libsecondlife;
namespace OpenSim.Region.ClientStack namespace OpenSim.Region.ClientStack
{ {
public class RegionApplicationBase public abstract class RegionApplicationBase
{ {
protected AssetCache m_assetCache; protected AssetCache m_assetCache;
protected InventoryCache m_inventoryCache; protected InventoryCache m_inventoryCache;
protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>(); protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
protected DateTime m_startuptime; protected DateTime m_startuptime;
protected NetworkServersInfo m_serversData; protected NetworkServersInfo m_networkServersInfo;
protected List<UDPServer> m_udpServer = new List<UDPServer>(); protected List<UDPServer> m_udpServer = new List<UDPServer>();
protected List<RegionInfo> m_regionData = new List<RegionInfo>(); protected List<RegionInfo> m_regionData = new List<RegionInfo>();
@ -58,7 +59,40 @@ namespace OpenSim.Region.ClientStack
public RegionApplicationBase( ) 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 );
}
} }
} }
}

View File

@ -8,7 +8,7 @@ using OpenSim.Region.Environment.LandManagement;
namespace OpenSim.Region.Environment namespace OpenSim.Region.Environment
{ {
public class RegionManager //needs renaming , but first we need to rename the namespace public class RegionManager
{ {
protected AuthenticateSessionsBase authenticateHandler; protected AuthenticateSessionsBase authenticateHandler;
protected RegionCommsListener regionCommsHost; protected RegionCommsListener regionCommsHost;

View File

@ -19,25 +19,29 @@ using OpenSim.Framework.Data;
namespace SimpleApp namespace SimpleApp
{ {
class Program : conscmd_callback class Program : RegionApplicationBase, conscmd_callback
{ {
private LogBase m_log;
AuthenticateSessionsBase m_circuitManager; AuthenticateSessionsBase m_circuitManager;
uint m_localId;
public MyWorld world; public MyWorld m_world;
private SceneObject m_sceneObject; private SceneObject m_sceneObject;
public MyNpcCharacter m_character; public MyNpcCharacter m_character;
private void Run() protected override LogBase CreateLog()
{ {
m_log = new LogBase(null, "SimpleApp", this, false); return new LogBase(null, "SimpleApp", this, false);
}
protected override void Initialize()
{
}
public void Run()
{
base.StartUp();
MainLog.Instance = m_log; MainLog.Instance = m_log;
// CheckSumServer checksumServer = new CheckSumServer(12036);
// checksumServer.ServerListener();
IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
m_circuitManager = new AuthenticateSessionsBase(); m_circuitManager = new AuthenticateSessionsBase();
InventoryCache inventoryCache = new InventoryCache(); InventoryCache inventoryCache = new InventoryCache();
@ -50,30 +54,27 @@ namespace SimpleApp
ScenePresence.LoadTextureFile("avatar-texture.dat"); ScenePresence.LoadTextureFile("avatar-texture.dat");
ScenePresence.PhysicsEngineFlying = true; ScenePresence.PhysicsEngineFlying = true;
PhysicsPluginManager physManager = new PhysicsPluginManager(); IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
physManager.LoadPlugins();
UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager); UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
PacketServer packetServer = new PacketServer(udpServer); PacketServer packetServer = new PacketServer(udpServer);
ClientView.TerrainManager = new TerrainManager(new SecondLife());
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port); BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
NetworkServersInfo serverInfo = new NetworkServersInfo(); CommunicationsLocal communicationsManager = new CommunicationsLocal(m_networkServersInfo, httpServer);
CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1"); 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"); 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); m_world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; m_world.PhysScene = GetPhysicsScene( );
world.LoadWorldMap(); m_world.LoadWorldMap();
world.PhysScene.SetTerrain(world.Terrain.getHeights1D()); m_world.PhysScene.SetTerrain(m_world.Terrain.getHeights1D());
world.performParcelPrimCountUpdate(); m_world.performParcelPrimCountUpdate();
udpServer.LocalWorld = world; udpServer.LocalWorld = m_world;
httpServer.Start(); httpServer.Start();
udpServer.ServerListener(); udpServer.ServerListener();
@ -81,27 +82,32 @@ namespace SimpleApp
UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test"); UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
if (masterAvatar != null) if (masterAvatar != null)
{ {
world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID; m_world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
world.LandManager.NoLandDataFromStorage(); m_world.LandManager.NoLandDataFromStorage();
} }
world.StartTimer(); m_world.StartTimer();
PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
LLVector3 pos = new LLVector3(138, 129, 27); LLVector3 pos = new LLVector3(138, 129, 27);
m_sceneObject = new MySceneObject(world, world.EventManager, LLUUID.Zero, world.PrimIDAllocate(), pos, shape); m_sceneObject = new MySceneObject(m_world, m_world.EventManager, LLUUID.Zero, m_world.PrimIDAllocate(), pos, shape);
world.AddEntity(m_sceneObject); m_world.AddEntity(m_sceneObject);
m_character = new MyNpcCharacter(); 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.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
m_log.ReadLine(); m_log.ReadLine();
} }
protected override PhysicsScene GetPhysicsScene( )
{
return GetPhysicsScene("basicphysics");
}
#region conscmd_callback Members #region conscmd_callback Members
public void RunCmd(string cmd, string[] cmdparams) public void RunCmd(string cmd, string[] cmdparams)
@ -120,7 +126,7 @@ namespace SimpleApp
{ {
Program app = new Program(); Program app = new Program();
app.Run(); app.StartUp();
} }
} }
} }

View File

@ -36,8 +36,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
/// </summary> /// </summary>
public class BasicPhysicsPlugin : IPhysicsPlugin public class BasicPhysicsPlugin : IPhysicsPlugin
{ {
private BasicScene _mScene;
public BasicPhysicsPlugin() public BasicPhysicsPlugin()
{ {
@ -145,35 +143,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
actor.Position.X = 256; 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;
}*/
} }
} }