aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prim_manager.cs
diff options
context:
space:
mode:
authorMW2007-02-02 17:23:56 +0000
committerMW2007-02-02 17:23:56 +0000
commite75e6f426bfc069e9185c8c72e8707399edfe299 (patch)
tree0700369d4d568eed609709abe0c4442637538218 /Prim_manager.cs
parentClean up (diff)
downloadopensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.zip
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.gz
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.bz2
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.xz
Clean up. Added GridManager and teleport between regions/sims.
Diffstat (limited to 'Prim_manager.cs')
-rw-r--r--Prim_manager.cs237
1 files changed, 165 insertions, 72 deletions
diff --git a/Prim_manager.cs b/Prim_manager.cs
index da1d626..1dc075b 100644
--- a/Prim_manager.cs
+++ b/Prim_manager.cs
@@ -35,53 +35,63 @@ using libsecondlife.AssetSystem;
35using System.IO; 35using System.IO;
36using Axiom.MathLib; 36using Axiom.MathLib;
37 37
38namespace Second_server 38namespace OpenSim
39{ 39{
40 /// <summary> 40 /// <summary>
41 /// Description of Prim_manager. 41 /// Description of Prim_manager.
42 /// </summary> 42 /// </summary>
43 public class Prim_manager 43 public class PrimManager
44 { 44 {
45 private Server server; 45 private Server server;
46 public Agent_Manager agent_man; 46 public AgentManager Agent_Manager;
47 47
48 private uint prim_count; 48 private uint prim_count;
49 49
50 public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock object_template; 50 public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate;
51 public Dictionary<libsecondlife.LLUUID,prim_info> Prim_list; 51 public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList;
52 public Prim_manager(Server serve) 52
53 /// <summary>
54 ///
55 /// </summary>
56 /// <param name="serve"></param>
57 public PrimManager(Server serve)
53 { 58 {
54 server=serve; 59 server=serve;
55 Prim_list=new Dictionary<libsecondlife.LLUUID,prim_info> (); 60 PrimList=new Dictionary<libsecondlife.LLUUID,PrimInfo> ();
56 this.setuptemplates("objectupate164.dat"); 61 this.SetupTemplates("objectupate164.dat");
62
57 } 63 }
58 64
59 65 /// <summary>
60 //********************************************************************* 66 ///
61 public void create_prim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) 67 /// </summary>
68 /// <param name="User_info"></param>
69 /// <param name="p1"></param>
70 /// <param name="add_pack"></param>
71 public void CreatePrim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack)
62 { 72 {
63 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 73 ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
64 objupdate.RegionData.RegionHandle=1096213093147648; 74 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
65 objupdate.RegionData.TimeDilation=64096; 75 objupdate.RegionData.TimeDilation=64096;
66 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 76 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
67 77 PrimData PData=new PrimData();
68 objupdate.ObjectData[0]=this.object_template; 78 objupdate.ObjectData[0]=this.PrimTemplate;
69 objupdate.ObjectData[0].OwnerID=User_info.AgentID; 79 PData.OwnerID=objupdate.ObjectData[0].OwnerID=User_info.AgentID;
70 objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; 80 PData.PCode=objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode;
71 objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; 81 PData.PathBegin=objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin;
72 objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; 82 PData.PathEnd=objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd;
73 objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; 83 PData.PathScaleX=objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX;
74 objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; 84 PData.PathScaleY=objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY;
75 objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; 85 PData.PathShearX=objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX;
76 objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; 86 PData.PathShearY=objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY;
77 objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; 87 PData.PathSkew=objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew;
78 objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; 88 PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin;
79 objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; 89 PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd;
80 objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); 90 PData.Scale=objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1);
81 objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; 91 PData.PathCurve=objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve;
82 objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; 92 PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve;
83 objupdate.ObjectData[0].ParentID=0; 93 PData.ParentID=objupdate.ObjectData[0].ParentID=0;
84 objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; 94 PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow;
85 //finish off copying rest of shape data 95 //finish off copying rest of shape data
86 96
87 objupdate.ObjectData[0].ID=(uint)(702000+prim_count); 97 objupdate.ObjectData[0].ID=(uint)(702000+prim_count);
@@ -95,30 +105,40 @@ namespace Second_server
95 server.SendPacket(objupdate,true,User_info); 105 server.SendPacket(objupdate,true,User_info);
96 106
97 //should send to all users 107 //should send to all users
98 foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) 108 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList)
99 { 109 {
100 if(kp.Value.Net_info.AgentID!=User_info.AgentID) 110 if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
101 { 111 {
102 server.SendPacket(objupdate,true,kp.Value.Net_info); 112 server.SendPacket(objupdate,true,kp.Value.NetInfo);
103 } 113 }
104 } 114 }
105 //should store this infomation 115 //should store this infomation
106 prim_info n_prim=new prim_info(); 116 PrimInfo NewPrim=new PrimInfo();
107 n_prim.full_ID=objupdate.ObjectData[0].FullID; 117 NewPrim.FullID=objupdate.ObjectData[0].FullID;
108 n_prim.local_ID=objupdate.ObjectData[0].ID; 118 NewPrim.LocalID=objupdate.ObjectData[0].ID;
109 n_prim.pos=p1; 119 NewPrim.Position=p1;
120 NewPrim.data=PData;
110 121
111 this.Prim_list.Add(n_prim.full_ID,n_prim); 122 this.PrimList.Add(NewPrim.FullID,NewPrim);
112 123
113 //store rest of data 124 //store rest of data
114 125
115 } 126 }
116 public void update_prim_position(User_Agent_info user,float x, float y, float z,uint l_id) 127
128 /// <summary>
129 ///
130 /// </summary>
131 /// <param name="User"></param>
132 /// <param name="position"></param>
133 /// <param name="LocalID"></param>
134 /// <param name="setRotation"></param>
135 /// <param name="rotation"></param>
136 public void UpdatePrimPosition(User_Agent_info User,LLVector3 position,uint LocalID,bool setRotation, LLQuaternion rotation)
117 { 137 {
118 prim_info pri=null; 138 PrimInfo pri=null;
119 foreach (KeyValuePair<libsecondlife.LLUUID,prim_info> kp in this.Prim_list) 139 foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList)
120 { 140 {
121 if(kp.Value.local_ID==l_id) 141 if(kp.Value.LocalID==LocalID)
122 { 142 {
123 pri=kp.Value; 143 pri=kp.Value;
124 } 144 }
@@ -127,18 +147,37 @@ namespace Second_server
127 { 147 {
128 return; 148 return;
129 } 149 }
130 uint ID=pri.local_ID; 150 uint ID=pri.LocalID;
151 libsecondlife.LLVector3 pos2=new LLVector3(position.X,position.Y,position.Z);
152 libsecondlife.LLQuaternion rotation2;
153 if(!setRotation)
154 {
155 pri.Position=pos2;
156 rotation2=new LLQuaternion(pri.Rotation.X,pri.Rotation.Y,pri.Rotation.Z,pri.Rotation.W);
157 }
158 else
159 {
160 rotation2=new LLQuaternion(rotation.X,rotation.Y,rotation.Z,rotation.W);
161
162 pos2=pri.Position;
163 pri.Rotation=rotation;
164 }
165 rotation2.W+=1;
166 rotation2.X+=1;
167 rotation2.Y+=1;
168 rotation2.Z+=1;
169
131 byte[] bytes=new byte[60]; 170 byte[] bytes=new byte[60];
132 171
133 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); 172 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket();
134 im.RegionData.RegionHandle=1096213093147648; 173 im.RegionData.RegionHandle=Globals.Instance.RegionHandle;
135 im.RegionData.TimeDilation=64096; 174 im.RegionData.TimeDilation=64096;
136 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 175 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
137 int i=0; 176 int i=0;
138 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 177 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
139 im.ObjectData[0]=dat; 178 im.ObjectData[0]=dat;
140 dat.TextureEntry=object_template.TextureEntry; 179 dat.TextureEntry=PrimTemplate.TextureEntry;
141 libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); 180 //System.Console.WriteLine("new position is :"+position);
142 181
143 bytes[i++] = (byte)(ID % 256); 182 bytes[i++] = (byte)(ID % 256);
144 bytes[i++] = (byte)((ID >> 8) % 256); 183 bytes[i++] = (byte)((ID >> 8) % 256);
@@ -151,7 +190,7 @@ namespace Second_server
151 // bytes[i++]=128; 190 // bytes[i++]=128;
152 // bytes[i++]=63; 191 // bytes[i++]=63;
153 byte[] pb=pos2.GetBytes(); 192 byte[] pb=pos2.GetBytes();
154 pri.pos=pos2; 193 pri.Position=pos2;
155 Array.Copy(pb,0,bytes,i,pb.Length); 194 Array.Copy(pb,0,bytes,i,pb.Length);
156 i+=12; 195 i+=12;
157 ushort ac=32767; 196 ushort ac=32767;
@@ -172,7 +211,27 @@ namespace Second_server
172 bytes[i++] = (byte)(ac % 256); 211 bytes[i++] = (byte)(ac % 256);
173 bytes[i++] = (byte)((ac >> 8) % 256); 212 bytes[i++] = (byte)((ac >> 8) % 256);
174 213
214 //if(setRotation)
215 //{
216
217 ushort rw, rx,ry,rz;
218 rw=(ushort)(32768*rotation2.W);
219 rx=(ushort)(32768*rotation2.X);
220 ry=(ushort)(32768*rotation2.Y);
221 rz=(ushort)(32768*rotation2.Z);
222
175 //rot 223 //rot
224 bytes[i++] = (byte)(rx % 256);
225 bytes[i++] = (byte)((rx >> 8) % 256);
226 bytes[i++] = (byte)(ry % 256);
227 bytes[i++] = (byte)((ry >> 8) % 256);
228 bytes[i++] = (byte)(rz % 256);
229 bytes[i++] = (byte)((rz >> 8) % 256);
230 bytes[i++] = (byte)(rw % 256);
231 bytes[i++] = (byte)((rw >> 8) % 256);
232 //}
233 /*else
234 {
176 bytes[i++] = (byte)(ac % 256); 235 bytes[i++] = (byte)(ac % 256);
177 bytes[i++] = (byte)((ac >> 8) % 256); 236 bytes[i++] = (byte)((ac >> 8) % 256);
178 bytes[i++] = (byte)(ac % 256); 237 bytes[i++] = (byte)(ac % 256);
@@ -181,7 +240,7 @@ namespace Second_server
181 bytes[i++] = (byte)((ac >> 8) % 256); 240 bytes[i++] = (byte)((ac >> 8) % 256);
182 bytes[i++] = (byte)(ac % 256); 241 bytes[i++] = (byte)(ac % 256);
183 bytes[i++] = (byte)((ac >> 8) % 256); 242 bytes[i++] = (byte)((ac >> 8) % 256);
184 243 }*/
185 //rotation vel 244 //rotation vel
186 bytes[i++] = (byte)(ac % 256); 245 bytes[i++] = (byte)(ac % 256);
187 bytes[i++] = (byte)((ac >> 8) % 256); 246 bytes[i++] = (byte)((ac >> 8) % 256);
@@ -193,23 +252,32 @@ namespace Second_server
193 dat.Data=bytes; 252 dat.Data=bytes;
194 //server.SendPacket(im,true,user); 253 //server.SendPacket(im,true,user);
195 //should send to all users. 254 //should send to all users.
196 foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) 255 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList)
197 { 256 {
198 if(kp.Value.Net_info.AgentID!=user.AgentID) 257 if(kp.Value.NetInfo.AgentID!=User.AgentID)
199 { 258 {
200 server.SendPacket(im,true,kp.Value.Net_info); 259 server.SendPacket(im,true,kp.Value.NetInfo);
201 } 260 }
202 } 261 }
203 } 262 }
204 public void send_existing_prims(User_Agent_info user) 263
264 /// <summary>
265 ///
266 /// </summary>
267 /// <param name="user"></param>
268 public void SendExistingPrims(User_Agent_info user)
205 { 269 {
206 //send data for already created prims to a new joining user 270 //send data for already created prims to a new joining user
207 } 271 }
208 //************************************************************** 272
209 public void setuptemplates(string name) 273 /// <summary>
274 ///
275 /// </summary>
276 /// <param name="name"></param>
277 public void SetupTemplates(string name)
210 { 278 {
211 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 279 ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
212 objupdate.RegionData.RegionHandle=1096213093147648; 280 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
213 objupdate.RegionData.TimeDilation=64096; 281 objupdate.RegionData.TimeDilation=64096;
214 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; 282 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
215 283
@@ -224,7 +292,7 @@ namespace Second_server
224 292
225 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); 293 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i);
226 objupdate.ObjectData[0]=objdata; 294 objupdate.ObjectData[0]=objdata;
227 this.object_template=objdata; 295 this.PrimTemplate=objdata;
228 objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; 296 objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256;
229 objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); 297 objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000");
230 //test adding a new texture to object , to test image downloading 298 //test adding a new texture to object , to test image downloading
@@ -235,8 +303,13 @@ namespace Second_server
235 303
236 objdata.TextureEntry=ntex.ToBytes(); 304 objdata.TextureEntry=ntex.ToBytes();
237 } 305 }
238 //******************************************************************** 306
239 public void Read_Prim_database(string name,User_Agent_info user) 307 /// <summary>
308 ///
309 /// </summary>
310 /// <param name="name"></param>
311 /// <param name="user"></param>
312 public void ReadPrimDatabase(string name,User_Agent_info user)
240 { 313 {
241 StreamReader SR; 314 StreamReader SR;
242 string line; 315 string line;
@@ -253,7 +326,7 @@ namespace Second_server
253 int num=Convert.ToInt32(comp[2]); 326 int num=Convert.ToInt32(comp[2]);
254 int start=Convert.ToInt32(comp[1]); 327 int start=Convert.ToInt32(comp[1]);
255 ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 328 ObjectUpdatePacket objupdate=new ObjectUpdatePacket();
256 objupdate.RegionData.RegionHandle=1096213093147648; 329 objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle;
257 objupdate.RegionData.TimeDilation=64096; 330 objupdate.RegionData.TimeDilation=64096;
258 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; 331 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num];
259 332
@@ -285,24 +358,44 @@ namespace Second_server
285 } 358 }
286 } 359 }
287 360
288 public class prim_info 361 public class PrimInfo
289 { 362 {
290 public LLVector3 pos; 363 public LLVector3 Position;
291 public LLVector3 vel; 364 public LLVector3 Velocity;
292 public uint local_ID; 365 public LLQuaternion Rotation=LLQuaternion.Identity;
293 public LLUUID full_ID; 366 public uint LocalID;
294 public prim_data data; 367 public LLUUID FullID;
368 public PrimData data;
295 369
296 public prim_info() 370 public PrimInfo()
297 { 371 {
298 pos=new LLVector3(0,0,0); 372 Position=new LLVector3(0,0,0);
299 vel=new LLVector3(0,0,0); 373 Velocity=new LLVector3(0,0,0);
300 data=new prim_data(); 374 //data=new PrimData();
301 } 375 }
302 } 376 }
303 public class prim_data 377 public class PrimData
304 { 378 {
305 public prim_data() 379 public LLUUID OwnerID;
380 public byte PCode;
381 public byte PathBegin;
382 public byte PathEnd;
383 public byte PathScaleX;
384 public byte PathScaleY;
385 public byte PathShearX;
386 public byte PathShearY;
387 public sbyte PathSkew;
388 public byte ProfileBegin;
389 public byte ProfileEnd;
390 public LLVector3 Scale;
391 public byte PathCurve;
392 public byte ProfileCurve;
393 public uint ParentID=0;
394 public byte ProfileHollow;
395
396 public bool DataBaseStorage=false;
397
398 public PrimData()
306 { 399 {
307 400
308 } 401 }