aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs57
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs421
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs228
5 files changed, 408 insertions, 316 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 6545a99..de8925d 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Framework
57 /// <summary> 57 /// <summary>
58 /// Each agent has its own capabilities handler. 58 /// Each agent has its own capabilities handler.
59 /// </summary> 59 /// </summary>
60 protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); 60 protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>();
61 61
62 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); 62 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
63 63
@@ -118,9 +118,10 @@ namespace OpenSim.Region.CoreModules.Framework
118 get { return null; } 118 get { return null; }
119 } 119 }
120 120
121 public void CreateCaps(UUID agentId) 121 public void CreateCaps(UUID agentId, uint circuitCode)
122 { 122 {
123 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 123 int flags = m_scene.GetUserFlags(agentId);
124 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
124 return; 125 return;
125 126
126 Caps caps; 127 Caps caps;
@@ -128,9 +129,9 @@ namespace OpenSim.Region.CoreModules.Framework
128 129
129 lock (m_capsObjects) 130 lock (m_capsObjects)
130 { 131 {
131 if (m_capsObjects.ContainsKey(agentId)) 132 if (m_capsObjects.ContainsKey(circuitCode))
132 { 133 {
133 Caps oldCaps = m_capsObjects[agentId]; 134 Caps oldCaps = m_capsObjects[circuitCode];
134 135
135 //m_log.WarnFormat( 136 //m_log.WarnFormat(
136 // "[CAPS]: Recreating caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ", 137 // "[CAPS]: Recreating caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ",
@@ -141,13 +142,12 @@ namespace OpenSim.Region.CoreModules.Framework
141 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 142 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
142 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 143 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
143 144
144 m_capsObjects[agentId] = caps; 145 m_capsObjects[circuitCode] = caps;
145 } 146 }
146
147 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); 147 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
148 } 148 }
149 149
150 public void RemoveCaps(UUID agentId) 150 public void RemoveCaps(UUID agentId, uint circuitCode)
151 { 151 {
152 m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); 152 m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName);
153 lock (m_childrenSeeds) 153 lock (m_childrenSeeds)
@@ -160,11 +160,11 @@ namespace OpenSim.Region.CoreModules.Framework
160 160
161 lock (m_capsObjects) 161 lock (m_capsObjects)
162 { 162 {
163 if (m_capsObjects.ContainsKey(agentId)) 163 if (m_capsObjects.ContainsKey(circuitCode))
164 { 164 {
165 m_capsObjects[agentId].DeregisterHandlers(); 165 m_capsObjects[circuitCode].DeregisterHandlers();
166 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]); 166 m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[circuitCode]);
167 m_capsObjects.Remove(agentId); 167 m_capsObjects.Remove(circuitCode);
168 } 168 }
169 else 169 else
170 { 170 {
@@ -175,19 +175,30 @@ namespace OpenSim.Region.CoreModules.Framework
175 } 175 }
176 } 176 }
177 177
178 public Caps GetCapsForUser(UUID agentId) 178 public Caps GetCapsForUser(uint circuitCode)
179 { 179 {
180 lock (m_capsObjects) 180 lock (m_capsObjects)
181 { 181 {
182 if (m_capsObjects.ContainsKey(agentId)) 182 if (m_capsObjects.ContainsKey(circuitCode))
183 { 183 {
184 return m_capsObjects[agentId]; 184 return m_capsObjects[circuitCode];
185 } 185 }
186 } 186 }
187 187
188 return null; 188 return null;
189 } 189 }
190 190
191 public void ActivateCaps(uint circuitCode)
192 {
193 lock (m_capsObjects)
194 {
195 if (m_capsObjects.ContainsKey(circuitCode))
196 {
197 m_capsObjects[circuitCode].Activate();
198 }
199 }
200 }
201
191 public void SetAgentCapsSeeds(AgentCircuitData agent) 202 public void SetAgentCapsSeeds(AgentCircuitData agent)
192 { 203 {
193 lock (m_capsPaths) 204 lock (m_capsPaths)
@@ -287,9 +298,9 @@ namespace OpenSim.Region.CoreModules.Framework
287 298
288 lock (m_capsObjects) 299 lock (m_capsObjects)
289 { 300 {
290 foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) 301 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
291 { 302 {
292 capsReport.AppendFormat("** User {0}:\n", kvp.Key); 303 capsReport.AppendFormat("** Circuit {0}:\n", kvp.Key);
293 Caps caps = kvp.Value; 304 Caps caps = kvp.Value;
294 305
295 for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 306 for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
@@ -337,6 +348,7 @@ namespace OpenSim.Region.CoreModules.Framework
337 348
338 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) 349 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
339 { 350 {
351 /*
340 sb.AppendFormat("Capability name {0}\n", capName); 352 sb.AppendFormat("Capability name {0}\n", capName);
341 353
342 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 354 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -382,10 +394,12 @@ namespace OpenSim.Region.CoreModules.Framework
382 } 394 }
383 395
384 sb.Append(cdt.ToString()); 396 sb.Append(cdt.ToString());
397 */
385 } 398 }
386 399
387 private void BuildSummaryStatsByCapReport(StringBuilder sb) 400 private void BuildSummaryStatsByCapReport(StringBuilder sb)
388 { 401 {
402 /*
389 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 403 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
390 cdt.AddColumn("Name", 34); 404 cdt.AddColumn("Name", 34);
391 cdt.AddColumn("Req Received", 12); 405 cdt.AddColumn("Req Received", 12);
@@ -442,10 +456,12 @@ namespace OpenSim.Region.CoreModules.Framework
442 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); 456 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
443 457
444 sb.Append(cdt.ToString()); 458 sb.Append(cdt.ToString());
459 */
445 } 460 }
446 461
447 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) 462 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
448 { 463 {
464 /*
449 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) 465 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
450 return; 466 return;
451 467
@@ -476,10 +492,12 @@ namespace OpenSim.Region.CoreModules.Framework
476 } 492 }
477 493
478 MainConsole.Instance.Output(sb.ToString()); 494 MainConsole.Instance.Output(sb.ToString());
495 */
479 } 496 }
480 497
481 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) 498 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
482 { 499 {
500 /*
483 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); 501 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
484 502
485 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 503 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -505,10 +523,12 @@ namespace OpenSim.Region.CoreModules.Framework
505 cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); 523 cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled);
506 524
507 sb.Append(cdt.ToString()); 525 sb.Append(cdt.ToString());
526 */
508 } 527 }
509 528
510 private void BuildSummaryStatsByUserReport(StringBuilder sb) 529 private void BuildSummaryStatsByUserReport(StringBuilder sb)
511 { 530 {
531 /*
512 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 532 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
513 cdt.AddColumn("Name", 32); 533 cdt.AddColumn("Name", 32);
514 cdt.AddColumn("Type", 5); 534 cdt.AddColumn("Type", 5);
@@ -548,6 +568,7 @@ namespace OpenSim.Region.CoreModules.Framework
548 ); 568 );
549 569
550 sb.Append(cdt.ToString()); 570 sb.Append(cdt.ToString());
571 */
551 } 572 }
552 573
553 private class CapTableRow 574 private class CapTableRow
@@ -564,4 +585,4 @@ namespace OpenSim.Region.CoreModules.Framework
564 } 585 }
565 } 586 }
566 } 587 }
567} \ No newline at end of file 588}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 4219254..ed14c12 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
369 /// <param name="sp"></param> 369 /// <param name="sp"></param>
370 /// <param name="position"></param> 370 /// <param name="position"></param>
371 /// <param name="lookAt"></param> 371 /// <param name="lookAt"></param>
372 /// <param name="teleportFlags"></param 372 /// <param name="teleportFlags"></param>
373 private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) 373 private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags)
374 { 374 {
375 m_log.DebugFormat( 375 m_log.DebugFormat(
@@ -404,11 +404,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
404 position.Z = newPosZ; 404 position.Z = newPosZ;
405 } 405 }
406 406
407 if (sp.Flying)
408 teleportFlags |= (uint)TeleportFlags.IsFlying;
409
407 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 410 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
408 411
409 sp.ControllingClient.SendTeleportStart(teleportFlags); 412 sp.ControllingClient.SendTeleportStart(teleportFlags);
410 413
411 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 414 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
415 sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
412 sp.Velocity = Vector3.Zero; 416 sp.Velocity = Vector3.Zero;
413 sp.Teleport(position); 417 sp.Teleport(position);
414 418
@@ -609,8 +613,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
609 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 613 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
610 // it's actually doing a lot of work. 614 // it's actually doing a lot of work.
611 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 615 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
612 616 if (endPoint == null || endPoint.Address == null)
613 if (endPoint.Address == null)
614 { 617 {
615 sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); 618 sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
616 619
@@ -647,6 +650,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
647 // both regions 650 // both regions
648 if (sp.ParentID != (uint)0) 651 if (sp.ParentID != (uint)0)
649 sp.StandUp(); 652 sp.StandUp();
653 else if (sp.Flying)
654 teleportFlags |= (uint)TeleportFlags.IsFlying;
650 655
651 if (DisableInterRegionTeleportCancellation) 656 if (DisableInterRegionTeleportCancellation)
652 teleportFlags |= (uint)TeleportFlags.DisableCancel; 657 teleportFlags |= (uint)TeleportFlags.DisableCancel;
@@ -1267,11 +1272,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1267 1272
1268 #region Teleport Home 1273 #region Teleport Home
1269 1274
1270 public virtual void TriggerTeleportHome(UUID id, IClientAPI client) 1275 public virtual void TriggerTeleportHome(UUID id, IClientAPI client)
1271 { 1276 {
1272 TeleportHome(id, client); 1277 TeleportHome(id, client);
1273 } 1278 }
1274 1279
1275 public virtual bool TeleportHome(UUID id, IClientAPI client) 1280 public virtual bool TeleportHome(UUID id, IClientAPI client)
1276 { 1281 {
1277 m_log.DebugFormat( 1282 m_log.DebugFormat(
@@ -1282,6 +1287,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1282 1287
1283 if (uinfo != null) 1288 if (uinfo != null)
1284 { 1289 {
1290 if (uinfo.HomeRegionID == UUID.Zero)
1291 {
1292 // can't find the Home region: Tell viewer and abort
1293 client.SendTeleportFailed("You don't have a home position set.");
1294 return false;
1295 }
1285 GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 1296 GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
1286 if (regionInfo == null) 1297 if (regionInfo == null)
1287 { 1298 {
@@ -1301,9 +1312,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1301 } 1312 }
1302 else 1313 else
1303 { 1314 {
1304 m_log.ErrorFormat( 1315 // can't find the Home region: Tell viewer and abort
1305 "[ENTITY TRANSFER MODULE]: No grid user information found for {0} {1}. Cannot send home.", 1316 client.SendTeleportFailed("Your home region could not be found.");
1306 client.Name, client.AgentId);
1307 } 1317 }
1308 return false; 1318 return false;
1309 } 1319 }
@@ -1313,15 +1323,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1313 1323
1314 #region Agent Crossings 1324 #region Agent Crossings
1315 1325
1316 public bool Cross(ScenePresence agent, bool isFlying) 1326 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos)
1317 { 1327 {
1318 Scene scene = agent.Scene; 1328 version = String.Empty;
1319 Vector3 pos = agent.AbsolutePosition; 1329 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1320 1330
1321// m_log.DebugFormat( 1331// m_log.DebugFormat(
1322// "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); 1332// "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name);
1323 1333
1324 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1325 uint neighbourx = scene.RegionInfo.RegionLocX; 1334 uint neighbourx = scene.RegionInfo.RegionLocX;
1326 uint neighboury = scene.RegionInfo.RegionLocY; 1335 uint neighboury = scene.RegionInfo.RegionLocY;
1327 const float boundaryDistance = 1.7f; 1336 const float boundaryDistance = 1.7f;
@@ -1342,52 +1351,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1342 } 1351 }
1343 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1352 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1344 { 1353 {
1345 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 1354 neighboury--;
1346 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) 1355 newpos.Y = Constants.RegionSize - enterDistance;
1347 {
1348 neighboury--;
1349 newpos.Y = Constants.RegionSize - enterDistance;
1350 }
1351 else
1352 {
1353 agent.IsInTransit = true;
1354
1355 neighboury = b.TriggerRegionY;
1356 neighbourx = b.TriggerRegionX;
1357
1358 Vector3 newposition = pos;
1359 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1360 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1361 agent.ControllingClient.SendAgentAlertMessage(
1362 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1363 InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1364 return true;
1365 }
1366 }
1367
1368 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1369 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1370 {
1371 neighbourx--;
1372 newpos.X = Constants.RegionSize - enterDistance;
1373 }
1374 else
1375 {
1376 agent.IsInTransit = true;
1377
1378 neighboury = ba.TriggerRegionY;
1379 neighbourx = ba.TriggerRegionX;
1380
1381 Vector3 newposition = pos;
1382 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1383 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1384 agent.ControllingClient.SendAgentAlertMessage(
1385 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1386 InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1387
1388 return true;
1389 } 1356 }
1390 1357
1358 neighbourx--;
1359 newpos.X = Constants.RegionSize - enterDistance;
1391 } 1360 }
1392 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) 1361 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1393 { 1362 {
@@ -1397,26 +1366,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1397 1366
1398 if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1367 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1399 { 1368 {
1400 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 1369 neighboury--;
1401 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) 1370 newpos.Y = Constants.RegionSize - enterDistance;
1402 {
1403 neighboury--;
1404 newpos.Y = Constants.RegionSize - enterDistance;
1405 }
1406 else
1407 {
1408 agent.IsInTransit = true;
1409
1410 neighboury = ba.TriggerRegionY;
1411 neighbourx = ba.TriggerRegionX;
1412 Vector3 newposition = pos;
1413 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1414 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1415 agent.ControllingClient.SendAgentAlertMessage(
1416 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1417 InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1418 return true;
1419 }
1420 } 1371 }
1421 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 1372 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1422 { 1373 {
@@ -1428,25 +1379,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1428 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1379 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1429 { 1380 {
1430 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 1381 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1431 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) 1382 neighboury--;
1432 { 1383 newpos.Y = Constants.RegionSize - enterDistance;
1433 neighboury--;
1434 newpos.Y = Constants.RegionSize - enterDistance;
1435 }
1436 else
1437 {
1438 agent.IsInTransit = true;
1439
1440 neighboury = b.TriggerRegionY;
1441 neighbourx = b.TriggerRegionX;
1442 Vector3 newposition = pos;
1443 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1444 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1445 agent.ControllingClient.SendAgentAlertMessage(
1446 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1447 InformClientToInitiateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1448 return true;
1449 }
1450 } 1384 }
1451 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 1385 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1452 { 1386 {
@@ -1480,19 +1414,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1480 } 1414 }
1481 */ 1415 */
1482 1416
1483 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1417 xDest = neighbourx;
1418 yDest = neighboury;
1484 1419
1485 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); 1420 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1486 1421
1422 ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y);
1423
1487 ExpiringCache<ulong, DateTime> r; 1424 ExpiringCache<ulong, DateTime> r;
1488 DateTime banUntil; 1425 DateTime banUntil;
1489 1426
1490 if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r)) 1427 if (m_bannedRegions.TryGetValue(agentID, out r))
1491 { 1428 {
1492 if (r.TryGetValue(neighbourHandle, out banUntil)) 1429 if (r.TryGetValue(neighbourHandle, out banUntil))
1493 { 1430 {
1494 if (DateTime.Now < banUntil) 1431 if (DateTime.Now < banUntil)
1495 return false; 1432 return null;
1496 r.Remove(neighbourHandle); 1433 r.Remove(neighbourHandle);
1497 } 1434 }
1498 } 1435 }
@@ -1504,28 +1441,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1504 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 1441 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
1505 1442
1506 string reason; 1443 string reason;
1507 string version; 1444 if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason))
1508 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out version, out reason))
1509 { 1445 {
1510 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
1511 if (r == null) 1446 if (r == null)
1512 { 1447 {
1513 r = new ExpiringCache<ulong, DateTime>(); 1448 r = new ExpiringCache<ulong, DateTime>();
1514 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 1449 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
1515 1450
1516 m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45)); 1451 m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45));
1517 } 1452 }
1518 else 1453 else
1519 { 1454 {
1520 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 1455 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
1521 } 1456 }
1457 return null;
1458 }
1459
1460 return neighbourRegion;
1461 }
1462
1463 public bool Cross(ScenePresence agent, bool isFlying)
1464 {
1465 uint x;
1466 uint y;
1467 Vector3 newpos;
1468 string version;
1469
1470 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, out x, out y, out version, out newpos);
1471 if (neighbourRegion == null)
1472 {
1473 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
1522 return false; 1474 return false;
1523 } 1475 }
1524 1476
1525 agent.IsInTransit = true; 1477 agent.IsInTransit = true;
1526 1478
1527 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 1479 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1528 d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); 1480 d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d);
1529 1481
1530 return true; 1482 return true;
1531 } 1483 }
@@ -1607,52 +1559,49 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1607 icon.EndInvoke(iar); 1559 icon.EndInvoke(iar);
1608 } 1560 }
1609 1561
1610 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version); 1562 public bool CrossAgentToNewRegionPrep(ScenePresence agent, GridRegion neighbourRegion)
1563 {
1564 if (neighbourRegion == null)
1565 return false;
1566
1567 m_entityTransferStateMachine.SetInTransit(agent.UUID);
1568
1569 agent.RemoveFromPhysicalScene();
1570
1571 return true;
1572 }
1611 1573
1612 /// <summary> 1574 /// <summary>
1613 /// This Closes child agents on neighbouring regions 1575 /// This Closes child agents on neighbouring regions
1614 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 1576 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1615 /// </summary> 1577 /// </summary>
1616 protected ScenePresence CrossAgentToNewRegionAsync( 1578 public ScenePresence CrossAgentToNewRegionAsync(
1617 ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, 1579 ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
1618 bool isFlying, string version) 1580 bool isFlying, string version)
1619 { 1581 {
1620 if (neighbourRegion == null) 1582 if (!CrossAgentToNewRegionPrep(agent, neighbourRegion))
1583 {
1584 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
1621 return agent; 1585 return agent;
1586 }
1622 1587
1623 if (!m_entityTransferStateMachine.SetInTransit(agent.UUID)) 1588 if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying))
1624 { 1589 {
1625 m_log.ErrorFormat( 1590 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
1626 "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2} - agent is already in transit",
1627 agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName);
1628 return agent; 1591 return agent;
1629 } 1592 }
1630 1593
1631 bool transitWasReset = false; 1594 CrossAgentToNewRegionPost(agent, pos, neighbourRegion, isFlying, version);
1595 return agent;
1596 }
1632 1597
1598 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying)
1599 {
1633 try 1600 try
1634 { 1601 {
1635 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1602 AgentData cAgent = new AgentData();
1636
1637 m_log.DebugFormat(
1638 "[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}",
1639 agent.Firstname, agent.Lastname, neighbourx, neighboury, version);
1640
1641 Scene m_scene = agent.Scene;
1642
1643 if (!agent.ValidateAttachments())
1644 m_log.DebugFormat(
1645 "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.",
1646 agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName);
1647
1648 pos = pos + agent.Velocity;
1649 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
1650
1651 agent.RemoveFromPhysicalScene();
1652
1653 AgentData cAgent = new AgentData();
1654 agent.CopyTo(cAgent); 1603 agent.CopyTo(cAgent);
1655 cAgent.Position = pos; 1604 cAgent.Position = pos + agent.Velocity;
1656 if (isFlying) 1605 if (isFlying)
1657 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; 1606 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1658 1607
@@ -1662,7 +1611,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1662 // Beyond this point, extra cleanup is needed beyond removing transit state 1611 // Beyond this point, extra cleanup is needed beyond removing transit state
1663 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); 1612 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring);
1664 1613
1665 if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) 1614 if (!agent.Scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
1666 { 1615 {
1667 // region doesn't take it 1616 // region doesn't take it
1668 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); 1617 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
@@ -1674,88 +1623,108 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1674 ReInstantiateScripts(agent); 1623 ReInstantiateScripts(agent);
1675 agent.AddToPhysicalScene(isFlying); 1624 agent.AddToPhysicalScene(isFlying);
1676 1625
1677 return agent; 1626 return false;
1678 } 1627 }
1679 1628
1680 //m_log.Debug("BEFORE CROSS"); 1629 }
1681 //Scene.DumpChildrenSeeds(UUID); 1630 catch (Exception e)
1682 //DumpKnownRegions(); 1631 {
1683 string agentcaps; 1632 m_log.ErrorFormat(
1684 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) 1633 "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}",
1685 { 1634 agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace);
1686 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
1687 neighbourRegion.RegionHandle);
1688 return agent;
1689 }
1690 1635
1691 // No turning back 1636 // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc.
1692 agent.IsChildAgent = true; 1637 return false;
1638 }
1693 1639
1694 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); 1640 return true;
1641 }
1695 1642
1696 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 1643 public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
1644 bool isFlying, string version)
1645 {
1646 agent.ControllingClient.RequestClientInfo();
1697 1647
1698 if (m_eqModule != null) 1648 string agentcaps;
1699 { 1649 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1700 m_eqModule.CrossRegion( 1650 {
1701 neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, 1651 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
1702 capsPath, agent.UUID, agent.ControllingClient.SessionId); 1652 neighbourRegion.RegionHandle);
1703 } 1653 return;
1704 else 1654 }
1705 {
1706 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1707 capsPath);
1708 }
1709 1655
1710 // SUCCESS! 1656 // No turning back
1711 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); 1657 agent.IsChildAgent = true;
1712 1658
1713 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. 1659 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
1714 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1715 1660
1716 agent.MakeChildAgent(); 1661 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1717 1662
1718 // FIXME: Possibly this should occur lower down after other commands to close other agents, 1663 Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);
1719 // but not sure yet what the side effects would be. 1664
1720 m_entityTransferStateMachine.ResetFromTransit(agent.UUID); 1665 if (m_eqModule != null)
1721 transitWasReset = true; 1666 {
1667 m_eqModule.CrossRegion(
1668 neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint,
1669 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1670 }
1671 else
1672 {
1673 agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint,
1674 capsPath);
1675 }
1722 1676
1723 // now we have a child agent in this region. Request all interesting data about other (root) agents 1677 // SUCCESS!
1724 agent.SendOtherAgentsAvatarDataToMe(); 1678 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
1725 agent.SendOtherAgentsAppearanceToMe();
1726 1679
1727 // Backwards compatibility. Best effort 1680 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
1728 if (version == "Unknown" || version == string.Empty) 1681 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1729 {
1730 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one...");
1731 Thread.Sleep(3000); // wait a little now that we're not waiting for the callback
1732 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1733 }
1734 1682
1735 // Next, let's close the child agent connections that are too far away. 1683 agent.MakeChildAgent();
1736 agent.CloseChildAgents(neighbourx, neighboury);
1737 1684
1738 AgentHasMovedAway(agent, false); 1685 // FIXME: Possibly this should occur lower down after other commands to close other agents,
1739 1686 // but not sure yet what the side effects would be.
1740 //m_log.Debug("AFTER CROSS"); 1687 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
1741 //Scene.DumpChildrenSeeds(UUID);
1742 //DumpKnownRegions();
1743 }
1744 catch (Exception e)
1745 {
1746 m_log.ErrorFormat(
1747 "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}",
1748 agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace);
1749 1688
1750 // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. 1689 // now we have a child agent in this region. Request all interesting data about other (root) agents
1751 } 1690 agent.SendOtherAgentsAvatarDataToMe();
1752 finally 1691 agent.SendOtherAgentsAppearanceToMe();
1692
1693 // Backwards compatibility. Best effort
1694 if (version == "Unknown" || version == string.Empty)
1753 { 1695 {
1754 if (!transitWasReset) 1696 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one...");
1755 m_entityTransferStateMachine.ResetFromTransit(agent.UUID); 1697 Thread.Sleep(3000); // wait a little now that we're not waiting for the callback
1698 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1756 } 1699 }
1757 1700
1758 return agent; 1701 // Next, let's close the child agent connections that are too far away.
1702 uint neighbourx;
1703 uint neighboury;
1704
1705 Utils.LongToUInts(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
1706
1707 neighbourx /= Constants.RegionSize;
1708 neighboury /= Constants.RegionSize;
1709
1710 agent.CloseChildAgents(neighbourx, neighboury);
1711
1712 AgentHasMovedAway(agent, false);
1713
1714 // the user may change their profile information in other region,
1715 // so the userinfo in UserProfileCache is not reliable any more, delete it
1716 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
1717// if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1718// {
1719// m_log.DebugFormat(
1720// "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
1721// }
1722
1723 //m_log.Debug("AFTER CROSS");
1724 //Scene.DumpChildrenSeeds(UUID);
1725 //DumpKnownRegions();
1726
1727 return;
1759 } 1728 }
1760 1729
1761 private void CrossAgentToNewRegionCompleted(IAsyncResult iar) 1730 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
@@ -1826,10 +1795,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1826 agent.Id0 = currentAgentCircuit.Id0; 1795 agent.Id0 = currentAgentCircuit.Id0;
1827 } 1796 }
1828 1797
1829 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1798 IPEndPoint external = region.ExternalEndPoint;
1830 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1799 if (external != null)
1800 {
1801 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1802 d.BeginInvoke(sp, agent, region, external, true,
1831 InformClientOfNeighbourCompleted, 1803 InformClientOfNeighbourCompleted,
1832 d); 1804 d);
1805 }
1833 } 1806 }
1834 #endregion 1807 #endregion
1835 1808
@@ -2426,30 +2399,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2426 Utils.LongToUInts(newRegionHandle, out x, out y); 2399 Utils.LongToUInts(newRegionHandle, out x, out y);
2427 GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 2400 GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
2428 2401
2429 if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) 2402 if (destination != null)
2430 { 2403 {
2431 m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID); 2404 if (CrossPrimGroupIntoNewRegion(destination, pos, grp, silent))
2405 return; // we did it
2406 }
2432 2407
2433 // We are going to move the object back to the old position so long as the old position 2408 // no one or failed lets go back and tell physics to go on
2434 // is in the region 2409 oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f);
2435 oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X,1.0f,(float)Constants.RegionSize-1); 2410 oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
2436 oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y,1.0f,(float)Constants.RegionSize-1); 2411 oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f);
2437 oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z,1.0f,4096.0f);
2438 2412
2439 grp.RootPart.GroupPosition = oldGroupPosition; 2413 grp.AbsolutePosition = oldGroupPosition;
2414 grp.Velocity = Vector3.Zero;
2440 2415
2441 // Need to turn off the physics flags, otherwise the object will continue to attempt to 2416 if (grp.RootPart.PhysActor != null)
2442 // move out of the region creating an infinite loop of failed attempts to cross 2417 grp.RootPart.PhysActor.CrossingFailure();
2443 grp.UpdatePrimFlags(grp.RootPart.LocalId,false,grp.IsTemporary,grp.IsPhantom,false);
2444 2418
2445 if (grp.RootPart.KeyframeMotion != null) 2419 if (grp.RootPart.KeyframeMotion != null)
2446 grp.RootPart.KeyframeMotion.CrossingFailure(); 2420 grp.RootPart.KeyframeMotion.CrossingFailure();
2447 2421
2448 grp.ScheduleGroupForFullUpdate(); 2422 grp.ScheduleGroupForFullUpdate();
2449 }
2450 } 2423 }
2451 2424
2452 2425
2426
2453 /// <summary> 2427 /// <summary>
2454 /// Move the given scene object into a new region 2428 /// Move the given scene object into a new region
2455 /// </summary> 2429 /// </summary>
@@ -2500,17 +2474,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2500 grp, e); 2474 grp, e);
2501 } 2475 }
2502 } 2476 }
2477/*
2478 * done on caller ( not in attachments crossing for now)
2503 else 2479 else
2504 { 2480 {
2481
2505 if (!grp.IsDeleted) 2482 if (!grp.IsDeleted)
2506 { 2483 {
2507 PhysicsActor pa = grp.RootPart.PhysActor; 2484 PhysicsActor pa = grp.RootPart.PhysActor;
2508 if (pa != null) 2485 if (pa != null)
2486 {
2509 pa.CrossingFailure(); 2487 pa.CrossingFailure();
2488 if (grp.RootPart.KeyframeMotion != null)
2489 {
2490 // moved to KeyframeMotion.CrossingFailure
2491// grp.RootPart.Velocity = Vector3.Zero;
2492 grp.RootPart.KeyframeMotion.CrossingFailure();
2493// grp.SendGroupRootTerseUpdate();
2494 }
2495 }
2510 } 2496 }
2511 2497
2512 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); 2498 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
2513 } 2499 }
2500 */
2514 } 2501 }
2515 else 2502 else
2516 { 2503 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
index fc02916..e903383 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
@@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
294 id, m_mod.Scene.RegionInfo.RegionName, currentState)); 294 id, m_mod.Scene.RegionInfo.RegionName, currentState));
295 } 295 }
296 296
297 int count = 200; 297 int count = 400;
298 298
299 // There should be no race condition here since no other code should be removing the agent transfer or 299 // There should be no race condition here since no other code should be removing the agent transfer or
300 // changing the state to another other than Transferring => ReceivedAtDestination. 300 // changing the state to another other than Transferring => ReceivedAtDestination.
@@ -349,4 +349,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
349 } 349 }
350 } 350 }
351 } 351 }
352} \ No newline at end of file 352}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 76dbc72..1cf1884 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -313,6 +313,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
313 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); 313 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
314 } 314 }
315 315
316 public void TriggerTeleportHome(UUID id, IClientAPI client)
317 {
318 TeleportHome(id, client);
319 }
320
316 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) 321 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason)
317 { 322 {
318 reason = "Please wear your grid's allowed appearance before teleporting to another grid"; 323 reason = "Please wear your grid's allowed appearance before teleporting to another grid";
@@ -431,11 +436,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
431 // return base.UpdateAgent(reg, finalDestination, agentData, sp); 436 // return base.UpdateAgent(reg, finalDestination, agentData, sp);
432 //} 437 //}
433 438
434 public virtual void TriggerTeleportHome(UUID id, IClientAPI client)
435 {
436 TeleportHome(id, client);
437 }
438
439 public override bool TeleportHome(UUID id, IClientAPI client) 439 public override bool TeleportHome(UUID id, IClientAPI client)
440 { 440 {
441 m_log.DebugFormat( 441 m_log.DebugFormat(
@@ -483,9 +483,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
483 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", 483 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
484 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); 484 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
485 485
486 DoTeleport( 486 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
487 sp, homeGatekeeper, finalDestination,
488 position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
489 return true; 487 return true;
490 } 488 }
491 489
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 68e4e26..89bb037 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -183,44 +183,49 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
183 if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) 183 if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
184 return; 184 return;
185 185
186 if (transactionID == UUID.Zero) 186 InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
187 InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f);
188
189 if (folder == null || folder.Owner != remoteClient.AgentId)
190 return;
191
192 if (transactionID != UUID.Zero)
187 { 193 {
188 ScenePresence presence; 194 IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule;
189 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 195 if (agentTransactions != null)
190 { 196 {
191 byte[] data = null; 197 if (agentTransactions.HandleItemCreationFromTransaction(
198 remoteClient, transactionID, folderID, callbackID, description,
199 name, invType, assetType, wearableType, nextOwnerMask))
200 return;
201 }
202 }
192 203
193 if (invType == (sbyte)InventoryType.Landmark && presence != null) 204 ScenePresence presence;
194 { 205 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
195 string suffix = string.Empty, prefix = string.Empty; 206 {
196 string strdata = GenerateLandmark(presence, out prefix, out suffix); 207 byte[] data = null;
197 data = Encoding.ASCII.GetBytes(strdata);
198 name = prefix + name;
199 description += suffix;
200 }
201 208
202 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); 209 if (invType == (sbyte)InventoryType.Landmark && presence != null)
203 m_Scene.AssetService.Store(asset);
204 m_Scene.CreateNewInventoryItem(
205 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
206 name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
207 }
208 else
209 { 210 {
210 m_log.ErrorFormat( 211 string suffix = string.Empty, prefix = string.Empty;
211 "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", 212 string strdata = GenerateLandmark(presence, out prefix, out suffix);
212 remoteClient.AgentId); 213 data = Encoding.ASCII.GetBytes(strdata);
214 name = prefix + name;
215 description += suffix;
213 } 216 }
217
218 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
219 m_Scene.AssetService.Store(asset);
220 m_Scene.CreateNewInventoryItem(
221 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID,
222 name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID);
214 } 223 }
215 else 224 else
216 { 225 {
217 IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; 226 m_log.ErrorFormat(
218 if (agentTransactions != null) 227 "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
219 { 228 remoteClient.AgentId);
220 agentTransactions.HandleItemCreationFromTransaction(
221 remoteClient, transactionID, folderID, callbackID, description,
222 name, invType, assetType, wearableType, nextOwnerMask);
223 }
224 } 229 }
225 } 230 }
226 231
@@ -359,20 +364,38 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
359 { 364 {
360 if (objectGroup.RootPart.KeyframeMotion != null) 365 if (objectGroup.RootPart.KeyframeMotion != null)
361 objectGroup.RootPart.KeyframeMotion.Stop(); 366 objectGroup.RootPart.KeyframeMotion.Stop();
367 objectGroup.RootPart.SetForce(Vector3.Zero);
368 objectGroup.RootPart.SetAngularImpulse(Vector3.Zero, false);
362 objectGroup.RootPart.KeyframeMotion = null; 369 objectGroup.RootPart.KeyframeMotion = null;
363// Vector3 inventoryStoredPosition = new Vector3 370
364// (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) 371 Vector3 inventoryStoredPosition = new Vector3
365// ? 250 372 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
366// : objectGroup.AbsolutePosition.X) 373 ? 250
367// , 374 : objectGroup.AbsolutePosition.X)
368// (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) 375 ,
369// ? 250 376 (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize)
370// : objectGroup.AbsolutePosition.Y, 377 ? 250
371// objectGroup.AbsolutePosition.Z); 378 : objectGroup.AbsolutePosition.Y,
372// 379 objectGroup.AbsolutePosition.Z);
373// originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; 380
374// 381 Quaternion inventoryStoredRotation = objectGroup.GroupRotation;
375// objectGroup.AbsolutePosition = inventoryStoredPosition; 382 //originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
383
384 // Restore attachment data after trip through the sim
385 if (objectGroup.RootPart.AttachPoint > 0)
386 {
387 inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
388 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
389 }
390
391 // Trees could be attached and it's been done, but it makes
392 // no sense. State must be preserved because it's the tree type
393 if (objectGroup.RootPart.Shape.PCode != (byte)PCode.Tree &&
394 objectGroup.RootPart.Shape.PCode != (byte)PCode.NewTree)
395 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
396
397 objectGroup.AbsolutePosition = inventoryStoredPosition;
398 objectGroup.RootPart.RotationOffset = inventoryStoredRotation;
376 399
377 // Make sure all bits but the ones we want are clear 400 // Make sure all bits but the ones we want are clear
378 // on take. 401 // on take.
@@ -491,8 +514,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
491 IClientAPI remoteClient) 514 IClientAPI remoteClient)
492 { 515 {
493 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7; 516 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move | PermissionMask.Export) | 7;
517 // For the porposes of inventory, an object is modify if the prims
518 // are modify. This allows renaming an object that contains no
519 // mod items.
494 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 520 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
495 effectivePerms &= grp.GetEffectivePermissions(); 521 {
522 uint groupPerms = grp.GetEffectivePermissions(true);
523 if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0)
524 groupPerms |= (uint)PermissionMask.Modify;
525
526 effectivePerms &= groupPerms;
527 }
496 effectivePerms |= (uint)PermissionMask.Move; 528 effectivePerms |= (uint)PermissionMask.Move;
497 529
498 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 530 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
@@ -673,7 +705,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
673 if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId) 705 if (so.FromFolderID != UUID.Zero && so.RootPart.OwnerID == remoteClient.AgentId)
674 { 706 {
675 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID); 707 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
676 folder = m_Scene.InventoryService.GetFolder(f); 708 if (f != null)
709 folder = m_Scene.InventoryService.GetFolder(f);
677 710
678 if(folder.Type == 14 || folder.Type == 16) 711 if(folder.Type == 14 || folder.Type == 16)
679 { 712 {
@@ -709,16 +742,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
709 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 742 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
710 { 743 {
711// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); 744// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID);
712
713 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 745 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
714 item = m_Scene.InventoryService.GetItem(item); 746 item = m_Scene.InventoryService.GetItem(item);
715 747
716 if (item == null) 748 if (item == null)
717 { 749 {
718 m_log.WarnFormat(
719 "[INVENTORY ACCESS MODULE]: Could not find item {0} for {1} in RezObject()",
720 itemID, remoteClient.Name);
721
722 return null; 750 return null;
723 } 751 }
724 752
@@ -766,9 +794,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
766 XmlDocument doc = new XmlDocument(); 794 XmlDocument doc = new XmlDocument();
767 doc.LoadXml(xmlData); 795 doc.LoadXml(xmlData);
768 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); 796 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
797 Vector3 rez_pos;
769 if (e == null || attachment) // Single 798 if (e == null || attachment) // Single
770 { 799 {
771 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); 800 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
801 if (!attachment)
802 {
803 g.RootPart.AttachPoint = g.RootPart.Shape.State;
804 g.RootPart.AttachOffset = g.AbsolutePosition;
805 g.RootPart.AttachRotation = g.GroupRotation;
806 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
807 g.RootPart.Shape.PCode != (byte)PCode.Tree)
808 g.RootPart.Shape.State = 0;
809 }
772 810
773 objlist.Add(g); 811 objlist.Add(g);
774 veclist.Add(Vector3.Zero); 812 veclist.Add(Vector3.Zero);
@@ -778,6 +816,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
778 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 816 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
779 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); 817 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false);
780 pos.Z += offsetHeight; 818 pos.Z += offsetHeight;
819 rez_pos = pos;
781 } 820 }
782 else 821 else
783 { 822 {
@@ -792,12 +831,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
792 BypassRayCast, bRayEndIsIntersection, true, 831 BypassRayCast, bRayEndIsIntersection, true,
793 bbox, false); 832 bbox, false);
794 833
834 rez_pos = pos;
835
795 pos -= bbox / 2; 836 pos -= bbox / 2;
796 837
797 XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); 838 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
798 foreach (XmlNode n in groups) 839 foreach (XmlNode n in groups)
799 { 840 {
800 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); 841 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
842 g.RootPart.AttachPoint = g.RootPart.Shape.State;
843 g.RootPart.AttachOffset = g.AbsolutePosition;
844 g.RootPart.AttachRotation = g.GroupRotation;
845 if (g.RootPart.Shape.PCode != (byte)PCode.NewTree &&
846 g.RootPart.Shape.PCode != (byte)PCode.Tree)
847 g.RootPart.Shape.State = 0;
801 848
802 objlist.Add(g); 849 objlist.Add(g);
803 XmlElement el = (XmlElement)n; 850 XmlElement el = (XmlElement)n;
@@ -817,12 +864,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
817 } 864 }
818 } 865 }
819 866
820 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, veclist, attachment)) 867 int primcount = 0;
868 foreach (SceneObjectGroup g in objlist)
869 primcount += g.PrimCount;
870
871 if (!m_Scene.Permissions.CanRezObject(
872 primcount, remoteClient.AgentId, rez_pos)
873 && !attachment)
874 {
875 // The client operates in no fail mode. It will
876 // have already removed the item from the folder
877 // if it's no copy.
878 // Put it back if it's not an attachment
879 //
880 if (item != null)
881 {
882 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
883 remoteClient.SendBulkUpdateInventory(item);
884 }
885
886 return null;
887 }
888
889 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, rez_pos, veclist, attachment))
821 return null; 890 return null;
822 891
823 for (int i = 0; i < objlist.Count; i++) 892 for (int i = 0; i < objlist.Count; i++)
824 { 893 {
825 group = objlist[i]; 894 group = objlist[i];
895 SceneObjectPart rootPart = group.RootPart;
826 896
827// m_log.DebugFormat( 897// m_log.DebugFormat(
828// "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", 898// "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}",
@@ -883,8 +953,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
883 953
884 if (!attachment) 954 if (!attachment)
885 { 955 {
886 SceneObjectPart rootPart = group.RootPart;
887
888 if (rootPart.Shape.PCode == (byte)PCode.Prim) 956 if (rootPart.Shape.PCode == (byte)PCode.Prim)
889 group.ClearPartAttachmentData(); 957 group.ClearPartAttachmentData();
890 958
@@ -902,6 +970,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
902// remoteClient.Name); 970// remoteClient.Name);
903 } 971 }
904 972
973 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
974
905 if (item != null) 975 if (item != null)
906 DoPostRezWhenFromItem(item, attachment); 976 DoPostRezWhenFromItem(item, attachment);
907 977
@@ -986,8 +1056,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
986 { 1056 {
987 rootPart.Name = item.Name; 1057 rootPart.Name = item.Name;
988 rootPart.Description = item.Description; 1058 rootPart.Description = item.Description;
989 rootPart.ObjectSaleType = item.SaleType; 1059 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
990 rootPart.SalePrice = item.SalePrice; 1060 {
1061 rootPart.ObjectSaleType = item.SaleType;
1062 rootPart.SalePrice = item.SalePrice;
1063 }
991 } 1064 }
992 1065
993 so.FromFolderID = item.Folder; 1066 so.FromFolderID = item.Folder;
@@ -997,7 +1070,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
997// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1070// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
998 1071
999 if ((rootPart.OwnerID != item.Owner) || 1072 if ((rootPart.OwnerID != item.Owner) ||
1000 (item.CurrentPermissions & 16) != 0) 1073 (item.CurrentPermissions & 16) != 0 ||
1074 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
1001 { 1075 {
1002 //Need to kill the for sale here 1076 //Need to kill the for sale here
1003 rootPart.ObjectSaleType = 0; 1077 rootPart.ObjectSaleType = 0;
@@ -1007,31 +1081,43 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1007 { 1081 {
1008 foreach (SceneObjectPart part in so.Parts) 1082 foreach (SceneObjectPart part in so.Parts)
1009 { 1083 {
1010 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1011 {
1012 part.EveryoneMask = item.EveryOnePermissions;
1013 part.NextOwnerMask = item.NextPermissions;
1014 }
1015 part.GroupMask = 0; // DO NOT propagate here 1084 part.GroupMask = 0; // DO NOT propagate here
1085
1086 part.LastOwnerID = part.OwnerID;
1087 part.OwnerID = item.Owner;
1088 part.Inventory.ChangeInventoryOwner(item.Owner);
1016 } 1089 }
1017 1090
1018 so.ApplyNextOwnerPermissions(); 1091 so.ApplyNextOwnerPermissions();
1092
1093 // In case the user has changed flags on a received item
1094 // we have to apply those changes after the slam. Else we
1095 // get a net loss of permissions
1096 foreach (SceneObjectPart part in so.Parts)
1097 {
1098 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1099 {
1100 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
1101 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
1102 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
1103 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1104 }
1105 }
1019 } 1106 }
1020 } 1107 }
1021 1108 else
1022 foreach (SceneObjectPart part in so.Parts)
1023 { 1109 {
1024 part.FromUserInventoryItemID = fromUserInventoryItemId; 1110 foreach (SceneObjectPart part in so.Parts)
1025
1026 if ((part.OwnerID != item.Owner) ||
1027 (item.CurrentPermissions & 16) != 0)
1028 { 1111 {
1029 part.Inventory.ChangeInventoryOwner(item.Owner); 1112 part.FromUserInventoryItemID = fromUserInventoryItemId;
1030 part.GroupMask = 0; // DO NOT propagate here 1113
1114 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
1115 part.EveryoneMask = item.EveryOnePermissions;
1116 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
1117 part.NextOwnerMask = item.NextPermissions;
1118 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
1119 part.GroupMask = item.GroupPermissions;
1031 } 1120 }
1032
1033 part.EveryoneMask = item.EveryOnePermissions;
1034 part.NextOwnerMask = item.NextPermissions;
1035 } 1121 }
1036 1122
1037 rootPart.TrimPermissions(); 1123 rootPart.TrimPermissions();