* Cleanup and CCC (Code Convention Conformance)

0.6.5-rc1
lbsa71 2009-03-10 20:06:25 +00:00
parent a8ae02df4f
commit 63a5a01945
2 changed files with 266 additions and 216 deletions

View File

@ -38,7 +38,6 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
using OpenSim.Region.CoreModules.Scripting.DynamicTexture; using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.CoreModules.Scripting.LoadImageURL; using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
using OpenSim.Region.CoreModules.Scripting.XMLRPC; using OpenSim.Region.CoreModules.Scripting.XMLRPC;
using OpenSim.Framework.Servers;
namespace OpenSim.ApplicationPlugins.LoadRegions namespace OpenSim.ApplicationPlugins.LoadRegions
{ {
@ -52,11 +51,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
#region IApplicationPlugin Members #region IApplicationPlugin Members
// TODO: required by IPlugin, but likely not at all right // TODO: required by IPlugin, but likely not at all right
string m_name = "LoadRegionsPlugin"; private string m_name = "LoadRegionsPlugin";
string m_version = "0.0"; private string m_version = "0.0";
public string Version { get { return m_version; } } public string Version
public string Name { get { return m_name; } } {
get { return m_version; }
}
public string Name
{
get { return m_name; }
}
protected OpenSimBase m_openSim; protected OpenSimBase m_openSim;
@ -106,7 +112,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
for (int i = 0; i < regionsToLoad.Length; i++) for (int i = 0; i < regionsToLoad.Length; i++)
{ {
IScene scene; IScene scene;
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
Thread.CurrentThread.ManagedThreadId.ToString() +
")"); ")");
m_openSim.CreateRegion(regionsToLoad[i], true, out scene); m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
if (scene != null) if (scene != null)
@ -155,7 +162,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
region.RegionName, checkedRegion.RegionName, region.RegionID); region.RegionName, checkedRegion.RegionName, region.RegionID);
return false; return false;
} }
else if (region.RegionLocX == checkedRegion.RegionLocX && region.RegionLocY == checkedRegion.RegionLocY) else if (region.RegionLocX == checkedRegion.RegionLocX &&
region.RegionLocY == checkedRegion.RegionLocY)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same location {2} {3}", "[LOADREGIONS]: Regions {0} and {1} have the same location {2} {3}",

View File

@ -55,11 +55,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
private string requiredPassword = String.Empty; private string requiredPassword = String.Empty;
// TODO: required by IPlugin, but likely not at all right // TODO: required by IPlugin, but likely not at all right
string m_name = "RemoteAdminPlugin"; private string m_name = "RemoteAdminPlugin";
string m_version = "0.0"; private string m_version = "0.0";
public string Version { get { return m_version; } } public string Version
public string Name { get { return m_name; } } {
get { return m_version; }
}
public string Name
{
get { return m_name; }
}
public void Initialise() public void Initialise()
{ {
@ -140,7 +147,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
try { try
{
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
m_log.Info("[RADMIN]: Request to restart Region."); m_log.Info("[RADMIN]: Request to restart Region.");
@ -230,7 +238,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
try { try
{
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString()); m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString());
@ -283,7 +292,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
XmlRpcResponse response = new XmlRpcResponse(); XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
try { try
{
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
if (requiredPassword != String.Empty && if (requiredPassword != String.Empty &&
@ -427,14 +437,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{ {
int m_regionLimit = m_config.GetInt("region_limit", 0); int m_regionLimit = m_config.GetInt("region_limit", 0);
try { try
{
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
checkStringParameters(request, new string[] { "password", checkStringParameters(request, new string[]
{
"password",
"region_name", "region_name",
"region_master_first", "region_master_last", "region_master_first", "region_master_last",
"region_master_password", "region_master_password",
"listen_ip", "external_address"}); "listen_ip", "external_address"
});
checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"});
// check password // check password
@ -454,7 +468,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{ {
regionID = (UUID) (string) requestData["region_id"]; regionID = (UUID) (string) requestData["region_id"];
if (m_app.SceneManager.TryGetScene(regionID, out scene)) if (m_app.SceneManager.TryGetScene(regionID, out scene))
throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", throw new Exception(
String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
} }
@ -475,12 +490,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// check for collisions: region name, region UUID, // check for collisions: region name, region UUID,
// region location // region location
if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) if (m_app.SceneManager.TryGetScene(region.RegionName, out scene))
throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", throw new Exception(
String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>",
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene))
throw new Exception(String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", throw new Exception(
String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>",
region.RegionLocX, region.RegionLocY, region.RegionLocX, region.RegionLocY,
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
@ -491,7 +508,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]);
if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0");
if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene))
throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", throw new Exception(
String.Format(
"region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
region.InternalEndPoint.Address, region.InternalEndPoint.Address,
region.InternalEndPoint.Port, region.InternalEndPoint.Port,
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
@ -522,7 +541,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
userID = m_app.CommunicationsManager.UserAdminService.AddUser( userID = m_app.CommunicationsManager.UserAdminService.AddUser(
masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY);
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", if (userID == UUID.Zero)
throw new Exception(String.Format("failed to create new user {0} {1}",
masterFirst, masterLast)); masterFirst, masterLast));
} }
else else
@ -553,12 +573,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController
// No INI setting recorded. // No INI setting recorded.
} }
string regionXmlPath = Path.Combine(regionConfigPath, string regionXmlPath = Path.Combine(regionConfigPath,
String.Format(m_config.GetString("region_file_template", "{0}x{1}-{2}.xml"), String.Format(
m_config.GetString("region_file_template",
"{0}x{1}-{2}.xml"),
region.RegionLocX.ToString(), region.RegionLocX.ToString(),
region.RegionLocY.ToString(), region.RegionLocY.ToString(),
regionID.ToString(), regionID.ToString(),
region.InternalEndPoint.Port.ToString(), region.InternalEndPoint.Port.ToString(),
region.RegionName.Replace(" ", "_").Replace(":", "_").Replace("/", "_"))); region.RegionName.Replace(" ", "_").Replace(":", "_").
Replace("/", "_")));
m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
region.RegionID, regionXmlPath); region.RegionID, regionXmlPath);
region.SaveRegionToFile("dynamic region", regionXmlPath); region.SaveRegionToFile("dynamic region", regionXmlPath);
@ -620,7 +643,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
lock (this) lock (this)
{ {
try { try
{
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
checkStringParameters(request, new string[] {"password", "region_name"}); checkStringParameters(request, new string[] {"password", "region_name"});
@ -648,7 +672,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
return response; return response;
} }
} }
@ -701,8 +724,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
// check completeness // check completeness
checkStringParameters(request, new string[] { "password", "user_firstname", checkStringParameters(request, new string[]
"user_lastname", "user_password", }); {
"password", "user_firstname",
"user_lastname", "user_password",
});
checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"}); checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"});
// check password // check password
@ -724,7 +750,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
UUID userID = m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname, UUID userID = m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname,
passwd, email, regX, regY); passwd, email, regX, regY);
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", if (userID == UUID.Zero)
throw new Exception(String.Format("failed to create new user {0} {1}",
firstname, lastname)); firstname, lastname));
responseData["success"] = "true"; responseData["success"] = "true";
@ -746,7 +773,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
response.Value = responseData; response.Value = responseData;
} }
return response; return response;
} }
} }
@ -801,8 +827,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
// check completeness // check completeness
checkStringParameters(request, new string[] { "password", "user_firstname", checkStringParameters(request, new string[]
"user_lastname", "user_password", "user_email" }); {
"password", "user_firstname",
"user_lastname", "user_password", "user_email"
});
checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"}); checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"});
// check password // check password
@ -817,7 +846,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); UserProfileData userProfile =
m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
if (null != userProfile) if (null != userProfile)
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
@ -825,7 +855,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
= m_app.CommunicationsManager.UserAdminService.AddUser( = m_app.CommunicationsManager.UserAdminService.AddUser(
firstname, lastname, passwd, email, regX, regY); firstname, lastname, passwd, email, regX, regY);
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", if (userID == UUID.Zero)
throw new Exception(String.Format("failed to create new user {0} {1}",
firstname, lastname)); firstname, lastname));
responseData["success"] = "true"; responseData["success"] = "true";
@ -847,7 +878,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
response.Value = responseData; response.Value = responseData;
} }
return response; return response;
} }
} }
@ -970,8 +1000,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
Hashtable requestData = (Hashtable) request.Params[0]; Hashtable requestData = (Hashtable) request.Params[0];
// check completeness // check completeness
checkStringParameters(request, new string[] { "password", "user_firstname", checkStringParameters(request, new string[]
"user_lastname" }); {
"password", "user_firstname",
"user_lastname"
});
// check password // check password
if (!String.IsNullOrEmpty(requiredPassword) && if (!String.IsNullOrEmpty(requiredPassword) &&
@ -994,16 +1027,24 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); if (requestData.ContainsKey("start_region_x"))
if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
if (requestData.ContainsKey("start_region_y"))
regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
if (requestData.ContainsKey("start_lookat_x")) ulaX = Convert.ToUInt32((Int32)requestData["start_lookat_x"]); if (requestData.ContainsKey("start_lookat_x"))
if (requestData.ContainsKey("start_lookat_y")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_y"]); ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
if (requestData.ContainsKey("start_lookat_z")) ulaZ = Convert.ToUInt32((Int32)requestData["start_lookat_z"]); if (requestData.ContainsKey("start_lookat_y"))
ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]);
if (requestData.ContainsKey("start_lookat_z"))
ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]);
if (requestData.ContainsKey("start_standat_x")) usaX = Convert.ToUInt32((Int32)requestData["start_standat_x"]); if (requestData.ContainsKey("start_standat_x"))
if (requestData.ContainsKey("start_standat_y")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_y"]); usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]);
if (requestData.ContainsKey("start_standat_z")) usaZ = Convert.ToUInt32((Int32)requestData["start_standat_z"]); if (requestData.ContainsKey("start_standat_y"))
usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]);
if (requestData.ContainsKey("start_standat_z"))
usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]);
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
@ -1034,7 +1075,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
response.Value = responseData; response.Value = responseData;
m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname, m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
firstname, lastname,
userProfile.ID); userProfile.ID);
} }
catch (Exception e) catch (Exception e)