Removing unnecessary null checks on structs in AgentsData pack/unpack.

0.6.2-post-fixes
diva 2008-12-30 23:53:51 +00:00
parent e4c7bdc730
commit f08f11fe60
1 changed files with 20 additions and 42 deletions

View File

@ -150,25 +150,15 @@ namespace OpenSim.Framework
OSDMap args = new OSDMap(); OSDMap args = new OSDMap();
args["region_handle"] = OSD.FromString(RegionHandle.ToString()); args["region_handle"] = OSD.FromString(RegionHandle.ToString());
args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
if (AgentID != null)
args["agent_uuid"] = OSD.FromUUID(AgentID); args["agent_uuid"] = OSD.FromUUID(AgentID);
if (SessionID != null)
args["session_uuid"] = OSD.FromUUID(SessionID); args["session_uuid"] = OSD.FromUUID(SessionID);
if (Position != null)
args["position"] = OSD.FromString(Position.ToString()); args["position"] = OSD.FromString(Position.ToString());
if (Velocity != null)
args["velocity"] = OSD.FromString(Velocity.ToString()); args["velocity"] = OSD.FromString(Velocity.ToString());
if (Center != null)
args["center"] = OSD.FromString(Center.ToString()); args["center"] = OSD.FromString(Center.ToString());
if (Size != null)
args["size"] = OSD.FromString(Size.ToString()); args["size"] = OSD.FromString(Size.ToString());
if (AtAxis != null)
args["at_axis"] = OSD.FromString(AtAxis.ToString()); args["at_axis"] = OSD.FromString(AtAxis.ToString());
if (LeftAxis != null)
args["left_axis"] = OSD.FromString(LeftAxis.ToString()); args["left_axis"] = OSD.FromString(LeftAxis.ToString());
if (UpAxis != null)
args["up_axis"] = OSD.FromString(UpAxis.ToString()); args["up_axis"] = OSD.FromString(UpAxis.ToString());
args["changed_grid"] = OSD.FromBoolean(ChangedGrid); args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
@ -179,16 +169,13 @@ namespace OpenSim.Framework
args["throttles"] = OSD.FromBinary(Throttles); args["throttles"] = OSD.FromBinary(Throttles);
args["locomotion_state"] = OSD.FromString(LocomotionState.ToString()); args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
if (HeadRotation != null)
args["head_rotation"] = OSD.FromString(HeadRotation.ToString()); args["head_rotation"] = OSD.FromString(HeadRotation.ToString());
if (BodyRotation != null)
args["body_rotation"] = OSD.FromString(BodyRotation.ToString()); args["body_rotation"] = OSD.FromString(BodyRotation.ToString());
args["control_flags"] = OSD.FromString(ControlFlags.ToString()); args["control_flags"] = OSD.FromString(ControlFlags.ToString());
args["energy_level"] = OSD.FromReal(EnergyLevel); args["energy_level"] = OSD.FromReal(EnergyLevel);
args["god_level"] = OSD.FromString(GodLevel.ToString()); args["god_level"] = OSD.FromString(GodLevel.ToString());
args["always_run"] = OSD.FromBoolean(AlwaysRun); args["always_run"] = OSD.FromBoolean(AlwaysRun);
if (PreyAgent != null)
args["prey_agent"] = OSD.FromUUID(PreyAgent); args["prey_agent"] = OSD.FromUUID(PreyAgent);
args["agent_access"] = OSD.FromString(AgentAccess.ToString()); args["agent_access"] = OSD.FromString(AgentAccess.ToString());
@ -200,7 +187,6 @@ namespace OpenSim.Framework
args["agent_textures"] = textures; args["agent_textures"] = textures;
} }
if (ActiveGroupID != null)
args["active_group_id"] = OSD.FromUUID(ActiveGroupID); args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
// Last few fields are still missing // Last few fields are still missing
@ -315,10 +301,8 @@ namespace OpenSim.Framework
/// <param name="cAgent"></param> /// <param name="cAgent"></param>
public void CopyFrom(ChildAgentDataUpdate cAgent) public void CopyFrom(ChildAgentDataUpdate cAgent)
{ {
if (cAgent.ActiveGroupID != null)
ActiveGroupID = new UUID(cAgent.ActiveGroupID); ActiveGroupID = new UUID(cAgent.ActiveGroupID);
if (cAgent.AgentID != null)
AgentID = new UUID(cAgent.AgentID); AgentID = new UUID(cAgent.AgentID);
AlwaysRun = cAgent.alwaysrun; AlwaysRun = cAgent.alwaysrun;
@ -327,7 +311,6 @@ namespace OpenSim.Framework
Size = new Vector3(); Size = new Vector3();
Size.Z = cAgent.AVHeight; Size.Z = cAgent.AVHeight;
if (cAgent.cameraPosition != null)
Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z); Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
Far = cAgent.drawdistance; Far = cAgent.drawdistance;
@ -335,20 +318,15 @@ namespace OpenSim.Framework
// downcasting ??? // downcasting ???
GodLevel = (byte)(cAgent.godlevel); GodLevel = (byte)(cAgent.godlevel);
if (cAgent.ActiveGroupID != null)
{
Groups = new AgentGroupData[1]; Groups = new AgentGroupData[1];
Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true); Groups[0] = new AgentGroupData(new UUID(cAgent.ActiveGroupID), cAgent.GroupAccess, true);
}
if (cAgent.Position != null)
Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z); Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z);
RegionHandle = cAgent.regionHandle; RegionHandle = cAgent.regionHandle;
Throttles = cAgent.throttles; Throttles = cAgent.throttles;
if (cAgent.Velocity != null)
Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z); Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
} }