From 0274b19cad2fc727f67e00f9e0f01b0f9035d08f Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 30 May 2007 21:05:35 +0000 Subject: Attempt to enable chat, but seems to be a problem with the distances --- OpenSim/OpenSim.World/Avatar.cs | 1 - OpenSim/OpenSim.World/World.PacketHandlers.cs | 15 +++++++++++++-- OpenSim/OpenSim.World/World.cs | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/OpenSim.World/Avatar.cs b/OpenSim/OpenSim.World/Avatar.cs index 247e194..1c22977 100644 --- a/OpenSim/OpenSim.World/Avatar.cs +++ b/OpenSim/OpenSim.World/Avatar.cs @@ -136,7 +136,6 @@ namespace OpenSim.world //really really should be moved somewhere else (RegionInfo.cs ?) public void SendRegionHandshake() { - Console.WriteLine("sending handshake"); this.ControllingClient.SendRegionHandshake(this.regionData); } diff --git a/OpenSim/OpenSim.World/World.PacketHandlers.cs b/OpenSim/OpenSim.World/World.PacketHandlers.cs index 3357536..9908525 100644 --- a/OpenSim/OpenSim.World/World.PacketHandlers.cs +++ b/OpenSim/OpenSim.World/World.PacketHandlers.cs @@ -33,11 +33,21 @@ namespace OpenSim.world public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { + Console.WriteLine("chat message"); + Avatar avatar = null; foreach (IClientAPI client in m_clientThreads.Values) { - // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); - int dis = 0; // (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos); + int dis = -1000; + if (this.Avatars.ContainsKey(client.AgentId)) + { + + avatar = this.Avatars[client.AgentId]; + // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); + dis= (int)avatar.Pos.GetDistanceTo(fromPos); + Console.WriteLine("found avatar at " +dis); + } + switch (type) { case 0: // Whisper @@ -50,6 +60,7 @@ namespace OpenSim.world case 1: // Say if ((dis < 30) && (dis > -30)) { + Console.WriteLine("sending chat"); client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); } break; diff --git a/OpenSim/OpenSim.World/World.cs b/OpenSim/OpenSim.World/World.cs index 6a50aaa..29c75e8 100644 --- a/OpenSim/OpenSim.World/World.cs +++ b/OpenSim/OpenSim.World/World.cs @@ -505,6 +505,7 @@ namespace OpenSim.world { remoteClient.OnRegionHandShakeReply += new GenericCall(this.SendLayerData); //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); + remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); Avatar newAvatar = null; try -- cgit v1.1