aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-25 03:06:26 +0100
committerJustin Clark-Casey (justincc)2012-05-25 03:06:26 +0100
commit888210ea4af0f9d41263193d450d73eba5d866fc (patch)
tree2d4f7cce2db487a0796c937896cf7750e0a9ebc4 /OpenSim/Region/CoreModules
parentRemove a call stack debugging line accidentally left in from a few days ago a... (diff)
downloadopensim-SC_OLD-888210ea4af0f9d41263193d450d73eba5d866fc.zip
opensim-SC_OLD-888210ea4af0f9d41263193d450d73eba5d866fc.tar.gz
opensim-SC_OLD-888210ea4af0f9d41263193d450d73eba5d866fc.tar.bz2
opensim-SC_OLD-888210ea4af0f9d41263193d450d73eba5d866fc.tar.xz
refactor: make ETM.CrossAgentToNewRegionAsync neighbourRegion == null check return earlier to simplify method
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs182
1 files changed, 92 insertions, 90 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index ddb621d..7295383 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1106,119 +1106,121 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1106 ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, 1106 ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion,
1107 bool isFlying, string version) 1107 bool isFlying, string version)
1108 { 1108 {
1109 if (neighbourRegion == null)
1110 return agent;
1111
1109 try 1112 try
1110 { 1113 {
1111 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1114 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1112 1115
1113 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version); 1116 m_log.DebugFormat(
1117 "[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}",
1118 agent.Firstname, agent.Lastname, neighbourx, neighboury, version);
1114 1119
1115 Scene m_scene = agent.Scene; 1120 Scene m_scene = agent.Scene;
1116
1117 if (neighbourRegion != null)
1118 {
1119 if (!agent.ValidateAttachments())
1120 m_log.DebugFormat(
1121 "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.",
1122 agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName);
1123 1121
1124 pos = pos + agent.Velocity; 1122 if (!agent.ValidateAttachments())
1125 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); 1123 m_log.DebugFormat(
1124 "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.",
1125 agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName);
1126 1126
1127 agent.RemoveFromPhysicalScene(); 1127 pos = pos + agent.Velocity;
1128 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
1128 1129
1129 SetInTransit(agent.UUID); 1130 agent.RemoveFromPhysicalScene();
1130 1131
1131 AgentData cAgent = new AgentData(); 1132 SetInTransit(agent.UUID);
1132 agent.CopyTo(cAgent);
1133 cAgent.Position = pos;
1134 if (isFlying)
1135 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1136 1133
1137 // We don't need the callback anymnore 1134 AgentData cAgent = new AgentData();
1138 cAgent.CallbackURI = String.Empty; 1135 agent.CopyTo(cAgent);
1136 cAgent.Position = pos;
1137 if (isFlying)
1138 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1139 1139
1140 // Beyond this point, extra cleanup is needed beyond removing transit state 1140 // We don't need the callback anymnore
1141 UpdateInTransit(agent.UUID, AgentTransferState.Transferring); 1141 cAgent.CallbackURI = String.Empty;
1142 1142
1143 if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) 1143 // Beyond this point, extra cleanup is needed beyond removing transit state
1144 { 1144 UpdateInTransit(agent.UUID, AgentTransferState.Transferring);
1145 // region doesn't take it
1146 ReInstantiateScripts(agent);
1147 agent.AddToPhysicalScene(isFlying);
1148 ResetFromTransit(agent.UUID);
1149 return agent;
1150 }
1151
1152 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1153 agent.ControllingClient.RequestClientInfo();
1154
1155 //m_log.Debug("BEFORE CROSS");
1156 //Scene.DumpChildrenSeeds(UUID);
1157 //DumpKnownRegions();
1158 string agentcaps;
1159 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1160 {
1161 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
1162 neighbourRegion.RegionHandle);
1163 return agent;
1164 }
1165 // No turning back
1166 agent.IsChildAgent = true;
1167 1145
1168 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); 1146 if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
1169 1147 {
1170 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 1148 // region doesn't take it
1149 ReInstantiateScripts(agent);
1150 agent.AddToPhysicalScene(isFlying);
1151 ResetFromTransit(agent.UUID);
1152 return agent;
1153 }
1171 1154
1172 if (m_eqModule != null) 1155 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1173 { 1156 agent.ControllingClient.RequestClientInfo();
1174 m_eqModule.CrossRegion(
1175 neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint,
1176 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1177 }
1178 else
1179 {
1180 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1181 capsPath);
1182 }
1183 1157
1184 // SUCCESS! 1158 //m_log.Debug("BEFORE CROSS");
1185 UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); 1159 //Scene.DumpChildrenSeeds(UUID);
1160 //DumpKnownRegions();
1161 string agentcaps;
1162 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1163 {
1164 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
1165 neighbourRegion.RegionHandle);
1166 return agent;
1167 }
1168 // No turning back
1169 agent.IsChildAgent = true;
1186 1170
1187 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. 1171 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
1188 UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1189 1172
1190 agent.MakeChildAgent(); 1173 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1191 1174
1192 // FIXME: Possibly this should occur lower down after other commands to close other agents, 1175 if (m_eqModule != null)
1193 // but not sure yet what the side effects would be. 1176 {
1194 ResetFromTransit(agent.UUID); 1177 m_eqModule.CrossRegion(
1178 neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint,
1179 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1180 }
1181 else
1182 {
1183 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1184 capsPath);
1185 }
1195 1186
1196 // now we have a child agent in this region. Request all interesting data about other (root) agents 1187 // SUCCESS!
1197 agent.SendOtherAgentsAvatarDataToMe(); 1188 UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
1198 agent.SendOtherAgentsAppearanceToMe();
1199 1189
1200 // Backwards compatibility. Best effort 1190 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
1201 if (version == "Unknown" || version == string.Empty) 1191 UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1202 {
1203 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one...");
1204 Thread.Sleep(3000); // wait a little now that we're not waiting for the callback
1205 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1206 }
1207 1192
1193 agent.MakeChildAgent();
1208 1194
1209 // Next, let's close the child agent connections that are too far away. 1195 // FIXME: Possibly this should occur lower down after other commands to close other agents,
1210 agent.CloseChildAgents(neighbourx, neighboury); 1196 // but not sure yet what the side effects would be.
1211 1197 ResetFromTransit(agent.UUID);
1212 AgentHasMovedAway(agent, false); 1198
1213 1199 // now we have a child agent in this region. Request all interesting data about other (root) agents
1214 // the user may change their profile information in other region, 1200 agent.SendOtherAgentsAvatarDataToMe();
1215 // so the userinfo in UserProfileCache is not reliable any more, delete it 1201 agent.SendOtherAgentsAppearanceToMe();
1216 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! 1202
1217 if (agent.Scene.NeedSceneCacheClear(agent.UUID)) 1203 // Backwards compatibility. Best effort
1218 { 1204 if (version == "Unknown" || version == string.Empty)
1219 m_log.DebugFormat( 1205 {
1220 "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); 1206 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one...");
1221 } 1207 Thread.Sleep(3000); // wait a little now that we're not waiting for the callback
1208 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1209 }
1210
1211
1212 // Next, let's close the child agent connections that are too far away.
1213 agent.CloseChildAgents(neighbourx, neighboury);
1214
1215 AgentHasMovedAway(agent, false);
1216
1217 // the user may change their profile information in other region,
1218 // so the userinfo in UserProfileCache is not reliable any more, delete it
1219 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
1220 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1221 {
1222 m_log.DebugFormat(
1223 "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
1222 } 1224 }
1223 1225
1224 //m_log.Debug("AFTER CROSS"); 1226 //m_log.Debug("AFTER CROSS");