diff options
author | UbitUmarov | 2014-10-24 18:10:28 +0100 |
---|---|---|
committer | UbitUmarov | 2014-10-24 18:10:28 +0100 |
commit | 4571e5bc3e284c916d1ae4dd6429b80a8028b8e0 (patch) | |
tree | 29420430b8535b1498b3fb656cb6b20e6409619f /OpenSim/Region/CoreModules/Framework/EntityTransfer | |
parent | TEST**** wingridproxy detection at grid login. Untested possible not (diff) | |
download | opensim-SC-4571e5bc3e284c916d1ae4dd6429b80a8028b8e0.zip opensim-SC-4571e5bc3e284c916d1ae4dd6429b80a8028b8e0.tar.gz opensim-SC-4571e5bc3e284c916d1ae4dd6429b80a8028b8e0.tar.bz2 opensim-SC-4571e5bc3e284c916d1ae4dd6429b80a8028b8e0.tar.xz |
try to make SOG crossings full async. Simplify some borders checking....
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 182 |
1 files changed, 152 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index c898946..b855233 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1385,13 +1385,61 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1385 | 1385 | ||
1386 | 1386 | ||
1387 | #region Agent Crossings | 1387 | #region Agent Crossings |
1388 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) | 1388 | |
1389 | public bool checkAgentAccessToRegion(ScenePresence agent, GridRegion destiny, Vector3 position, out string version, out string reason) | ||
1390 | { | ||
1391 | reason = String.Empty; | ||
1392 | version = String.Empty; | ||
1393 | |||
1394 | UUID agentID = agent.UUID; | ||
1395 | ulong destinyHandle = destiny.RegionHandle; | ||
1396 | |||
1397 | ExpiringCache<ulong, DateTime> r; | ||
1398 | DateTime banUntil; | ||
1399 | if (m_bannedRegions.TryGetValue(agentID, out r)) | ||
1400 | { | ||
1401 | if (r.TryGetValue(destinyHandle, out banUntil)) | ||
1402 | { | ||
1403 | if (DateTime.Now < banUntil) | ||
1404 | { | ||
1405 | reason = "Cannot connect to region"; | ||
1406 | return false; | ||
1407 | } | ||
1408 | r.Remove(destinyHandle); | ||
1409 | } | ||
1410 | } | ||
1411 | else | ||
1412 | { | ||
1413 | r = null; | ||
1414 | } | ||
1415 | |||
1416 | Scene ascene = agent.Scene; | ||
1417 | |||
1418 | if (!ascene.SimulationService.QueryAccess(destiny, agentID, position, out version, out reason)) | ||
1419 | { | ||
1420 | if (r == null) | ||
1421 | { | ||
1422 | r = new ExpiringCache<ulong, DateTime>(); | ||
1423 | r.Add(destinyHandle, DateTime.Now + TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); | ||
1424 | |||
1425 | m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(30)); | ||
1426 | } | ||
1427 | else | ||
1428 | { | ||
1429 | r.Add(destinyHandle, DateTime.Now + TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); | ||
1430 | } | ||
1431 | return false; | ||
1432 | } | ||
1433 | return true; | ||
1434 | } | ||
1435 | |||
1436 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos) | ||
1389 | { | 1437 | { |
1390 | string r = String.Empty; | 1438 | string r = String.Empty; |
1391 | return GetDestination(scene, agentID, pos, out xDest, out yDest, out version, out newpos, out r); | 1439 | return GetDestination(scene, agentID, pos, out version, out newpos, out r); |
1392 | } | 1440 | } |
1393 | 1441 | ||
1394 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos, out string reason) | 1442 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos, out string reason) |
1395 | { | 1443 | { |
1396 | version = String.Empty; | 1444 | version = String.Empty; |
1397 | reason = String.Empty; | 1445 | reason = String.Empty; |
@@ -1400,9 +1448,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1400 | // m_log.DebugFormat( | 1448 | // m_log.DebugFormat( |
1401 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); | 1449 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); |
1402 | 1450 | ||
1403 | uint neighbourx = scene.RegionInfo.RegionLocX; | 1451 | RegionInfo regInfo = scene.RegionInfo; |
1404 | uint neighboury = scene.RegionInfo.RegionLocY; | 1452 | |
1453 | uint neighbourx = regInfo.RegionLocX; | ||
1454 | uint neighboury = regInfo.RegionLocY; | ||
1405 | const float boundaryDistance = 0.7f; | 1455 | const float boundaryDistance = 0.7f; |
1456 | |||
1457 | /* | ||
1406 | Vector3 northCross = new Vector3(0, boundaryDistance, 0); | 1458 | Vector3 northCross = new Vector3(0, boundaryDistance, 0); |
1407 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); | 1459 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); |
1408 | Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); | 1460 | Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); |
@@ -1463,11 +1515,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1463 | 1515 | ||
1464 | newpos.X = Util.Clamp(newpos.X, enterDistance, maxX); | 1516 | newpos.X = Util.Clamp(newpos.X, enterDistance, maxX); |
1465 | newpos.Y = Util.Clamp(newpos.Y, enterDistance, maxY); | 1517 | newpos.Y = Util.Clamp(newpos.Y, enterDistance, maxY); |
1518 | */ | ||
1519 | float regionSizeX = regInfo.RegionSizeX; | ||
1520 | float regionSizeY = regInfo.RegionSizeY; | ||
1521 | |||
1522 | if (pos.X < boundaryDistance) | ||
1523 | neighbourx--; | ||
1524 | else if (pos.X > regionSizeX - boundaryDistance) | ||
1525 | neighbourx += (uint)(regionSizeX / Constants.RegionSize); | ||
1466 | 1526 | ||
1467 | xDest = neighbourx; | 1527 | if (pos.Y < boundaryDistance) |
1468 | yDest = neighboury; | 1528 | neighboury--; |
1529 | else if (pos.Y > regionSizeY - boundaryDistance) | ||
1530 | neighboury += (uint)(regionSizeY / Constants.RegionSize); | ||
1469 | 1531 | ||
1470 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); | 1532 | int x = (int)(neighbourx * Constants.RegionSize); |
1533 | int y = (int)(neighboury * Constants.RegionSize); | ||
1471 | 1534 | ||
1472 | ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y); | 1535 | ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y); |
1473 | 1536 | ||
@@ -1489,6 +1552,28 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1489 | } | 1552 | } |
1490 | 1553 | ||
1491 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 1554 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
1555 | if (neighbourRegion == null) | ||
1556 | { | ||
1557 | reason = ""; | ||
1558 | return null; | ||
1559 | } | ||
1560 | |||
1561 | float newRegionSizeX = neighbourRegion.RegionSizeX; | ||
1562 | float newRegionSizeY = neighbourRegion.RegionSizeY; | ||
1563 | |||
1564 | if (pos.X < boundaryDistance) | ||
1565 | newpos.X += newRegionSizeX; | ||
1566 | else if (pos.X > regionSizeX - boundaryDistance) | ||
1567 | newpos.X -= regionSizeX; | ||
1568 | |||
1569 | if (pos.Y < boundaryDistance) | ||
1570 | newpos.Y += newRegionSizeY; | ||
1571 | else if (pos.Y > regionSizeY - boundaryDistance) | ||
1572 | newpos.Y -= regionSizeY; | ||
1573 | |||
1574 | const float enterDistance = 0.5f; | ||
1575 | newpos.X = Util.Clamp(newpos.X, enterDistance, newRegionSizeX - enterDistance); | ||
1576 | newpos.Y = Util.Clamp(newpos.Y, enterDistance, newRegionSizeY - enterDistance); | ||
1492 | 1577 | ||
1493 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason)) | 1578 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason)) |
1494 | { | 1579 | { |
@@ -1543,13 +1628,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1543 | 1628 | ||
1544 | Vector3 pos = agent.AbsolutePosition + agent.Velocity; | 1629 | Vector3 pos = agent.AbsolutePosition + agent.Velocity; |
1545 | 1630 | ||
1546 | GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos, out x, out y, out version, out newpos, out reason); | 1631 | GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos, out version, out newpos, out reason); |
1547 | if (neighbourRegion == null) | 1632 | if (neighbourRegion == null) |
1548 | { | 1633 | { |
1549 | if (reason == String.Empty) | 1634 | if (reason != String.Empty) |
1550 | agent.ControllingClient.SendAlertMessage("Cannot cross to region"); | 1635 | agent.ControllingClient.SendAlertMessage("Cannot cross to region"); |
1551 | else | ||
1552 | agent.ControllingClient.SendAlertMessage("Cannot cross to region: " + reason); | ||
1553 | return agent; | 1636 | return agent; |
1554 | } | 1637 | } |
1555 | 1638 | ||
@@ -2346,6 +2429,62 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2346 | 2429 | ||
2347 | #region Object Transfers | 2430 | #region Object Transfers |
2348 | 2431 | ||
2432 | public GridRegion GetObjectDestination(SceneObjectGroup grp, Vector3 targetPosition,out Vector3 newpos) | ||
2433 | { | ||
2434 | newpos = targetPosition; | ||
2435 | |||
2436 | Scene scene = grp.Scene; | ||
2437 | if (scene == null) | ||
2438 | return null; | ||
2439 | |||
2440 | RegionInfo srcRegionInfo = scene.RegionInfo; | ||
2441 | int neighbourx = (int)srcRegionInfo.RegionLocX; | ||
2442 | int neighboury = (int)srcRegionInfo.RegionLocY; | ||
2443 | float regionSizeX = srcRegionInfo.RegionSizeX; | ||
2444 | float regionSizeY = srcRegionInfo.RegionSizeY; | ||
2445 | |||
2446 | float edgeJitter = 0.2f; | ||
2447 | |||
2448 | if (targetPosition.X < edgeJitter) | ||
2449 | neighbourx--; | ||
2450 | else if (targetPosition.X > regionSizeX - edgeJitter) | ||
2451 | neighbourx += (int)(regionSizeX / Constants.RegionSize); | ||
2452 | |||
2453 | if (targetPosition.Y < edgeJitter) | ||
2454 | neighboury--; | ||
2455 | else if (targetPosition.Y > regionSizeY - edgeJitter) | ||
2456 | neighboury += (int)(regionSizeY / Constants.RegionSize); | ||
2457 | |||
2458 | int x = neighbourx * (int)Constants.RegionSize; | ||
2459 | int y = neighboury * (int)Constants.RegionSize; | ||
2460 | |||
2461 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
2462 | if (neighbourRegion == null) | ||
2463 | { | ||
2464 | return null; | ||
2465 | } | ||
2466 | |||
2467 | float newRegionSizeX = neighbourRegion.RegionSizeX; | ||
2468 | float newRegionSizeY = neighbourRegion.RegionSizeY; | ||
2469 | |||
2470 | if (targetPosition.X < edgeJitter) | ||
2471 | newpos.X += newRegionSizeX; | ||
2472 | else if (targetPosition.X > regionSizeX - edgeJitter) | ||
2473 | newpos.X -= regionSizeX; | ||
2474 | |||
2475 | if (targetPosition.Y < edgeJitter) | ||
2476 | newpos.Y += newRegionSizeY; | ||
2477 | else if (targetPosition.Y > regionSizeY - edgeJitter) | ||
2478 | newpos.Y -= regionSizeY; | ||
2479 | |||
2480 | const float enterDistance = 0.2f; | ||
2481 | newpos.X = Util.Clamp(newpos.X, enterDistance, newRegionSizeX - enterDistance); | ||
2482 | newpos.Y = Util.Clamp(newpos.Y, enterDistance, newRegionSizeY - enterDistance); | ||
2483 | |||
2484 | return neighbourRegion; | ||
2485 | } | ||
2486 | |||
2487 | |||
2349 | /// <summary> | 2488 | /// <summary> |
2350 | /// Move the given scene object into a new region depending on which region its absolute position has moved | 2489 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
2351 | /// into. | 2490 | /// into. |
@@ -2365,23 +2504,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2365 | if (scene == null) | 2504 | if (scene == null) |
2366 | return; | 2505 | return; |
2367 | 2506 | ||
2368 | // http://wiki.secondlife.com/wiki/STATUS_DIE_AT_EDGE | ||
2369 | // DieAtEdge does NOT mean that objects can't cross regions. | ||
2370 | // It just means they die when they go off world, unless | ||
2371 | // RETURN_AT_EDGE is set. | ||
2372 | // if (grp.RootPart.DIE_AT_EDGE) | ||
2373 | // { | ||
2374 | // // We remove the object here | ||
2375 | // try | ||
2376 | // { | ||
2377 | // scene.DeleteSceneObject(grp, false); | ||
2378 | // } | ||
2379 | // catch (Exception) | ||
2380 | // { | ||
2381 | // m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); | ||
2382 | // } | ||
2383 | // return; | ||
2384 | // } | ||
2385 | 2507 | ||
2386 | int thisx = (int)scene.RegionInfo.RegionLocX; | 2508 | int thisx = (int)scene.RegionInfo.RegionLocX; |
2387 | int thisy = (int)scene.RegionInfo.RegionLocY; | 2509 | int thisy = (int)scene.RegionInfo.RegionLocY; |
@@ -2594,7 +2716,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2594 | /// true if the crossing itself was successful, false on failure | 2716 | /// true if the crossing itself was successful, false on failure |
2595 | /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region | 2717 | /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region |
2596 | /// </returns> | 2718 | /// </returns> |
2597 | protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) | 2719 | public bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) |
2598 | { | 2720 | { |
2599 | //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); | 2721 | //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); |
2600 | 2722 | ||