clean up of startup config settings (command line args etc),

Now using the Nini configuration library (suggest we look into using this for the rest of our config handling, as it provides a standard interface for command line args, INI files, Xml files, .NET config files, and windows registry). 
One IMPORTANT change is that to TO START GRIDMODE , you need to now use -gridmode=true .
Also need someone to test it under mono. (there is a dll that has been compiled under mono available, just hoping that we don't have to deal with separate dlls for windows and linux.
afrisby
MW 2007-08-04 18:15:48 +00:00
parent bb60d87538
commit f1e10e555d
6 changed files with 72 additions and 102 deletions

View File

@ -28,6 +28,7 @@
using System;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim
{
@ -52,70 +53,16 @@ namespace OpenSim
Console.WriteLine("Starting...\n");
bool sandBoxMode = true;
bool startLoginServer = true;
string physicsEngine = "basicphysics";
ArgvConfigSource source = new ArgvConfigSource(args);
bool userAccounts = false;
bool gridLocalAsset = false;
bool useConfigFile = false;
bool silent = false;
string configFile = "simconfig.xml";
source.AddSwitch("Startup", "inifile");
source.AddSwitch("Startup", "configfile");
source.AddSwitch("Startup", "gridmode");
source.AddSwitch("Startup", "physics");
source.AddSwitch("Startup", "config");
source.AddSwitch("Startup", "noverbose");
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-gridmode")
{
sandBoxMode = false;
startLoginServer = false;
}
if (args[i] == "-accounts")
{
userAccounts = true;
}
if (args[i] == "-realphysx")
{
physicsEngine = "RealPhysX";
}
if (args[i] == "-bulletX")
{
physicsEngine = "BulletXEngine";
}
if (args[i] == "-ode")
{
physicsEngine = "OpenDynamicsEngine";
}
if (args[i] == "-localasset")
{
gridLocalAsset = true;
}
if (args[i] == "-configfile")
{
useConfigFile = true;
}
if (args[i] == "-noverbose")
{
silent = true;
}
if (args[i] == "-config")
{
try
{
i++;
configFile = args[i];
}
catch (Exception e)
{
Console.WriteLine("-config: Please specify a config file. (" + e.ToString() + ")");
}
}
}
OpenSimMain sim = new OpenSimMain(sandBoxMode, startLoginServer, physicsEngine, useConfigFile, silent, configFile);
sim.user_accounts = userAccounts;
sim.m_gridLocalAsset = gridLocalAsset;
OpenSimMain sim = new OpenSimMain(source);
sim.StartUp();

View File

@ -29,6 +29,7 @@
using System;
using System.IO;
using libsecondlife;
using Nini.Config;
using OpenSim.Assets;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@ -57,7 +58,6 @@ namespace OpenSim
{
public string m_physicsEngine;
public bool m_sandbox;
public bool m_loginserver;
public bool user_accounts;
public bool m_gridLocalAsset;
protected bool m_useConfigFile;
@ -70,17 +70,36 @@ namespace OpenSim
private bool m_silent;
private string m_logFilename = ("region-console-" + Guid.NewGuid().ToString() + ".log");
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngineName, bool useConfigFile, bool silent, string configFileName)
:base( )
public OpenSimMain(IConfigSource configSource)
: base()
{
m_useConfigFile = useConfigFile;
m_sandbox = sandBoxMode;
m_loginserver = startLoginServer;
m_physicsEngine = physicsEngineName;
m_configFileName = configFileName;
m_silent = silent;
IConfigSource startupSource = configSource;
string iniFile = startupSource.Configs["Startup"].GetString("inifile", "NA");
if (iniFile != "NA")
{
//a ini is set to be used for startup settings
string iniFilePath = Path.Combine(Util.configDir(), iniFile);
if (File.Exists(iniFilePath))
{
startupSource = new IniConfigSource(iniFilePath);
//enable follow line, if we want the original config source(normally commandline args) merged with ini file settings.
//in this case we have it so if both sources have the same named setting, command line value will overwrite the ini file value.
//(as if someone has bothered to enter a command line arg, we should take notice of it)
//startupSource.Merge(configSource);
}
}
ReadConfigSettings(startupSource);
}
protected void ReadConfigSettings(IConfigSource configSource)
{
m_useConfigFile = configSource.Configs["Startup"].GetBoolean("configfile", false);
m_sandbox = !configSource.Configs["Startup"].GetBoolean("gridmode", false);
m_physicsEngine = configSource.Configs["Startup"].GetString("physics", "basicphysics");
m_configFileName = configSource.Configs["Startup"].GetString("config", "simconfig.xml");
m_silent = configSource.Configs["Startup"].GetBoolean("noverbose", false);
}
/// <summary>
/// Performs initialisation of the scene, such as loading configuration from disk.
@ -91,7 +110,7 @@ namespace OpenSim
{
Directory.CreateDirectory(Util.logDir());
}
m_log = new LogBase(Path.Combine(Util.logDir(),m_logFilename), "Region", this, m_silent);
m_log = new LogBase(Path.Combine(Util.logDir(), m_logFilename), "Region", this, m_silent);
MainLog.Instance = m_log;
base.StartUp();
@ -103,11 +122,11 @@ namespace OpenSim
if (m_sandbox)
{
m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer, m_assetCache);
m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache);
}
else
{
m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache);
m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache);
}
@ -129,7 +148,7 @@ namespace OpenSim
for (int i = 0; i < configFiles.Length; i++)
{
Console.WriteLine("Loading region config file");
//Console.WriteLine("Loading region config file");
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]);
UDPServer udpServer;
@ -163,7 +182,7 @@ namespace OpenSim
protected override void Initialize()
{
m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(),"network_servers_information.xml"));
m_networkServersInfo = new NetworkServersInfo("NETWORK SERVERS INFO", Path.Combine(Util.configDir(), "network_servers_information.xml"));
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
m_assetCache = new AssetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
}
@ -175,14 +194,14 @@ namespace OpenSim
Directory.CreateDirectory(Util.logDir());
}
return new LogBase((Path.Combine(Util.logDir(),m_logFilename)), "Region", this, m_silent);
return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, m_silent);
}
# region Setup methods
protected override PhysicsScene GetPhysicsScene( )
protected override PhysicsScene GetPhysicsScene()
{
return GetPhysicsScene( m_physicsEngine );
return GetPhysicsScene(m_physicsEngine);
}
private class SimStatusHandler : IStreamHandler

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment
return false;
SceneObject task = (SceneObject)m_scene.Entities[obj];
LLUUID taskOwner = null; // Since we dont have a 'owner' property on task yet
LLUUID taskOwner = task.rootPrimitive.OwnerID;
// Object owners should be able to edit their own content
if (user == taskOwner)

View File

@ -94,16 +94,24 @@ namespace OpenSim.Region.Environment.Scenes
return dupe;
}
/// <summary>
///
/// </summary>
/// <param name="part"></param>
public void CopyRootPart(AllNewSceneObjectPart2 part)
{
AllNewSceneObjectPart2 newPart = part.Copy(m_scene);
AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
this.m_parts.Add(newPart.UUID, newPart);
this.SetPartAsRoot(newPart);
}
/// <summary>
///
/// </summary>
/// <param name="part"></param>
public void CopyPart(AllNewSceneObjectPart2 part)
{
AllNewSceneObjectPart2 newPart = part.Copy(m_scene);
AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
this.m_parts.Add(newPart.UUID, newPart);
this.SetPartAsNonRoot(newPart);
}

View File

@ -27,7 +27,7 @@ namespace OpenSim.Region.Environment.Scenes
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
protected PrimitiveBaseShape m_shape;
protected byte[] m_particleSystem = new byte[0];
protected AllNewSceneObjectGroup2 m_parentGroup;
@ -54,9 +54,6 @@ namespace OpenSim.Region.Environment.Scenes
}
protected string m_name;
/// <summary>
///
/// </summary>
public virtual string Name
{
get { return m_name; }
@ -154,9 +151,9 @@ namespace OpenSim.Region.Environment.Scenes
set { m_touchName = value; }
}
protected PrimitiveBaseShape m_shape;
public PrimitiveBaseShape Shape
{
get { return this.m_shape; }
set { m_shape = value; }
}
@ -245,14 +242,13 @@ namespace OpenSim.Region.Environment.Scenes
///
/// </summary>
/// <returns></returns>
public AllNewSceneObjectPart2 Copy(Scene scene)
public AllNewSceneObjectPart2 Copy(uint localID)
{
AllNewSceneObjectPart2 dupe = (AllNewSceneObjectPart2)this.MemberwiseClone();
dupe.m_shape = m_shape.Copy();
dupe.m_regionHandle = m_regionHandle;
uint newLocalID = scene.PrimIDAllocate();
dupe.UUID = LLUUID.Random();
dupe.LocalID = newLocalID;
dupe.LocalID = localID;
dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z);
dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W);
dupe.Velocity = new LLVector3(0, 0, 0);
@ -303,7 +299,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes
if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
{
SendFullUpdateToAllClients();
ClearUpdateSchedule();

View File

@ -666,7 +666,7 @@
<Reference name="XMLRPC.dll"/>
<Reference name="OpenSim.Framework.UserManagement" />
<Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>