aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/World.PacketHandlers.cs
diff options
context:
space:
mode:
authorMW2007-05-21 16:06:58 +0000
committerMW2007-05-21 16:06:58 +0000
commitfe46b045f75dec5ecdd0a29273c70df3e6ea540e (patch)
tree554c0fb47e513fc6a89f496d99b7b67de24edde7 /OpenSim.RegionServer/world/World.PacketHandlers.cs
parentIncreased version number to 0.2! ZOMG! (diff)
downloadopensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.zip
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.gz
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.bz2
opensim-SC_OLD-fe46b045f75dec5ecdd0a29273c70df3e6ea540e.tar.xz
Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim , switching to a event based system (World/Avatar register as event handlers). It is possible that I've broke something with this commit but it doesn't matter as I'll just hide and no one will find me.
Diffstat (limited to 'OpenSim.RegionServer/world/World.PacketHandlers.cs')
-rw-r--r--OpenSim.RegionServer/world/World.PacketHandlers.cs56
1 files changed, 16 insertions, 40 deletions
diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs
index 175b777..27f200f 100644
--- a/OpenSim.RegionServer/world/World.PacketHandlers.cs
+++ b/OpenSim.RegionServer/world/World.PacketHandlers.cs
@@ -16,7 +16,7 @@ namespace OpenSim.world
16 public partial class World 16 public partial class World
17 { 17 {
18 18
19 public bool ModifyTerrain(SimClient simClient, Packet packet) 19 public bool ModifyTerrain(ClientView simClient, Packet packet)
20 { 20 {
21 ModifyLandPacket modify = (ModifyLandPacket)packet; 21 ModifyLandPacket modify = (ModifyLandPacket)packet;
22 22
@@ -42,68 +42,44 @@ namespace OpenSim.world
42 return true; 42 return true;
43 } 43 }
44 44
45 public bool SimChat(SimClient simClient, Packet packet) 45 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
46 { 46 {
47 System.Text.Encoding enc = System.Text.Encoding.ASCII; 47 foreach (ClientView client in m_clientThreads.Values)
48 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
49 if (Util.FieldToString(inchatpack.ChatData.Message) == "")
50 {
51 //empty message so don't bother with it
52 return true;
53 }
54
55 string fromName = simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname;
56 byte[] message = inchatpack.ChatData.Message;
57 byte type = inchatpack.ChatData.Type;
58 LLVector3 fromPos = simClient.ClientAvatar.Pos;
59 LLUUID fromAgentID = simClient.AgentID;
60
61 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
62 reply.ChatData.Audible = 1;
63 reply.ChatData.Message = message;
64 reply.ChatData.ChatType = type;
65 reply.ChatData.SourceType = 1;
66 reply.ChatData.Position = fromPos;
67 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
68 reply.ChatData.OwnerID = fromAgentID;
69 reply.ChatData.SourceID = fromAgentID;
70
71 foreach (SimClient client in m_clientThreads.Values)
72 { 48 {
73 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); 49 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
74 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(simClient.ClientAvatar.Pos); 50 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
75 51
76 switch (inchatpack.ChatData.Type) 52 switch (type)
77 { 53 {
78 case 0: // Whisper 54 case 0: // Whisper
79 if ((dis < 10) && (dis > -10)) 55 if ((dis < 10) && (dis > -10))
80 { 56 {
81 client.OutPacket(reply); 57 //should change so the message is sent through the avatar rather than direct to the ClientView
58 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
82 } 59 }
83 break; 60 break;
84 case 1: // Say 61 case 1: // Say
85 if ((dis < 30) && (dis > -30)) 62 if ((dis < 30) && (dis > -30))
86 { 63 {
87 client.OutPacket(reply); 64 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
88 } 65 }
89 break; 66 break;
90 case 2: // Shout 67 case 2: // Shout
91 if ((dis < 100) && (dis > -100)) 68 if ((dis < 100) && (dis > -100))
92 { 69 {
93 client.OutPacket(reply); 70 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
94 } 71 }
95 break; 72 break;
96 73
97 case 0xff: // Broadcast 74 case 0xff: // Broadcast
98 client.OutPacket(reply); 75 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
99 break; 76 break;
100 } 77 }
101 78
102 } 79 }
103 return true;
104 } 80 }
105 81
106 public bool RezObject(SimClient simClient, Packet packet) 82 public bool RezObject(ClientView simClient, Packet packet)
107 { 83 {
108 RezObjectPacket rezPacket = (RezObjectPacket)packet; 84 RezObjectPacket rezPacket = (RezObjectPacket)packet;
109 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); 85 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
@@ -126,7 +102,7 @@ namespace OpenSim.world
126 return true; 102 return true;
127 } 103 }
128 104
129 public bool DeRezObject(SimClient simClient, Packet packet) 105 public bool DeRezObject(ClientView simClient, Packet packet)
130 { 106 {
131 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; 107 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
132 108
@@ -151,7 +127,7 @@ namespace OpenSim.world
151 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 127 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
152 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 128 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
153 kill.ObjectData[0].ID = ent.localid; 129 kill.ObjectData[0].ID = ent.localid;
154 foreach (SimClient client in m_clientThreads.Values) 130 foreach (ClientView client in m_clientThreads.Values)
155 { 131 {
156 client.OutPacket(kill); 132 client.OutPacket(kill);
157 } 133 }
@@ -201,7 +177,7 @@ namespace OpenSim.world
201 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 177 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
202 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 178 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
203 kill.ObjectData[0].ID = selectedEnt.localid; 179 kill.ObjectData[0].ID = selectedEnt.localid;
204 foreach (SimClient client in m_clientThreads.Values) 180 foreach (ClientView client in m_clientThreads.Values)
205 { 181 {
206 client.OutPacket(kill); 182 client.OutPacket(kill);
207 } 183 }
@@ -215,7 +191,7 @@ namespace OpenSim.world
215 return true; 191 return true;
216 } 192 }
217 193
218 public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY) 194 public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY)
219 { 195 {
220 System.Text.Encoding _enc = System.Text.Encoding.ASCII; 196 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
221 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) 197 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))