From 9479f647781184d39d174fd708650da1e847c18c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 May 2014 23:48:10 +0100 Subject: Fix issue where avatar and script chat could sometimes be heard from anywhere in neighbouring regions. This was due to a silent uint overflow in ScenePresence.UpdateChildAgent() corrupting child agent positions when the child agent was in a region with a greater x or y map co-ord than the root agent region Probably introduced in beeec1c. This still will not function properly with very high region map co-ords (in the millions) but other parts of the code don't handle this properly anyway. Looks to address http://opensimulator.org/mantis/view.php?id=7163 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dd4bbe9..28b5b46 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3777,10 +3777,15 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) return; - //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", +// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); + // Find the distance (in meters) between the two regions - uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); - uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); + // XXX: We cannot use Util.RegionLocToHandle() here because a negative value will silently overflow the + // uint + int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); + int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); Vector3 offset = new Vector3(shiftx, shifty, 0f); -- cgit v1.1