Formatting cleanup, minor refactoring. Fixed some comparisons of value types and null.

0.6.0-stable
Jeff Ames 2008-05-18 23:06:50 +00:00
parent 901e97f821
commit 6ec680918b
14 changed files with 93 additions and 122 deletions

View File

@ -38,7 +38,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
/* This module doesn't check for changes, since it's *assumed* there are none.
* Nevertheless, it's possible to have changes, since all the fields are public.
* There's no event to subscribe to. :/
*
*
* I don't think anything changes the fields beyond RegionModule PostInit, however.
*/
private Scene m_scene = null;

View File

@ -23,7 +23,6 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;

View File

@ -23,7 +23,6 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
@ -53,9 +52,9 @@ namespace OpenSim.Region.DataSnapshot.Providers
/*
* David, I don't think we need this at all. When we do the snapshot, we can
* simply look into the parcels that are marked for ShowDirectory -- see
* simply look into the parcels that are marked for ShowDirectory -- see
* conditional in RequestSnapshotData
*
*
//Revise this, look for more direct way of checking for change in land
#region Client hooks
@ -119,7 +118,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
}
public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
{
{
ILandChannel landChannel = (LandChannel)m_scene.LandChannel;
Dictionary<int, ILandObject> landList = null;
try

View File

@ -79,7 +79,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
client.OnObjectPermissions += delegate(IClientAPI controller, LLUUID agentID, LLUUID sessionID,
byte field, uint localId, uint mask, byte set) { this.Stale = true; };
client.OnRezObject += delegate(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd,
LLVector3 RayStart, LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
LLVector3 RayStart, LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, bool RezSelected,
bool RemoveItem, LLUUID fromTaskID) { this.Stale = true; };
}
@ -99,7 +99,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
foreach (EntityBase entity in m_scene.Entities.Values)
{
// only objects, not avatars
if (entity is SceneObjectGroup)
if (entity is SceneObjectGroup)
{
SceneObjectGroup obj = (SceneObjectGroup)entity;
@ -135,7 +135,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
node.InnerText = m_rootPart.Description;
xmlobject.AppendChild(node);
node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags);
xmlobject.AppendChild(node);

View File

@ -23,7 +23,6 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;

View File

@ -33,7 +33,7 @@ namespace OpenSim.Region.Environment.Interfaces
{
public delegate void ObjectPaid(LLUUID objectID, LLUUID agentID, int amount);
public interface IMoneyModule : IRegionModule
{
{
bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID,
int amount);

View File

@ -2658,7 +2658,7 @@ namespace OpenSim.Region.Environment.Scenes
ClientManager.ForEachClient(delegate(IClientAPI controller)
{
ScenePresence p = GetScenePresence(controller.AgentId);
bool childagent = !p.Equals(null) && p.IsChildAgent;
bool childagent = p != null && p.IsChildAgent;
if (controller.AgentId != godID && !childagent)
// Do we really want to kick the initiator of this madness?
{
@ -2669,14 +2669,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
if (m_scenePresences[agentID].IsChildAgent)
{
m_innerScene.removeUserCount(false);
}
else
{
m_innerScene.removeUserCount(true);
}
m_innerScene.removeUserCount(!m_scenePresences[agentID].IsChildAgent);
m_scenePresences[agentID].ControllingClient.Kick(Helpers.FieldToUTF8String(reason));
m_scenePresences[agentID].ControllingClient.Close(true);
@ -2696,7 +2689,6 @@ namespace OpenSim.Region.Environment.Scenes
// Check for spoofing.. since this is permissions we're talking about here!
if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
{
// Tell the object to do permission update
if (localId != 0)
{
@ -2706,7 +2698,6 @@ namespace OpenSim.Region.Environment.Scenes
chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
}
}
}
}
@ -3126,8 +3117,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="action"></param>
public void ForEachScenePresence(Action<ScenePresence> action)
{
// We don't want to try to send messages if there are no avatar.
if (!(m_scenePresences.Equals(null)))
// We don't want to try to send messages if there are no avatars.
if (m_scenePresences != null)
{
try
{

View File

@ -140,7 +140,7 @@ namespace OpenSim.Region.Environment.Scenes
Result = m_localScenes[i].RegionInfo;
}
}
if (!(Result.Equals(null)))
if (Result != null)
{
for (int i = 0; i < m_localScenes.Count; i++)
{

View File

@ -497,26 +497,26 @@ namespace OpenSim.Region.Environment.Scenes
{
foreach (TaskInventoryItem item in m_taskInventory.Values)
{
LLUUID ownerID=item.OwnerID;
uint everyoneMask=0;
uint baseMask=item.BaseMask;
uint ownerMask=item.OwnerMask;
LLUUID ownerID = item.OwnerID;
uint everyoneMask = 0;
uint baseMask = item.BaseMask;
uint ownerMask = item.OwnerMask;
if(item.InvType == 10) // Script
if (item.InvType == 10) // Script
{
if((item.OwnerID != client.AgentId) && m_parentGroup.Scene.ExternalChecks.ExternalChecksCanViewScript(item.ItemID, UUID, client.AgentId))
if ((item.OwnerID != client.AgentId) && m_parentGroup.Scene.ExternalChecks.ExternalChecksCanViewScript(item.ItemID, UUID, client.AgentId))
{
ownerID=client.AgentId;
baseMask=0x7fffffff;
ownerMask=0x7fffffff;
everyoneMask=(uint)(PermissionMask.Move | PermissionMask.Transfer);
ownerID = client.AgentId;
baseMask = 0x7fffffff;
ownerMask = 0x7fffffff;
everyoneMask = (uint)(PermissionMask.Move | PermissionMask.Transfer);
}
if((item.OwnerID != client.AgentId) && m_parentGroup.Scene.ExternalChecks.ExternalChecksCanEditScript(item.ItemID, UUID, client.AgentId))
if ((item.OwnerID != client.AgentId) && m_parentGroup.Scene.ExternalChecks.ExternalChecksCanEditScript(item.ItemID, UUID, client.AgentId))
{
ownerID=client.AgentId;
baseMask=0x7fffffff;
ownerMask=0x7fffffff;
everyoneMask=(uint)(PermissionMask.Move | PermissionMask.Transfer | PermissionMask.Modify);
ownerID = client.AgentId;
baseMask = 0x7fffffff;
ownerMask = 0x7fffffff;
everyoneMask = (uint)(PermissionMask.Move | PermissionMask.Transfer | PermissionMask.Modify);
}
}

View File

@ -1469,7 +1469,7 @@ namespace OpenSim.Region.Environment.Scenes
public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
{
m_log.Info("[APPEARANCE] Setting wearable with client, wearableid, wearable");
m_log.Info("[APPEARANCE] Setting wearable with client, wearableid, wearable");
m_appearance.SetWearable(wearableId, wearable);
m_scene.CommsManager.UserService.UpdateUserAppearance(client.AgentId, m_appearance);
client.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
@ -1524,7 +1524,7 @@ namespace OpenSim.Region.Environment.Scenes
public void SetWearable(int wearableId, AvatarWearable wearable)
{
m_log.Warn("[APPEARANCE] Setting Wearable");
m_log.Warn("[APPEARANCE] Setting Wearable");
m_appearance.SetWearable(wearableId, wearable);
m_scene.CommsManager.UserService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance);
}

View File

@ -297,7 +297,7 @@ namespace OpenSim.Region.Modules.AvatarFactory
else
{
LLUUID assetId;
InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
if (baseItem != null)
@ -306,7 +306,7 @@ namespace OpenSim.Region.Modules.AvatarFactory
avatAppearance.Wearables[wear.Type].AssetID = assetId;
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
}
else
else
{
m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, not wearing", wear.ItemID);
}
@ -314,8 +314,8 @@ namespace OpenSim.Region.Modules.AvatarFactory
}
}
m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance);
}
else
}
else
{
m_log.Error("Root Profile is null, we can't set the appearance");
}

View File

@ -144,9 +144,9 @@ namespace OpenSim.Region.Physics.OdePlugin
//private int m_returncollisions = 10;
private IntPtr contactgroup;
private IntPtr LandGeom = (IntPtr) 0;
private IntPtr LandGeom;
private IntPtr WaterGeom = (IntPtr)0;
private IntPtr WaterGeom;
private float nmTerrainContactFriction = 255.0f;
private float nmTerrainContactBounce = 0.1f;
@ -430,7 +430,7 @@ namespace OpenSim.Region.Physics.OdePlugin
internal void waitForSpaceUnlock(IntPtr space)
{
//if (space != (IntPtr)0)
//if (space != IntPtr.Zero)
//while (d.SpaceLockQuery(space)) { } // Wait and do nothing
}
@ -461,7 +461,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
{
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
return;
// Separating static prim geometry spaces.
// We'll be calling near recursivly if one
@ -484,7 +484,7 @@ namespace OpenSim.Region.Physics.OdePlugin
return;
}
if (g1 == (IntPtr)0 || g2 == (IntPtr)0)
if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
return;
IntPtr b1 = d.GeomGetBody(g1);
@ -1037,10 +1037,14 @@ namespace OpenSim.Region.Physics.OdePlugin
{
lock (chr)
{
if (space != (IntPtr)0 && chr.prim_geom != (IntPtr)0 && chr.m_taintremove == false)
if (space != IntPtr.Zero && chr.prim_geom != IntPtr.Zero && chr.m_taintremove == false)
{
d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
}
else
{
m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed");
}
}
}
catch (AccessViolationException)
@ -1204,7 +1208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
remCollisionEventReporting(prim);
lock (ode)
{
if (prim.prim_geom != (IntPtr)0)
if (prim.prim_geom != IntPtr.Zero)
{
prim.ResetTaints();
@ -1217,7 +1221,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// If the geometry is in the targetspace, remove it from the target space
//m_log.Warn(prim.m_targetSpace);
//if (prim.m_targetSpace != (IntPtr)0)
//if (prim.m_targetSpace != IntPtr.Zero)
//{
//if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
//{
@ -1226,7 +1230,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//{
//waitForSpaceUnlock(prim.m_targetSpace);
//d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
prim.m_targetSpace = (IntPtr)0;
prim.m_targetSpace = IntPtr.Zero;
//}
//else
//{
@ -1239,10 +1243,10 @@ namespace OpenSim.Region.Physics.OdePlugin
//m_log.Warn(prim.prim_geom);
try
{
if (prim.prim_geom != (IntPtr)0)
if (prim.prim_geom != IntPtr.Zero)
{
d.GeomDestroy(prim.prim_geom);
prim.prim_geom = (IntPtr)0;
prim.prim_geom = IntPtr.Zero;
}
else
{
@ -1258,7 +1262,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//If there are no more geometries in the sub-space, we don't need it in the main space anymore
//if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
//{
//if (!(prim.m_targetSpace.Equals(null)))
//if (prim.m_targetSpace != null)
//{
//if (d.GeomIsSpace(prim.m_targetSpace))
//{
@ -1327,11 +1331,11 @@ namespace OpenSim.Region.Physics.OdePlugin
if (currentspace != space)
{
//m_log.Info("[SPACE]: C:" + currentspace.ToString() + " g:" + geom.ToString());
//if (currentspace == (IntPtr) 0)
//if (currentspace == IntPtr.Zero)
//{
//int adfadf = 0;
//}
if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr) 0)
if (d.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero)
{
if (d.GeomIsSpace(currentspace))
{
@ -1347,20 +1351,17 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
IntPtr sGeomIsIn = d.GeomGetSpace(geom);
if (!(sGeomIsIn.Equals(null)))
if (sGeomIsIn != IntPtr.Zero)
{
if (sGeomIsIn != (IntPtr) 0)
if (d.GeomIsSpace(currentspace))
{
if (d.GeomIsSpace(currentspace))
{
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
{
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn.ToString() + " Geom:" + geom.ToString());
}
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
{
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn.ToString() + " Geom:" + geom.ToString());
}
}
}
@ -1368,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//If there are no more geometries in the sub-space, we don't need it in the main space anymore
if (d.SpaceGetNumGeoms(currentspace) == 0)
{
if (currentspace != (IntPtr) 0)
if (currentspace != IntPtr.Zero)
{
if (d.GeomIsSpace(currentspace))
{
@ -1391,7 +1392,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
// this is a physical object that got disabled. ;.;
if (currentspace != (IntPtr)0 && geom != (IntPtr)0)
if (currentspace != IntPtr.Zero && geom != IntPtr.Zero)
{
if (d.SpaceQuery(currentspace, geom))
{
@ -1409,20 +1410,17 @@ namespace OpenSim.Region.Physics.OdePlugin
else
{
IntPtr sGeomIsIn = d.GeomGetSpace(geom);
if (!(sGeomIsIn.Equals(null)))
if (sGeomIsIn != IntPtr.Zero)
{
if (sGeomIsIn != (IntPtr)0)
if (d.GeomIsSpace(sGeomIsIn))
{
if (d.GeomIsSpace(sGeomIsIn))
{
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
{
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn.ToString() + " Geom:" + geom.ToString());
}
waitForSpaceUnlock(sGeomIsIn);
d.SpaceRemove(sGeomIsIn, geom);
}
else
{
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn.ToString() + " Geom:" + geom.ToString());
}
}
}
@ -1461,20 +1459,15 @@ namespace OpenSim.Region.Physics.OdePlugin
}
/// <summary>
/// Calculates the space the prim should be in by it's position
/// Calculates the space the prim should be in by its position
/// </summary>
/// <param name="pos"></param>
/// <returns>a pointer to the space. This could be a new space or reused space.</returns>
public IntPtr calculateSpaceForGeom(PhysicsVector pos)
{
IntPtr locationbasedspace =IntPtr.Zero;
int[] xyspace = calculateSpaceArrayItemFromPos(pos);
//m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]];
//locationbasedspace = space;
return locationbasedspace;
int[] xyspace = calculateSpaceArrayItemFromPos(pos);
//m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
return staticPrimspace[xyspace[0], xyspace[1]];
}
/// <summary>
@ -2050,7 +2043,7 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (OdeLock)
{
if (!(LandGeom == (IntPtr) 0))
if (LandGeom != IntPtr.Zero)
{
d.SpaceRemove(space, LandGeom);
}
@ -2060,7 +2053,7 @@ namespace OpenSim.Region.Physics.OdePlugin
offset, thickness, wrap);
d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
if (LandGeom != (IntPtr)0)
if (LandGeom != IntPtr.Zero)
{
d.GeomSetCategoryBits(LandGeom, (int)(CollisionCategories.Land));
d.GeomSetCollideBits(LandGeom, (int)(CollisionCategories.Space));
@ -2115,7 +2108,7 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (OdeLock)
{
if (!(WaterGeom == (IntPtr)0))
if (WaterGeom != IntPtr.Zero)
{
d.SpaceRemove(space, WaterGeom);
}
@ -2125,7 +2118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
offset, thickness, wrap);
d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
WaterGeom = d.CreateHeightfield(space, HeightmapData, 1);
if (WaterGeom != (IntPtr)0)
if (WaterGeom != IntPtr.Zero)
{
d.GeomSetCategoryBits(WaterGeom, (int)(CollisionCategories.Water));
d.GeomSetCollideBits(WaterGeom, (int)(CollisionCategories.Space));

View File

@ -39,13 +39,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
//private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
private Dictionary<string, string> quotes = new Dictionary<string, string>();
// c Style
// c Style
private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline);
// c# one liners
// c# one liners
private Regex conelinecomments = new Regex(@".?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline);
// ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"])
// value we're looking for: (?:[a-zA-Z])\.[a-zA-Z]
public LSL2CSConverter()
@ -89,16 +87,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
bool last_was_escape = false;
int quote_replaced_count = 0;
string removecomments = conelinecomments.Replace(Script, "");
removecomments = cstylecomments.Replace(removecomments, "");
string[] localscript = removecomments.Split('"');
string checkscript = String.Empty;
bool flip = true;
for (int p = 0; p < localscript.Length; p++)
{
if (localscript[p].Length >= 1)
@ -115,7 +109,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
if (!flip)
checkscript += "\"" + localscript[p];
}
//System.Console.WriteLine("SCRIPT:" + checkscript);
// checks for alpha.alpha way of referring to objects in C#
@ -132,9 +126,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
if (SecurityM.Success)
throw new Exception("CS0103: 'The object.GetType method isn't allowed in LSL'");
for (int p = 0; p < Script.Length; p++)
{
C = Script.Substring(p, 1);

View File

@ -45,27 +45,25 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
ChannelServices.RegisterChannel(chan, true);
}
/// <summary>
/// Create a channel for communicating w/ the remote object
/// Notice no port is specified on the client
/// </summary>
public ScriptServerInterfaces.ServerRemotingObject Connect(string hostname, int port)
{
// Create a channel for communicating w/ the remote object
// Notice no port is specified on the client
ScriptServerInterfaces.ServerRemotingObject obj = null;
try
{
// Create an instance of the remote object
ScriptServerInterfaces.ServerRemotingObject obj = (ScriptServerInterfaces.ServerRemotingObject)Activator.GetObject(
obj = (ScriptServerInterfaces.ServerRemotingObject)Activator.GetObject(
typeof(ScriptServerInterfaces.ServerRemotingObject),
"tcp://" + hostname + ":" + port + "/DotNetEngine");
// Use the object
if (obj.Equals(null))
if (obj == null)
{
Console.WriteLine("Error: unable to locate server");
}
else
{
return obj;
}
}
catch (SocketException)
{
@ -75,7 +73,8 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
{
Console.WriteLine("Error: unable to connect to server");
}
return null;
return obj;
}
}
}