aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Agent_Manager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Agent_Manager.cs')
-rw-r--r--Agent_Manager.cs480
1 files changed, 235 insertions, 245 deletions
diff --git a/Agent_Manager.cs b/Agent_Manager.cs
index 769ee2a..5ff40cd 100644
--- a/Agent_Manager.cs
+++ b/Agent_Manager.cs
@@ -41,23 +41,23 @@ namespace OpenSim
41 { 41 {
42 public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList; 42 public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList;
43 43
44 private uint local_numer=0; 44 private uint _localNumber=0;
45 private Server server; 45 private Server _server;
46 public PrimManager Prim_Manager; 46 public PrimManager Prim_Manager;
47 public AssetManagement Asset_Manager; 47 public AssetManagement assetManager;
48 48
49 private libsecondlife.Packets.RegionHandshakePacket RegionPacket; 49 private libsecondlife.Packets.RegionHandshakePacket RegionPacket;
50 private System.Text.Encoding enc = System.Text.Encoding.ASCII; 50 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
51 public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 51 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
52 52
53 /// <summary> 53 /// <summary>
54 /// 54 ///
55 /// </summary> 55 /// </summary>
56 /// <param name="serve"></param> 56 /// <param name="serve"></param>
57 public AgentManager(Server serve) 57 public AgentManager(Server server)
58 { 58 {
59 AgentList=new Dictionary<libsecondlife.LLUUID,AvatarData>(); 59 AgentList = new Dictionary<libsecondlife.LLUUID,AvatarData>();
60 server=serve; 60 _server = server;
61 this.initialise(); 61 this.initialise();
62 } 62 }
63 63
@@ -74,8 +74,8 @@ namespace OpenSim
74 } 74 }
75 else 75 else
76 { 76 {
77 AvatarData ad=this.AgentList[id]; 77 AvatarData avatar = this.AgentList[id];
78 return ad; 78 return avatar;
79 } 79 }
80 } 80 }
81 /// <summary> 81 /// <summary>
@@ -84,7 +84,7 @@ namespace OpenSim
84 /// <param name="agent"></param> 84 /// <param name="agent"></param>
85 public void AddAgent(AvatarData agent) 85 public void AddAgent(AvatarData agent)
86 { 86 {
87 this.AgentList.Add(agent.FullID,agent); 87 this.AgentList.Add(agent.FullID, agent);
88 } 88 }
89 /// <summary> 89 /// <summary>
90 /// 90 ///
@@ -102,20 +102,20 @@ namespace OpenSim
102 /// <param name="first"></param> 102 /// <param name="first"></param>
103 /// <param name="last"></param> 103 /// <param name="last"></param>
104 /// <returns></returns> 104 /// <returns></returns>
105 public bool NewAgent(User_Agent_info User_info, string first, string last ,LLUUID BaseFolder,LLUUID InventoryFolder) 105 public bool NewAgent(UserAgentInfo userInfo, string first, string last, LLUUID baseFolder, LLUUID inventoryFolder)
106 { 106 {
107 AvatarData agent=new AvatarData(); 107 AvatarData agent = new AvatarData();
108 agent.FullID=User_info.AgentID; 108 agent.FullID = userInfo.AgentID;
109 agent.NetInfo=User_info; 109 agent.NetInfo = userInfo;
110 agent.NetInfo.first_name=first; 110 agent.NetInfo.first_name =first;
111 agent.NetInfo.last_name=last; 111 agent.NetInfo.last_name = last;
112 agent.Position=new LLVector3(100,100,22); 112 agent.Position = new LLVector3(100, 100, 22);
113 agent.BaseFolder=BaseFolder; 113 agent.BaseFolder = baseFolder;
114 agent.InventoryFolder=InventoryFolder; 114 agent.InventoryFolder = inventoryFolder;
115 this.AgentList.Add(agent.FullID,agent); 115 this.AgentList.Add(agent.FullID, agent);
116 116
117 //Create new Wearable Assets and place in Inventory 117 //Create new Wearable Assets and place in Inventory
118 this.Asset_Manager.CreateNewInventorySet(ref agent,User_info); 118 this.assetManager.CreateNewInventorySet(ref agent, userInfo);
119 119
120 return(true); 120 return(true);
121 } 121 }
@@ -124,9 +124,9 @@ namespace OpenSim
124 /// 124 ///
125 /// </summary> 125 /// </summary>
126 /// <param name="UserInfo"></param> 126 /// <param name="UserInfo"></param>
127 public void RemoveAgent(User_Agent_info UserInfo) 127 public void RemoveAgent(UserAgentInfo userInfo)
128 { 128 {
129 this.AgentList.Remove(UserInfo.AgentID); 129 this.AgentList.Remove(userInfo.AgentID);
130 130
131 //tell other clients to delete this avatar 131 //tell other clients to delete this avatar
132 } 132 }
@@ -135,20 +135,20 @@ namespace OpenSim
135 /// 135 ///
136 /// </summary> 136 /// </summary>
137 /// <param name="User_info"></param> 137 /// <param name="User_info"></param>
138 public void AgentJoin(User_Agent_info User_info) 138 public void AgentJoin(UserAgentInfo userInfo)
139 { 139 {
140 //send region data 140 //send region data
141 server.SendPacket(RegionPacket,true,User_info); 141 _server.SendPacket(RegionPacket,true, userInfo);
142 142
143 //inform client of join comlete 143 //inform client of join comlete
144 libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); 144 libsecondlife.Packets.AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
145 mov.AgentData.SessionID=User_info.SessionID; 145 mov.AgentData.SessionID = userInfo.SessionID;
146 mov.AgentData.AgentID=User_info.AgentID; 146 mov.AgentData.AgentID = userInfo.AgentID;
147 mov.Data.RegionHandle=Globals.Instance.RegionHandle; 147 mov.Data.RegionHandle = Globals.Instance.RegionHandle;
148 mov.Data.Timestamp=1169838966; 148 mov.Data.Timestamp = 1169838966;
149 mov.Data.Position=new LLVector3(100f,100f,22f); 149 mov.Data.Position = new LLVector3(100f, 100f, 22f);
150 mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); 150 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
151 server.SendPacket(mov,true,User_info); 151 _server.SendPacket(mov, true, userInfo);
152 } 152 }
153 153
154 /// <summary> 154 /// <summary>
@@ -157,12 +157,12 @@ namespace OpenSim
157 public void UpdatePositions() 157 public void UpdatePositions()
158 { 158 {
159 //update positions 159 //update positions
160 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 160 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList)
161 { 161 {
162 162
163 kp.Value.Position.X+=(kp.Value.Velocity.X*0.2f); 163 kp.Value.Position.X += (kp.Value.Velocity.X * 0.2f);
164 kp.Value.Position.Y+=(kp.Value.Velocity.Y*0.2f); 164 kp.Value.Position.Y += (kp.Value.Velocity.Y * 0.2f);
165 kp.Value.Position.Z+=(kp.Value.Velocity.Z*0.2f); 165 kp.Value.Position.Z += (kp.Value.Velocity.Z * 0.2f);
166 } 166 }
167 } 167 }
168 168
@@ -172,31 +172,31 @@ namespace OpenSim
172 private void initialise() 172 private void initialise()
173 { 173 {
174 //Region data 174 //Region data
175 RegionPacket=new RegionHandshakePacket(); 175 RegionPacket = new RegionHandshakePacket();
176 RegionPacket.RegionInfo.BillableFactor=0; 176 RegionPacket.RegionInfo.BillableFactor = 0;
177 RegionPacket.RegionInfo.IsEstateManager=false; 177 RegionPacket.RegionInfo.IsEstateManager = false;
178 RegionPacket.RegionInfo.TerrainHeightRange00=60; 178 RegionPacket.RegionInfo.TerrainHeightRange00 = 60;
179 RegionPacket.RegionInfo.TerrainHeightRange01=60; 179 RegionPacket.RegionInfo.TerrainHeightRange01 = 60;
180 RegionPacket.RegionInfo.TerrainHeightRange10=60; 180 RegionPacket.RegionInfo.TerrainHeightRange10 = 60;
181 RegionPacket.RegionInfo.TerrainHeightRange11=60; 181 RegionPacket.RegionInfo.TerrainHeightRange11 = 60;
182 RegionPacket.RegionInfo.TerrainStartHeight00=20; 182 RegionPacket.RegionInfo.TerrainStartHeight00 = 20;
183 RegionPacket.RegionInfo.TerrainStartHeight01=20; 183 RegionPacket.RegionInfo.TerrainStartHeight01 = 20;
184 RegionPacket.RegionInfo.TerrainStartHeight10=20; 184 RegionPacket.RegionInfo.TerrainStartHeight10 = 20;
185 RegionPacket.RegionInfo.TerrainStartHeight11=20; 185 RegionPacket.RegionInfo.TerrainStartHeight11 = 20;
186 RegionPacket.RegionInfo.SimAccess=13; 186 RegionPacket.RegionInfo.SimAccess = 13;
187 RegionPacket.RegionInfo.WaterHeight=5; 187 RegionPacket.RegionInfo.WaterHeight = 5;
188 RegionPacket.RegionInfo.RegionFlags=72458694; 188 RegionPacket.RegionInfo.RegionFlags = 72458694;
189 RegionPacket.RegionInfo.SimName=enc.GetBytes( Globals.Instance.RegionName); 189 RegionPacket.RegionInfo.SimName = _enc.GetBytes( Globals.Instance.RegionName);
190 RegionPacket.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); 190 RegionPacket.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
191 RegionPacket.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); 191 RegionPacket.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
192 RegionPacket.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); 192 RegionPacket.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
193 RegionPacket.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); 193 RegionPacket.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
194 RegionPacket.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); 194 RegionPacket.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
195 RegionPacket.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); 195 RegionPacket.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
196 RegionPacket.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); 196 RegionPacket.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
197 RegionPacket.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); 197 RegionPacket.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
198 RegionPacket.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); 198 RegionPacket.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
199 RegionPacket.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); 199 RegionPacket.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
200 200
201 this.SetupTemplate("objectupate168.dat"); 201 this.SetupTemplate("objectupate168.dat");
202 } 202 }
@@ -208,7 +208,7 @@ namespace OpenSim
208 private void SetupTemplate(string name) 208 private void SetupTemplate(string name)
209 { 209 {
210 210
211 int i=0; 211 int i = 0;
212 FileInfo fInfo = new FileInfo(name); 212 FileInfo fInfo = new FileInfo(name);
213 long numBytes = fInfo.Length; 213 long numBytes = fInfo.Length;
214 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 214 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
@@ -217,19 +217,19 @@ namespace OpenSim
217 br.Close(); 217 br.Close();
218 fStream.Close(); 218 fStream.Close();
219 219
220 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); 220 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
221 221
222 System.Text.Encoding enc = System.Text.Encoding.ASCII; 222 System.Text.Encoding enc = System.Text.Encoding.ASCII;
223 libsecondlife.LLVector3 pos=new LLVector3(objdata.ObjectData, 16); 223 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
224 pos.X=100f; 224 pos.X = 100f;
225 objdata.ID=8880000; 225 objdata.ID = 8880000;
226 objdata.NameValue=enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); 226 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
227 libsecondlife.LLVector3 pos2=new LLVector3(13.981f,100.0f,20.0f); 227 libsecondlife.LLVector3 pos2 = new LLVector3(13.981f,100.0f,20.0f);
228 //objdata.FullID=user.AgentID; 228 //objdata.FullID=user.AgentID;
229 byte[] pb=pos.GetBytes(); 229 byte[] pb = pos.GetBytes();
230 Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); 230 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
231 231
232 AvatarTemplate=objdata; 232 AvatarTemplate = objdata;
233 233
234 } 234 }
235 235
@@ -237,52 +237,52 @@ namespace OpenSim
237 /// 237 ///
238 /// </summary> 238 /// </summary>
239 /// <param name="User_info"></param> 239 /// <param name="User_info"></param>
240 public void SendInitialData(User_Agent_info User_info) 240 public void SendInitialData(UserAgentInfo userInfo)
241 { 241 {
242 242
243 //shouldn't have to read all this in from disk for every new client 243 //shouldn't have to read all this in from disk for every new client
244 string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; 244 string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\";
245 245
246 //send layerdata 246 //send layerdata
247 LayerDataPacket layerpack=new LayerDataPacket(); 247 LayerDataPacket layerpack = new LayerDataPacket();
248 layerpack.LayerID.Type=76; 248 layerpack.LayerID.Type = 76;
249 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat"); 249 this.SendLayerData(userInfo,ref layerpack, data_path+@"layerdata0.dat");
250 250
251 LayerDataPacket layerpack1=new LayerDataPacket(); 251 LayerDataPacket layerpack1 = new LayerDataPacket();
252 layerpack1.LayerID.Type=76; 252 layerpack1.LayerID.Type = 76;
253 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat"); 253 this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata1.dat");
254 254
255 LayerDataPacket layerpack2=new LayerDataPacket(); 255 LayerDataPacket layerpack2 = new LayerDataPacket();
256 layerpack2.LayerID.Type=56; 256 layerpack2.LayerID.Type = 56;
257 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat"); 257 this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata2.dat");
258 258
259 LayerDataPacket layerpack3=new LayerDataPacket(); 259 LayerDataPacket layerpack3 = new LayerDataPacket();
260 layerpack3.LayerID.Type=55; 260 layerpack3.LayerID.Type = 55;
261 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat"); 261 this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata3.dat");
262 262
263 LayerDataPacket layerpack4=new LayerDataPacket(); 263 LayerDataPacket layerpack4 = new LayerDataPacket();
264 layerpack4.LayerID.Type=56; 264 layerpack4.LayerID.Type = 56;
265 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat"); 265 this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata4.dat");
266 266
267 LayerDataPacket layerpack5=new LayerDataPacket(); 267 LayerDataPacket layerpack5 = new LayerDataPacket();
268 layerpack5.LayerID.Type=55; 268 layerpack5.LayerID.Type = 55;
269 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat"); 269 this.SendLayerData(userInfo, ref layerpack, data_path+@"layerdata5.dat");
270 270
271 //send intial set of captured prims data? 271 //send intial set of captured prims data?
272 this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info); 272 this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini", userInfo);
273 273
274 //send prims that have been created by users 274 //send prims that have been created by users
275 //prim_man.send_existing_prims(User_info); 275 //prim_man.send_existing_prims(User_info);
276 276
277 //send update about clients avatar 277 //send update about clients avatar
278 this.SendInitialAvatarPosition(User_info); 278 this.SendInitialAvatarPosition(userInfo);
279 279
280 //send updates about all other users 280 //send updates about all other users
281 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 281 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList)
282 { 282 {
283 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 283 if(kp.Value.NetInfo.AgentID != userInfo.AgentID)
284 { 284 {
285 this.SendOtherAvatarPosition(User_info,kp.Value); 285 this.SendOtherAvatarPosition(userInfo, kp.Value);
286 } 286 }
287 } 287 }
288 } 288 }
@@ -291,41 +291,40 @@ namespace OpenSim
291 /// 291 ///
292 /// </summary> 292 /// </summary>
293 /// <param name="User_info"></param> 293 /// <param name="User_info"></param>
294 public void SendInitialAvatarPosition(User_Agent_info User_info) 294 public void SendInitialAvatarPosition(UserAgentInfo userInfo)
295 { 295 {
296 //send a objectupdate packet with information about the clients avatar 296 //send a objectupdate packet with information about the clients avatar
297 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 297 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
298 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; 298 objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
299 objupdate.RegionData.TimeDilation=64096; 299 objupdate.RegionData.TimeDilation = 64096;
300 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 300 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
301 301
302 objupdate.ObjectData[0]=AvatarTemplate; 302 objupdate.ObjectData[0] = AvatarTemplate;
303 //give this avatar object a local id and assign the user a name 303 //give this avatar object a local id and assign the user a name
304 objupdate.ObjectData[0].ID=8880000+this.local_numer; 304 objupdate.ObjectData[0].ID = 8880000 + this._localNumber;
305 User_info.localID=objupdate.ObjectData[0].ID; 305 userInfo.localID = objupdate.ObjectData[0].ID;
306 //User_info.name="Test"+this.local_numer+" User"; 306 //User_info.name="Test"+this.local_numer+" User";
307 this.GetAgent(User_info.AgentID).Started=true; 307 this.GetAgent(userInfo.AgentID).Started = true;
308 objupdate.ObjectData[0].FullID=User_info.AgentID; 308 objupdate.ObjectData[0].FullID = userInfo.AgentID;
309 objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"); 309 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0");
310 User_info.name="FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"; 310 userInfo.name = "FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0";
311 //User_info.last_name="User"; 311
312 //User_info.first_name="Test"+this.local_numer; 312 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f);
313 libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); 313
314 314 byte[] pb = pos2.GetBytes();
315 byte[] pb=pos2.GetBytes();
316 315
317 Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); 316 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
318 this.local_numer++; 317 this._localNumber++;
319 318
320 server.SendPacket(objupdate,true,User_info); 319 _server.SendPacket(objupdate, true, userInfo);
321 320
322 //send this info to other existing clients 321 //send this info to other existing clients
323 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 322 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList)
324 { 323 {
325 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 324 if(kp.Value.NetInfo.AgentID != userInfo.AgentID)
326 { 325 {
327 server.SendPacket(objupdate,true,kp.Value.NetInfo); 326 _server.SendPacket(objupdate, true, kp.Value.NetInfo);
328 this.SendOtherAppearance(kp.Value.NetInfo,objupdate.ObjectData[0].FullID); 327 this.SendOtherAppearance(kp.Value.NetInfo, objupdate.ObjectData[0].FullID);
329 } 328 }
330 } 329 }
331 330
@@ -335,38 +334,38 @@ namespace OpenSim
335 /// 334 ///
336 /// </summary> 335 /// </summary>
337 /// <param name="user"></param> 336 /// <param name="user"></param>
338 public void SendIntialAvatarAppearance(User_Agent_info user) 337 public void SendIntialAvatarAppearance(UserAgentInfo userInfo)
339 { 338 {
340 AvatarData Agent=this.AgentList[user.AgentID]; 339 AvatarData Agent = this.AgentList[userInfo.AgentID];
341 AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); 340 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
342 aw.AgentData.AgentID=user.AgentID; 341 aw.AgentData.AgentID = userInfo.AgentID;
343 aw.AgentData.SerialNum=0; 342 aw.AgentData.SerialNum = 0;
344 aw.AgentData.SessionID=user.SessionID; 343 aw.AgentData.SessionID = userInfo.SessionID;
345 344
346 aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; 345 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
347 AgentWearablesUpdatePacket.WearableDataBlock awb=null; 346 AgentWearablesUpdatePacket.WearableDataBlock awb = null;
348 awb=new AgentWearablesUpdatePacket.WearableDataBlock(); 347 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
349 awb.WearableType=(byte)0; 348 awb.WearableType = (byte)0;
350 awb.AssetID=Agent.Wearables[0].AssetID;//new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); 349 awb.AssetID = Agent.Wearables[0].AssetID;
351 awb.ItemID=Agent.Wearables[0].ItemID;//new LLUUID("b7878441893b094917f791174bc8401c"); 350 awb.ItemID = Agent.Wearables[0].ItemID;
352 aw.WearableData[0]=awb; 351 aw.WearableData[0] = awb;
353 352
354 awb=new AgentWearablesUpdatePacket.WearableDataBlock(); 353 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
355 awb.WearableType=(byte)1; 354 awb.WearableType =(byte)1;
356 awb.AssetID=Agent.Wearables[1].AssetID;//new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); 355 awb.AssetID = Agent.Wearables[1].AssetID;
357 awb.ItemID=Agent.Wearables[1].ItemID;//new LLUUID("193f0876fc11d143797454352f9c9c26"); 356 awb.ItemID = Agent.Wearables[1].ItemID;
358 aw.WearableData[1]=awb; 357 aw.WearableData[1] = awb;
359 358
360 for(int i=2; i<13; i++) 359 for(int i=2; i<13; i++)
361 { 360 {
362 awb=new AgentWearablesUpdatePacket.WearableDataBlock(); 361 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
363 awb.WearableType=(byte)i; 362 awb.WearableType = (byte)i;
364 awb.AssetID=new LLUUID("00000000-0000-0000-0000-000000000000"); 363 awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
365 awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); 364 awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
366 aw.WearableData[i]=awb; 365 aw.WearableData[i] = awb;
367 } 366 }
368 367
369 server.SendPacket(aw,true,user); 368 _server.SendPacket(aw, true, userInfo);
370 } 369 }
371 370
372 /// <summary> 371 /// <summary>
@@ -374,34 +373,33 @@ namespace OpenSim
374 /// </summary> 373 /// </summary>
375 /// <param name="user"></param> 374 /// <param name="user"></param>
376 /// <param name="id"></param> 375 /// <param name="id"></param>
377 public void SendOtherAppearance(User_Agent_info user,LLUUID id) 376 public void SendOtherAppearance(UserAgentInfo userInfo, LLUUID id)
378 { 377 {
379 AvatarAppearancePacket avp=new AvatarAppearancePacket(); 378 AvatarAppearancePacket avp = new AvatarAppearancePacket();
380 379
381 380
382 avp.VisualParam=new AvatarAppearancePacket.VisualParamBlock[218]; 381 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
383 //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); 382 //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
384 383
385 FileInfo fInfo = new FileInfo("Avatar_texture3.dat"); 384 FileInfo fInfo = new FileInfo("Avatar_texture3.dat");
386
387 long numBytes = fInfo.Length; 385 long numBytes = fInfo.Length;
388 FileStream fStream = new FileStream("Avatar_texture3.dat", FileMode.Open, FileAccess.Read); 386 FileStream fStream = new FileStream("Avatar_texture3.dat", FileMode.Open, FileAccess.Read);
389 BinaryReader br = new BinaryReader(fStream); 387 BinaryReader br = new BinaryReader(fStream);
390 avp.ObjectData.TextureEntry= br.ReadBytes((int)numBytes); 388 avp.ObjectData.TextureEntry = br.ReadBytes((int)numBytes);
391 br.Close(); 389 br.Close();
392 fStream.Close(); 390 fStream.Close();
393 391
394 AvatarAppearancePacket.VisualParamBlock avblock=null; 392 AvatarAppearancePacket.VisualParamBlock avblock = null;
395 for(int i=0; i<218; i++) 393 for(int i = 0; i < 218; i++)
396 { 394 {
397 avblock=new AvatarAppearancePacket.VisualParamBlock(); 395 avblock = new AvatarAppearancePacket.VisualParamBlock();
398 avblock.ParamValue=(byte)100; 396 avblock.ParamValue = (byte)100;
399 avp.VisualParam[i]=avblock; 397 avp.VisualParam[i] = avblock;
400 } 398 }
401 399
402 avp.Sender.IsTrial=false; 400 avp.Sender.IsTrial = false;
403 avp.Sender.ID=id; 401 avp.Sender.ID = id;
404 server.SendPacket(avp,true,user); 402 _server.SendPacket(avp, true, userInfo);
405 403
406 } 404 }
407 405
@@ -410,29 +408,27 @@ namespace OpenSim
410 /// </summary> 408 /// </summary>
411 /// <param name="User_info"></param> 409 /// <param name="User_info"></param>
412 /// <param name="avd"></param> 410 /// <param name="avd"></param>
413 public void SendOtherAvatarPosition(User_Agent_info User_info, AvatarData avd) 411 public void SendOtherAvatarPosition(UserAgentInfo userInfo, AvatarData avatar)
414 { 412 {
415 //send a objectupdate packet with information about the clients avatar 413 //send a objectupdate packet with information about the clients avatar
416 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 414 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
417 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; 415 objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
418 objupdate.RegionData.TimeDilation=64500; 416 objupdate.RegionData.TimeDilation = 64500;
419 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 417 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
420 418
421 objupdate.ObjectData[0]=AvatarTemplate; 419 objupdate.ObjectData[0] = AvatarTemplate;
422 //give this avatar object a local id and assign the user a name 420 //give this avatar object a local id and assign the user a name
423 objupdate.ObjectData[0].ID=avd.NetInfo.localID; 421 objupdate.ObjectData[0].ID = avatar.NetInfo.localID;
424 objupdate.ObjectData[0].FullID=avd.NetInfo.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); 422 objupdate.ObjectData[0].FullID = avatar.NetInfo.AgentID;
425 objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.NetInfo.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); 423 objupdate.ObjectData[0].NameValue = _enc.GetBytes(avatar.NetInfo.name);
426 libsecondlife.LLVector3 pos2=new LLVector3(avd.Position.X,avd.Position.Y,avd.Position.Z); 424 libsecondlife.LLVector3 pos2 = new LLVector3(avatar.Position.X, avatar.Position.Y, avatar.Position.Z);
427 425
428 byte[] pb=pos2.GetBytes(); 426 byte[] pb = pos2.GetBytes();
429 427 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
430 Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); 428 this._localNumber++;
431 this.local_numer++;
432
433 server.SendPacket(objupdate,true,User_info);
434 429
435 this.SendOtherAppearance(User_info,avd.NetInfo.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); 430 _server.SendPacket(objupdate, true, userInfo);
431 this.SendOtherAppearance(userInfo, avatar.NetInfo.AgentID);
436 432
437 } 433 }
438 434
@@ -441,26 +437,26 @@ namespace OpenSim
441 /// </summary> 437 /// </summary>
442 /// <param name="User_info"></param> 438 /// <param name="User_info"></param>
443 /// <param name="line"></param> 439 /// <param name="line"></param>
444 public void SendChatMessage(User_Agent_info User_info, string line) 440 public void SendChatMessage(UserAgentInfo userInfo, string line)
445 { 441 {
446 libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); 442 libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
447 reply.ChatData.Audible=1; 443 reply.ChatData.Audible = 1;
448 reply.ChatData.Message=enc.GetBytes(line); 444 reply.ChatData.Message = _enc.GetBytes(line);
449 reply.ChatData.ChatType=1; 445 reply.ChatData.ChatType = 1;
450 reply.ChatData.SourceType=1; 446 reply.ChatData.SourceType = 1;
451 reply.ChatData.Position=new LLVector3(120,100,21); //should set to actual position 447 reply.ChatData.Position = new LLVector3(120, 100, 21); //should set to actual position
452 reply.ChatData.FromName=enc.GetBytes(User_info.first_name +" "+User_info.last_name +"\0"); //enc.GetBytes("Echo: \0"); //and actual name 448 reply.ChatData.FromName = _enc.GetBytes(userInfo.first_name + " " + userInfo.last_name + "\0");
453 reply.ChatData.OwnerID=User_info.AgentID; 449 reply.ChatData.OwnerID = userInfo.AgentID;
454 reply.ChatData.SourceID=User_info.AgentID; 450 reply.ChatData.SourceID = userInfo.AgentID;
455 //echo to sender 451 //echo to sender
456 server.SendPacket(reply,true,User_info); 452 _server.SendPacket(reply, true, userInfo);
457 453
458 //send to all users 454 //send to all users
459 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 455 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList)
460 { 456 {
461 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 457 if(kp.Value.NetInfo.AgentID!=userInfo.AgentID)
462 { 458 {
463 server.SendPacket(reply,true,kp.Value.NetInfo); 459 _server.SendPacket(reply, true, kp.Value.NetInfo);
464 } 460 }
465 } 461 }
466 } 462 }
@@ -475,54 +471,54 @@ namespace OpenSim
475 /// <param name="z"></param> 471 /// <param name="z"></param>
476 /// <param name="av_id"></param> 472 /// <param name="av_id"></param>
477 /// <param name="body"></param> 473 /// <param name="body"></param>
478 public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) 474 public void SendMoveCommand(UserAgentInfo userInfo, bool stop, float x, float y, float z, uint avatarID, libsecondlife.LLQuaternion body)
479 { 475 {
480 uint ID=user.localID; 476 Console.WriteLine("sending move");
481 //ID=av_id; 477 uint ID = userInfo.localID;
482 byte[] bytes=new byte[60]; 478 byte[] bytes = new byte[60];
479 int i=0;
483 480
484 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); 481 ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket();
485 im.RegionData.RegionHandle=Globals.Instance.RegionHandle;; 482 im.RegionData.RegionHandle = Globals.Instance.RegionHandle;;
486 im.RegionData.TimeDilation=64096; 483 im.RegionData.TimeDilation = 64096;
487 484
488 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 485 im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
489 int i=0; 486 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
490 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
491 487
492 im.ObjectData[0]=dat; 488 im.ObjectData[0] = dat;
493 489
494 dat.TextureEntry=AvatarTemplate.TextureEntry; 490 dat.TextureEntry = AvatarTemplate.TextureEntry;
495 libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); 491 libsecondlife.LLVector3 pos2 = new LLVector3(x, y, z);
496 492
497 bytes[i++] = (byte)(ID % 256); 493 bytes[i++] = (byte)(ID % 256);
498 bytes[i++] = (byte)((ID >> 8) % 256); 494 bytes[i++] = (byte)((ID >> 8) % 256);
499 bytes[i++] = (byte)((ID >> 16) % 256); 495 bytes[i++] = (byte)((ID >> 16) % 256);
500 bytes[i++] = (byte)((ID >> 24) % 256); 496 bytes[i++] = (byte)((ID >> 24) % 256);
501 497
502 bytes[i++]=0; 498 bytes[i++] = 0;
503 bytes[i++]=1; 499 bytes[i++] = 1;
504 500
505 i+=14; 501 i += 14;
506 bytes[i++]=128; 502 bytes[i++] = 128;
507 bytes[i++]=63; 503 bytes[i++] = 63;
508 byte[] pb=pos2.GetBytes(); 504 byte[] pb = pos2.GetBytes();
509 505
510 Array.Copy(pb,0,bytes,i,pb.Length); 506 Array.Copy(pb, 0, bytes, i, pb.Length);
511 i+=12; 507 i += 12;
512 ushort ac=32767; 508 ushort ac = 32767;
513 Axiom.MathLib.Vector3 v3=new Axiom.MathLib.Vector3(1,0,0); 509 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
514 Axiom.MathLib.Quaternion q=new Axiom.MathLib.Quaternion(body.W,body.X,body.Y,body.Z); 510 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(body.W, body.X, body.Y, body.Z);
515 Axiom.MathLib.Vector3 direc=q*v3; 511 Axiom.MathLib.Vector3 direc = q * v3;
516 direc.Normalize(); 512 direc.Normalize();
517 513
518 direc=direc*(0.03f); 514 direc = direc * (0.03f);
519 direc.x+=1; 515 direc.x += 1;
520 direc.y+=1; 516 direc.y += 1;
521 direc.z+=1; 517 direc.z += 1;
522 ushort dx,dy,dz; 518 ushort dx, dy, dz;
523 dx=(ushort)(32768*direc.x); 519 dx = (ushort)(32768 * direc.x);
524 dy=(ushort)(32768*direc.y); 520 dy = (ushort)(32768 * direc.y);
525 dz=(ushort)(32768*direc.z); 521 dz = (ushort)(32768 * direc.z);
526 522
527 //vel 523 //vel
528 if(!stop) 524 if(!stop)
@@ -582,14 +578,14 @@ namespace OpenSim
582 578
583 dat.Data=bytes; 579 dat.Data=bytes;
584 580
585 server.SendPacket(im,true,user); 581 _server.SendPacket(im, true, userInfo);
586 582
587 //should send to all users. 583 //should send to all users.
588 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 584 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList)
589 { 585 {
590 if(kp.Value.NetInfo.AgentID!=user.AgentID) 586 if(kp.Value.NetInfo.AgentID != userInfo.AgentID)
591 { 587 {
592 server.SendPacket(im,true,kp.Value.NetInfo); 588 _server.SendPacket(im, true, kp.Value.NetInfo);
593 } 589 }
594 } 590 }
595 } 591 }
@@ -600,36 +596,30 @@ namespace OpenSim
600 /// <param name="User_info"></param> 596 /// <param name="User_info"></param>
601 /// <param name="lay"></param> 597 /// <param name="lay"></param>
602 /// <param name="name"></param> 598 /// <param name="name"></param>
603 public void SendLayerData(User_Agent_info User_info,ref LayerDataPacket lay,string name) 599 public void SendLayerData(UserAgentInfo userInfo, ref LayerDataPacket layer, string name)
604 { 600 {
605 FileInfo fInfo = new FileInfo(name); 601 FileInfo fInfo = new FileInfo(name);
606
607 long numBytes = fInfo.Length; 602 long numBytes = fInfo.Length;
608
609 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 603 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
610
611 BinaryReader br = new BinaryReader(fStream); 604 BinaryReader br = new BinaryReader(fStream);
612
613 byte [] data1 = br.ReadBytes((int)numBytes); 605 byte [] data1 = br.ReadBytes((int)numBytes);
614
615 br.Close(); 606 br.Close();
616
617 fStream.Close(); 607 fStream.Close();
618 lay.LayerData.Data=data1; 608 layer.LayerData.Data = data1;
619 server.SendPacket(lay,true,User_info); 609 _server.SendPacket(layer, true, userInfo);
620 //System.Console.WriteLine("sent"); 610
621 } 611 }
622 } 612 }
623 613
624 public class AvatarData 614 public class AvatarData
625 { 615 {
626 public User_Agent_info NetInfo; 616 public UserAgentInfo NetInfo;
627 public LLUUID FullID; 617 public LLUUID FullID;
628 public LLVector3 Position; 618 public LLVector3 Position;
629 public LLVector3 Velocity=new LLVector3(0,0,0); 619 public LLVector3 Velocity = new LLVector3(0,0,0);
630 //public LLQuaternion Rotation; 620 //public LLQuaternion Rotation;
631 public bool Walk=false; 621 public bool Walk = false;
632 public bool Started=false; 622 public bool Started = false;
633 //public TextureEntry TextureEntry; 623 //public TextureEntry TextureEntry;
634 public AvatarWearable[] Wearables; 624 public AvatarWearable[] Wearables;
635 public LLUUID InventoryFolder; 625 public LLUUID InventoryFolder;
@@ -638,9 +628,9 @@ namespace OpenSim
638 public AvatarData() 628 public AvatarData()
639 { 629 {
640 Wearables=new AvatarWearable[2]; //should be 13 630 Wearables=new AvatarWearable[2]; //should be 13
641 for(int i=0; i<2; i++) 631 for(int i = 0; i < 2; i++)
642 { 632 {
643 Wearables[i]=new AvatarWearable(); 633 Wearables[i] = new AvatarWearable();
644 } 634 }
645 } 635 }
646 } 636 }