aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prim_manager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Prim_manager.cs236
1 files changed, 118 insertions, 118 deletions
diff --git a/Prim_manager.cs b/Prim_manager.cs
index 856bffe..aa1c32a 100644
--- a/Prim_manager.cs
+++ b/Prim_manager.cs
@@ -40,11 +40,10 @@ namespace OpenSim
40 /// </summary> 40 /// </summary>
41 public class PrimManager 41 public class PrimManager
42 { 42 {
43 private Server server; 43 private Server _server;
44 public AgentManager Agent_Manager; 44 private uint _primCount;
45
46 private uint prim_count;
47 45
46 public AgentManager AgentManagement;
48 public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate; 47 public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate;
49 public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList; 48 public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList;
50 49
@@ -52,10 +51,10 @@ namespace OpenSim
52 /// 51 ///
53 /// </summary> 52 /// </summary>
54 /// <param name="serve"></param> 53 /// <param name="serve"></param>
55 public PrimManager(Server serve) 54 public PrimManager(Server server)
56 { 55 {
57 server=serve; 56 _server = server;
58 PrimList=new Dictionary<libsecondlife.LLUUID,PrimInfo> (); 57 PrimList = new Dictionary<libsecondlife.LLUUID,PrimInfo> ();
59 this.SetupTemplates("objectupate164.dat"); 58 this.SetupTemplates("objectupate164.dat");
60 59
61 } 60 }
@@ -66,58 +65,59 @@ namespace OpenSim
66 /// <param name="User_info"></param> 65 /// <param name="User_info"></param>
67 /// <param name="p1"></param> 66 /// <param name="p1"></param>
68 /// <param name="add_pack"></param> 67 /// <param name="add_pack"></param>
69 public void CreatePrim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) 68 public void CreatePrim(UserAgentInfo userInfo, libsecondlife.LLVector3 pos1, ObjectAddPacket addPacket)
70 { 69 {
71 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 70 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
72 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; 71 objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
73 objupdate.RegionData.TimeDilation=64096; 72 objupdate.RegionData.TimeDilation = 64096;
74 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 73
75 PrimData PData=new PrimData(); 74 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
76 objupdate.ObjectData[0]=this.PrimTemplate; 75 PrimData PData = new PrimData();
77 PData.OwnerID=objupdate.ObjectData[0].OwnerID=User_info.AgentID; 76 objupdate.ObjectData[0] = this.PrimTemplate;
78 PData.PCode=objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; 77 PData.OwnerID=objupdate.ObjectData[0].OwnerID = userInfo.AgentID;
79 PData.PathBegin=objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; 78 PData.PCode=objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
80 PData.PathEnd=objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; 79 PData.PathBegin=objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
81 PData.PathScaleX=objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; 80 PData.PathEnd=objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
82 PData.PathScaleY=objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; 81 PData.PathScaleX=objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
83 PData.PathShearX=objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; 82 PData.PathScaleY=objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
84 PData.PathShearY=objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; 83 PData.PathShearX=objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
85 PData.PathSkew=objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; 84 PData.PathShearY=objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
86 PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; 85 PData.PathSkew=objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
87 PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; 86 PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
88 PData.Scale=objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); 87 PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
89 PData.PathCurve=objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; 88 PData.Scale=objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
90 PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; 89 PData.PathCurve=objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
91 PData.ParentID=objupdate.ObjectData[0].ParentID=0; 90 PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
92 PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; 91 PData.ParentID=objupdate.ObjectData[0].ParentID = 0;
92 PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
93 //finish off copying rest of shape data 93 //finish off copying rest of shape data
94 94
95 objupdate.ObjectData[0].ID=(uint)(702000+prim_count); 95 objupdate.ObjectData[0].ID = (uint)(702000 + _primCount);
96 objupdate.ObjectData[0].FullID=new LLUUID("edba7151-5857-acc5-b30b-f01efefda"+prim_count.ToString("000")); 96 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda"+_primCount.ToString("000"));
97 97
98 //update position 98 //update position
99 byte[] pb=p1.GetBytes(); 99 byte[] pb = pos1.GetBytes();
100 Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,0,pb.Length); 100 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
101 101
102 prim_count++; 102 _primCount++;
103 server.SendPacket(objupdate,true,User_info); 103 _server.SendPacket(objupdate, true, userInfo);
104 104
105 //should send to all users 105 //should send to all users
106 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) 106 foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in AgentManagement.AgentList)
107 { 107 {
108 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 108 if(kp.Value.NetInfo.AgentID != userInfo.AgentID)
109 { 109 {
110 server.SendPacket(objupdate,true,kp.Value.NetInfo); 110 _server.SendPacket(objupdate, true, kp.Value.NetInfo);
111 } 111 }
112 } 112 }
113 //should store this infomation 113 //should store this infomation
114 PrimInfo NewPrim=new PrimInfo(); 114 PrimInfo NewPrim = new PrimInfo();
115 NewPrim.FullID=objupdate.ObjectData[0].FullID; 115 NewPrim.FullID = objupdate.ObjectData[0].FullID;
116 NewPrim.LocalID=objupdate.ObjectData[0].ID; 116 NewPrim.LocalID = objupdate.ObjectData[0].ID;
117 NewPrim.Position=p1; 117 NewPrim.Position = pos1;
118 NewPrim.data=PData; 118 NewPrim.Data = PData;
119 119
120 this.PrimList.Add(NewPrim.FullID,NewPrim); 120 this.PrimList.Add(NewPrim.FullID, NewPrim);
121 121
122 //store rest of data 122 //store rest of data
123 123
@@ -131,62 +131,62 @@ namespace OpenSim
131 /// <param name="LocalID"></param> 131 /// <param name="LocalID"></param>
132 /// <param name="setRotation"></param> 132 /// <param name="setRotation"></param>
133 /// <param name="rotation"></param> 133 /// <param name="rotation"></param>
134 public void UpdatePrimPosition(User_Agent_info User,LLVector3 position,uint LocalID,bool setRotation, LLQuaternion rotation) 134 public void UpdatePrimPosition(UserAgentInfo userInfo, LLVector3 position, uint localID, bool setRotation, LLQuaternion rotation)
135 { 135 {
136 PrimInfo pri=null; 136 PrimInfo pri = null;
137 foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList) 137 foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList)
138 { 138 {
139 if(kp.Value.LocalID==LocalID) 139 if(kp.Value.LocalID == localID)
140 { 140 {
141 pri=kp.Value; 141 pri = kp.Value;
142 } 142 }
143 } 143 }
144 if(pri==null) 144 if(pri == null)
145 { 145 {
146 return; 146 return;
147 } 147 }
148 uint ID=pri.LocalID; 148 uint ID = pri.LocalID;
149 libsecondlife.LLVector3 pos2=new LLVector3(position.X,position.Y,position.Z); 149 libsecondlife.LLVector3 pos2 = new LLVector3(position.X, position.Y, position.Z);
150 libsecondlife.LLQuaternion rotation2; 150 libsecondlife.LLQuaternion rotation2;
151 if(!setRotation) 151 if(!setRotation)
152 { 152 {
153 pri.Position=pos2; 153 pri.Position = pos2;
154 rotation2=new LLQuaternion(pri.Rotation.X,pri.Rotation.Y,pri.Rotation.Z,pri.Rotation.W); 154 rotation2 = new LLQuaternion(pri.Rotation.X, pri.Rotation.Y, pri.Rotation.Z, pri.Rotation.W);
155 } 155 }
156 else 156 else
157 { 157 {
158 rotation2=new LLQuaternion(rotation.X,rotation.Y,rotation.Z,rotation.W); 158 rotation2=new LLQuaternion(rotation.X, rotation.Y, rotation.Z, rotation.W);
159 pos2=pri.Position; 159 pos2 = pri.Position;
160 pri.Rotation=rotation; 160 pri.Rotation = rotation;
161 } 161 }
162 rotation2.W+=1; 162 rotation2.W += 1;
163 rotation2.X+=1; 163 rotation2.X += 1;
164 rotation2.Y+=1; 164 rotation2.Y += 1;
165 rotation2.Z+=1; 165 rotation2.Z += 1;
166 166
167 byte[] bytes=new byte[60]; 167 byte[] bytes = new byte[60];
168 168
169 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); 169 ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket();
170 im.RegionData.RegionHandle=Globals.Instance.RegionHandle; 170 im.RegionData.RegionHandle = Globals.Instance.RegionHandle;
171 im.RegionData.TimeDilation=64096; 171 im.RegionData.TimeDilation = 64096;
172 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 172 im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
173 int i=0; 173 int i = 0;
174 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 174 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
175 im.ObjectData[0]=dat; 175 im.ObjectData[0] = dat;
176 dat.TextureEntry=PrimTemplate.TextureEntry; 176 dat.TextureEntry = PrimTemplate.TextureEntry;
177 177
178 bytes[i++] = (byte)(ID % 256); 178 bytes[i++] = (byte)(ID % 256);
179 bytes[i++] = (byte)((ID >> 8) % 256); 179 bytes[i++] = (byte)((ID >> 8) % 256);
180 bytes[i++] = (byte)((ID >> 16) % 256); 180 bytes[i++] = (byte)((ID >> 16) % 256);
181 bytes[i++] = (byte)((ID >> 24) % 256); 181 bytes[i++] = (byte)((ID >> 24) % 256);
182 bytes[i++]=0; 182 bytes[i++]= 0;
183 bytes[i++]=0;//1; 183 bytes[i++]= 0;
184 184
185 byte[] pb=pos2.GetBytes(); 185 byte[] pb = pos2.GetBytes();
186 pri.Position=pos2; 186 pri.Position = pos2;
187 Array.Copy(pb,0,bytes,i,pb.Length); 187 Array.Copy(pb, 0, bytes, i, pb.Length);
188 i+=12; 188 i += 12;
189 ushort ac=32767; 189 ushort ac = 32767;
190 190
191 //vel 191 //vel
192 bytes[i++] = (byte)(ac % 256); 192 bytes[i++] = (byte)(ac % 256);
@@ -205,10 +205,10 @@ namespace OpenSim
205 bytes[i++] = (byte)((ac >> 8) % 256); 205 bytes[i++] = (byte)((ac >> 8) % 256);
206 206
207 ushort rw, rx,ry,rz; 207 ushort rw, rx,ry,rz;
208 rw=(ushort)(32768*rotation2.W); 208 rw = (ushort)(32768 * rotation2.W);
209 rx=(ushort)(32768*rotation2.X); 209 rx = (ushort)(32768 * rotation2.X);
210 ry=(ushort)(32768*rotation2.Y); 210 ry = (ushort)(32768 * rotation2.Y);
211 rz=(ushort)(32768*rotation2.Z); 211 rz = (ushort)(32768 * rotation2.Z);
212 212
213 //rot 213 //rot
214 bytes[i++] = (byte)(rx % 256); 214 bytes[i++] = (byte)(rx % 256);
@@ -230,11 +230,11 @@ namespace OpenSim
230 230
231 dat.Data=bytes; 231 dat.Data=bytes;
232 232
233 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) 233 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in AgentManagement.AgentList)
234 { 234 {
235 if(kp.Value.NetInfo.AgentID!=User.AgentID) 235 if(kp.Value.NetInfo.AgentID!=userInfo.AgentID)
236 { 236 {
237 server.SendPacket(im,true,kp.Value.NetInfo); 237 _server.SendPacket(im, true, kp.Value.NetInfo);
238 } 238 }
239 } 239 }
240 } 240 }
@@ -243,7 +243,7 @@ namespace OpenSim
243 /// 243 ///
244 /// </summary> 244 /// </summary>
245 /// <param name="user"></param> 245 /// <param name="user"></param>
246 public void SendExistingPrims(User_Agent_info user) 246 public void SendExistingPrims(UserAgentInfo userInfo)
247 { 247 {
248 //send data for already created prims to a new joining user 248 //send data for already created prims to a new joining user
249 } 249 }
@@ -254,12 +254,12 @@ namespace OpenSim
254 /// <param name="name"></param> 254 /// <param name="name"></param>
255 public void SetupTemplates(string name) 255 public void SetupTemplates(string name)
256 { 256 {
257 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 257 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
258 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; 258 objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
259 objupdate.RegionData.TimeDilation=64096; 259 objupdate.RegionData.TimeDilation = 64096;
260 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 260 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
261 261
262 int i=0; 262 int i = 0;
263 FileInfo fInfo = new FileInfo(name); 263 FileInfo fInfo = new FileInfo(name);
264 long numBytes = fInfo.Length; 264 long numBytes = fInfo.Length;
265 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 265 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
@@ -268,18 +268,18 @@ namespace OpenSim
268 br.Close(); 268 br.Close();
269 fStream.Close(); 269 fStream.Close();
270 270
271 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); 271 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i);
272 objupdate.ObjectData[0]=objdata; 272 objupdate.ObjectData[0] = objdata;
273 this.PrimTemplate=objdata; 273 this.PrimTemplate = objdata;
274 objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; 274 objdata.UpdateFlags = objdata.UpdateFlags + 12 - 16 + 32 + 256;
275 objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); 275 objdata.OwnerID = new LLUUID("00000000-0000-0000-0000-000000000000");
276 //test adding a new texture to object , to test image downloading 276 //test adding a new texture to object , to test image downloading
277 LLObject.TextureEntry te=new LLObject.TextureEntry(objdata.TextureEntry,0,objdata.TextureEntry.Length); 277 LLObject.TextureEntry te = new LLObject.TextureEntry(objdata.TextureEntry, 0, objdata.TextureEntry.Length);
278 te.DefaultTexture.TextureID=new LLUUID("00000000-0000-0000-5005-000000000005"); 278 te.DefaultTexture.TextureID = new LLUUID("00000000-0000-0000-5005-000000000005");
279 279
280 LLObject.TextureEntry ntex=new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 280 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
281 281
282 objdata.TextureEntry=ntex.ToBytes(); 282 objdata.TextureEntry = ntex.ToBytes();
283 } 283 }
284 284
285 /// <summary> 285 /// <summary>
@@ -287,34 +287,34 @@ namespace OpenSim
287 /// </summary> 287 /// </summary>
288 /// <param name="name"></param> 288 /// <param name="name"></param>
289 /// <param name="user"></param> 289 /// <param name="user"></param>
290 public void ReadPrimDatabase(string name,User_Agent_info user) 290 public void ReadPrimDatabase(string name, UserAgentInfo userInfo)
291 { 291 {
292 StreamReader SR; 292 StreamReader SR;
293 string line; 293 string line;
294 SR=File.OpenText(name); 294 SR=File.OpenText(name);
295 string [] comp= new string[10]; 295 string [] comp = new string[10];
296 string delimStr = " , "; 296 string delimStr = " , ";
297 char [] delimiter = delimStr.ToCharArray(); 297 char [] delimiter = delimStr.ToCharArray();
298 298
299 line=SR.ReadLine(); 299 line=SR.ReadLine();
300 while(line!="end") 300 while(line != "end")
301 { 301 {
302 comp=line.Split(delimiter); 302 comp = line.Split(delimiter);
303 if(comp[0]=="ObjPack") 303 if(comp[0] == "ObjPack")
304 { 304 {
305 int num=Convert.ToInt32(comp[2]); 305 int num = Convert.ToInt32(comp[2]);
306 int start=Convert.ToInt32(comp[1]); 306 int start = Convert.ToInt32(comp[1]);
307 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 307 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
308 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; 308 objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
309 objupdate.RegionData.TimeDilation=64096; 309 objupdate.RegionData.TimeDilation = 64096;
310 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; 310 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num];
311 311
312 // int count=0; 312 // int count=0;
313 string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\data\"; 313 string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\data\";
314 for(int cc=0; cc<num; cc++) 314 for(int cc = 0; cc < num; cc++)
315 { 315 {
316 string filenam=data_path+@"prim_updates"+start+".dat"; 316 string filenam = data_path+@"prim_updates"+start+".dat";
317 int i=0; 317 int i = 0;
318 //FileInfo fInfo = new FileInfo("objectupate"+start+".dat"); 318 //FileInfo fInfo = new FileInfo("objectupate"+start+".dat");
319 FileInfo fInfo = new FileInfo(filenam); 319 FileInfo fInfo = new FileInfo(filenam);
320 long numBytes = fInfo.Length; 320 long numBytes = fInfo.Length;
@@ -325,12 +325,12 @@ namespace OpenSim
325 br.Close(); 325 br.Close();
326 fStream.Close(); 326 fStream.Close();
327 327
328 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); 328 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
329 objupdate.ObjectData[cc]=objdata; 329 objupdate.ObjectData[cc] = objdata;
330 start++; 330 start++;
331 } 331 }
332 server.SendPacket(objupdate,true,user); 332 _server.SendPacket(objupdate, true, userInfo);
333 line=SR.ReadLine(); 333 line = SR.ReadLine();
334 } 334 }
335 } 335 }
336 SR.Close(); 336 SR.Close();
@@ -344,7 +344,7 @@ namespace OpenSim
344 public LLQuaternion Rotation=LLQuaternion.Identity; 344 public LLQuaternion Rotation=LLQuaternion.Identity;
345 public uint LocalID; 345 public uint LocalID;
346 public LLUUID FullID; 346 public LLUUID FullID;
347 public PrimData data; 347 public PrimData Data;
348 348
349 public PrimInfo() 349 public PrimInfo()
350 { 350 {