aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.API.cs
diff options
context:
space:
mode:
authorMW2007-05-29 09:16:18 +0000
committerMW2007-05-29 09:16:18 +0000
commitb2eb26e4babbf87c8db84e67de116ef145feb2d6 (patch)
treeb5feafcaa4ee0dbe18c502203595d7e0d9014987 /OpenSim/OpenSim.RegionServer/ClientView.API.cs
parentShould allow multiple worlds (and UDP servers) to be ran in one instance, jus... (diff)
downloadopensim-SC-b2eb26e4babbf87c8db84e67de116ef145feb2d6.zip
opensim-SC-b2eb26e4babbf87c8db84e67de116ef145feb2d6.tar.gz
opensim-SC-b2eb26e4babbf87c8db84e67de116ef145feb2d6.tar.bz2
opensim-SC-b2eb26e4babbf87c8db84e67de116ef145feb2d6.tar.xz
number of changes
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.API.cs198
1 files changed, 197 insertions, 1 deletions
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.API.cs b/OpenSim/OpenSim.RegionServer/ClientView.API.cs
index 579928c..55ff8a1 100644
--- a/OpenSim/OpenSim.RegionServer/ClientView.API.cs
+++ b/OpenSim/OpenSim.RegionServer/ClientView.API.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Framework.Interfaces; 4using OpenSim.Framework.Interfaces;
5using OpenSim.Framework.Inventory; 5using OpenSim.Framework.Inventory;
6using OpenSim.Framework.Types;
6using libsecondlife; 7using libsecondlife;
7using libsecondlife.Packets; 8using libsecondlife.Packets;
8 9
@@ -32,6 +33,8 @@ namespace OpenSim
32 public event UpdatePrimVector OnUpdatePrimScale; 33 public event UpdatePrimVector OnUpdatePrimScale;
33 public event StatusChange OnChildAgentStatus; 34 public event StatusChange OnChildAgentStatus;
34 public event GenericCall2 OnStopMovement; 35 public event GenericCall2 OnStopMovement;
36 public event NewAvatar OnNewAvatar;
37 public event GenericCall6 OnRemoveAvatar;
35 38
36 public LLVector3 StartPos 39 public LLVector3 StartPos
37 { 40 {
@@ -70,7 +73,7 @@ namespace OpenSim
70 this.OutPacket(reply); 73 this.OutPacket(reply);
71 } 74 }
72 75
73 public void SendAppearance(AvatarWearable[] wearables) 76 public void SendWearables(AvatarWearable[] wearables)
74 { 77 {
75 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); 78 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
76 aw.AgentData.AgentID = this.AgentID; 79 aw.AgentData.AgentID = this.AgentID;
@@ -90,6 +93,199 @@ namespace OpenSim
90 93
91 this.OutPacket(aw); 94 this.OutPacket(aw);
92 } 95 }
96
97 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
98 {
99 AvatarAppearancePacket avp = new AvatarAppearancePacket();
100 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
101 avp.ObjectData.TextureEntry = textureEntry;
102
103 AvatarAppearancePacket.VisualParamBlock avblock = null;
104 for (int i = 0; i < 218; i++)
105 {
106 avblock = new AvatarAppearancePacket.VisualParamBlock();
107 avblock.ParamValue = visualParams[i];
108 avp.VisualParam[i] = avblock;
109 }
110
111 avp.Sender.IsTrial = false;
112 avp.Sender.ID = agentID;
113 OutPacket(avp);
114 }
115
116 /// <summary>
117 /// Send the region heightmap to the client
118 /// </summary>
119 /// <param name="map">heightmap</param>
120 public virtual void SendLayerData(float[] map)
121 {
122 try
123 {
124 int[] patches = new int[4];
125
126 for (int y = 0; y < 16; y++)
127 {
128 for (int x = 0; x < 16; x = x + 4)
129 {
130 patches[0] = x + 0 + y * 16;
131 patches[1] = x + 1 + y * 16;
132 patches[2] = x + 2 + y * 16;
133 patches[3] = x + 3 + y * 16;
134
135 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
136 OutPacket(layerpack);
137 }
138 }
139 }
140 catch (Exception e)
141 {
142 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
143 }
144 }
145
146 /// <summary>
147 /// Sends a specified patch to a client
148 /// </summary>
149 /// <param name="px">Patch coordinate (x) 0..16</param>
150 /// <param name="py">Patch coordinate (y) 0..16</param>
151 /// <param name="map">heightmap</param>
152 public void SendLayerData(int px, int py, float[] map)
153 {
154 try
155 {
156 int[] patches = new int[1];
157 int patchx, patchy;
158 patchx = px / 16;
159 patchy = py / 16;
160
161 patches[0] = patchx + 0 + patchy * 16;
162
163 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
164 OutPacket(layerpack);
165 }
166 catch (Exception e)
167 {
168 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
169 }
170 }
171
172 public void SendRegionHandshake(RegionInfo regionInfo)
173 {
174 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
175 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
176 RegionHandshakePacket handshake = new RegionHandshakePacket();
177
178 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
179 handshake.RegionInfo.BillableFactor = 0;
180 handshake.RegionInfo.IsEstateManager = false;
181 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.TerrainHeightRange00;
182 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.TerrainHeightRange01;
183 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.TerrainHeightRange10;
184 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.TerrainHeightRange11;
185 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.TerrainStartHeight00;
186 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.TerrainStartHeight01;
187 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.TerrainStartHeight10;
188 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.TerrainStartHeight11;
189 handshake.RegionInfo.SimAccess = 13;
190 handshake.RegionInfo.WaterHeight = regionInfo.RegionWaterHeight;
191 uint regionFlags = 72458694;
192 if (regionInfo.RegionTerraform)
193 {
194 regionFlags -= 64;
195 }
196 handshake.RegionInfo.RegionFlags = regionFlags;
197 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
198 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
199 handshake.RegionInfo.TerrainBase0 = regionInfo.TerrainBase0;
200 handshake.RegionInfo.TerrainBase1 = regionInfo.TerrainBase1;
201 handshake.RegionInfo.TerrainBase2 = regionInfo.TerrainBase2;
202 handshake.RegionInfo.TerrainBase3 = regionInfo.TerrainBase3;
203 handshake.RegionInfo.TerrainDetail0 = regionInfo.TerrainDetail0;
204 handshake.RegionInfo.TerrainDetail1 = regionInfo.TerrainDetail1;
205 handshake.RegionInfo.TerrainDetail2 = regionInfo.TerrainDetail2;
206 handshake.RegionInfo.TerrainDetail3 = regionInfo.TerrainDetail3;
207 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
208
209 OutPacket(handshake);
210 }
211
212 public void SendAvatarData(RegionInfo regionInfo, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos)
213 {
214 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
215 //send a objectupdate packet with information about the clients avatar
216
217 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
218 objupdate.RegionData.RegionHandle = regionInfo.RegionHandle;
219 objupdate.RegionData.TimeDilation = 64096;
220 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
221 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket();
222 //give this avatar object a local id and assign the user a name
223
224 objupdate.ObjectData[0].ID = avatarLocalID;
225 objupdate.ObjectData[0].FullID = avatarID;
226 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName + " \0");
227 libsecondlife.LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
228 byte[] pb = pos2.GetBytes();
229 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
230
231 OutPacket(objupdate);
232
233 }
234
235 protected void SetDefaultPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
236 {
237 objdata.PSBlock = new byte[0];
238 objdata.ExtraParams = new byte[1];
239 objdata.MediaURL = new byte[0];
240 objdata.NameValue = new byte[0];
241 objdata.Text = new byte[0];
242 objdata.TextColor = new byte[4];
243 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
244 objdata.JointPivot = new LLVector3(0, 0, 0);
245 objdata.Material = 4;
246 objdata.TextureAnim = new byte[0];
247 objdata.Sound = LLUUID.Zero;
248 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
249 objdata.TextureEntry = ntex.ToBytes();
250 objdata.State = 0;
251 objdata.Data = new byte[0];
252
253 objdata.ObjectData = new byte[76];
254 objdata.ObjectData[15] = 128;
255 objdata.ObjectData[16] = 63;
256 objdata.ObjectData[56] = 128;
257 objdata.ObjectData[61] = 102;
258 objdata.ObjectData[62] = 40;
259 objdata.ObjectData[63] = 61;
260 objdata.ObjectData[64] = 189;
261 }
262
263 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket()
264 {
265 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
266
267 SetDefaultPacketValues(ref objdata);
268 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
269 objdata.PathCurve = 16;
270 objdata.ProfileCurve = 1;
271 objdata.PathScaleX = 100;
272 objdata.PathScaleY = 100;
273 objdata.ParentID = 0;
274 objdata.OwnerID = LLUUID.Zero;
275 objdata.Scale = new LLVector3(1, 1, 1);
276 objdata.PCode = 47;
277 System.Text.Encoding enc = System.Text.Encoding.ASCII;
278 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
279 pos.X = 100f;
280 objdata.ID = 8880000;
281 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
282 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
283 //objdata.FullID=user.AgentID;
284 byte[] pb = pos.GetBytes();
285 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
286
287 return objdata;
288 }
93 #endregion 289 #endregion
94 290
95 } 291 }