diff options
author | MW | 2007-02-03 21:09:54 +0000 |
---|---|---|
committer | MW | 2007-02-03 21:09:54 +0000 |
commit | dc2316de9c7a7168263e7a367b4c69189f9bc232 (patch) | |
tree | 57b639a77d585f5ded98f283d24a02617faf5b1a /Prim_manager.cs | |
parent | (no commit message) (diff) | |
download | opensim-SC-dc2316de9c7a7168263e7a367b4c69189f9bc232.zip opensim-SC-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.gz opensim-SC-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.bz2 opensim-SC-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.xz |
Basic Inventory support and clean up
Diffstat (limited to 'Prim_manager.cs')
-rw-r--r-- | Prim_manager.cs | 305 |
1 files changed, 143 insertions, 162 deletions
diff --git a/Prim_manager.cs b/Prim_manager.cs index 56eccfc..856bffe 100644 --- a/Prim_manager.cs +++ b/Prim_manager.cs | |||
@@ -133,130 +133,110 @@ namespace OpenSim | |||
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(User_Agent_info User,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 | 159 | pos2=pri.Position; | |
160 | pos2=pri.Position; | 160 | pri.Rotation=rotation; |
161 | pri.Rotation=rotation; | 161 | } |
162 | } | 162 | rotation2.W+=1; |
163 | rotation2.W+=1; | 163 | rotation2.X+=1; |
164 | rotation2.X+=1; | 164 | rotation2.Y+=1; |
165 | rotation2.Y+=1; | 165 | rotation2.Z+=1; |
166 | rotation2.Z+=1; | 166 | |
167 | 167 | byte[] bytes=new byte[60]; | |
168 | byte[] bytes=new byte[60]; | 168 | |
169 | 169 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); | |
170 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); | 170 | im.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
171 | im.RegionData.RegionHandle=Globals.Instance.RegionHandle; | 171 | im.RegionData.TimeDilation=64096; |
172 | im.RegionData.TimeDilation=64096; | 172 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
173 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 173 | int i=0; |
174 | int i=0; | 174 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); |
175 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | 175 | im.ObjectData[0]=dat; |
176 | im.ObjectData[0]=dat; | 176 | dat.TextureEntry=PrimTemplate.TextureEntry; |
177 | dat.TextureEntry=PrimTemplate.TextureEntry; | 177 | |
178 | //System.Console.WriteLine("new position is :"+position); | 178 | bytes[i++] = (byte)(ID % 256); |
179 | 179 | bytes[i++] = (byte)((ID >> 8) % 256); | |
180 | bytes[i++] = (byte)(ID % 256); | 180 | bytes[i++] = (byte)((ID >> 16) % 256); |
181 | bytes[i++] = (byte)((ID >> 8) % 256); | 181 | bytes[i++] = (byte)((ID >> 24) % 256); |
182 | bytes[i++] = (byte)((ID >> 16) % 256); | 182 | bytes[i++]=0; |
183 | bytes[i++] = (byte)((ID >> 24) % 256); | 183 | bytes[i++]=0;//1; |
184 | bytes[i++]=0; | ||
185 | bytes[i++]=0;//1; | ||
186 | 184 | ||
187 | // i+=14; | 185 | byte[] pb=pos2.GetBytes(); |
188 | // bytes[i++]=128; | 186 | pri.Position=pos2; |
189 | // bytes[i++]=63; | 187 | Array.Copy(pb,0,bytes,i,pb.Length); |
190 | byte[] pb=pos2.GetBytes(); | 188 | i+=12; |
191 | pri.Position=pos2; | 189 | ushort ac=32767; |
192 | Array.Copy(pb,0,bytes,i,pb.Length); | ||
193 | i+=12; | ||
194 | ushort ac=32767; | ||
195 | 190 | ||
196 | //vel | 191 | //vel |
197 | bytes[i++] = (byte)(ac % 256); | 192 | bytes[i++] = (byte)(ac % 256); |
198 | bytes[i++] = (byte)((ac >> 8) % 256); | 193 | bytes[i++] = (byte)((ac >> 8) % 256); |
199 | bytes[i++] = (byte)(ac % 256); | 194 | bytes[i++] = (byte)(ac % 256); |
200 | bytes[i++] = (byte)((ac >> 8) % 256); | 195 | bytes[i++] = (byte)((ac >> 8) % 256); |
201 | bytes[i++] = (byte)(ac % 256); | 196 | bytes[i++] = (byte)(ac % 256); |
202 | bytes[i++] = (byte)((ac >> 8) % 256); | 197 | bytes[i++] = (byte)((ac >> 8) % 256); |
203 | 198 | ||
204 | //accel | 199 | //accel |
205 | bytes[i++] = (byte)(ac % 256); | 200 | bytes[i++] = (byte)(ac % 256); |
206 | bytes[i++] = (byte)((ac >> 8) % 256); | 201 | bytes[i++] = (byte)((ac >> 8) % 256); |
207 | bytes[i++] = (byte)(ac % 256); | 202 | bytes[i++] = (byte)(ac % 256); |
208 | bytes[i++] = (byte)((ac >> 8) % 256); | 203 | bytes[i++] = (byte)((ac >> 8) % 256); |
209 | bytes[i++] = (byte)(ac % 256); | 204 | bytes[i++] = (byte)(ac % 256); |
210 | bytes[i++] = (byte)((ac >> 8) % 256); | 205 | bytes[i++] = (byte)((ac >> 8) % 256); |
211 | 206 | ||
212 | //if(setRotation) | 207 | ushort rw, rx,ry,rz; |
213 | //{ | 208 | rw=(ushort)(32768*rotation2.W); |
214 | 209 | rx=(ushort)(32768*rotation2.X); | |
215 | ushort rw, rx,ry,rz; | 210 | ry=(ushort)(32768*rotation2.Y); |
216 | rw=(ushort)(32768*rotation2.W); | 211 | rz=(ushort)(32768*rotation2.Z); |
217 | rx=(ushort)(32768*rotation2.X); | 212 | |
218 | ry=(ushort)(32768*rotation2.Y); | 213 | //rot |
219 | rz=(ushort)(32768*rotation2.Z); | 214 | bytes[i++] = (byte)(rx % 256); |
220 | 215 | bytes[i++] = (byte)((rx >> 8) % 256); | |
221 | //rot | 216 | bytes[i++] = (byte)(ry % 256); |
222 | bytes[i++] = (byte)(rx % 256); | 217 | bytes[i++] = (byte)((ry >> 8) % 256); |
223 | bytes[i++] = (byte)((rx >> 8) % 256); | 218 | bytes[i++] = (byte)(rz % 256); |
224 | bytes[i++] = (byte)(ry % 256); | 219 | bytes[i++] = (byte)((rz >> 8) % 256); |
225 | bytes[i++] = (byte)((ry >> 8) % 256); | 220 | bytes[i++] = (byte)(rw % 256); |
226 | bytes[i++] = (byte)(rz % 256); | 221 | bytes[i++] = (byte)((rw >> 8) % 256); |
227 | bytes[i++] = (byte)((rz >> 8) % 256); | 222 | |
228 | bytes[i++] = (byte)(rw % 256); | 223 | //rotation vel |
229 | bytes[i++] = (byte)((rw >> 8) % 256); | 224 | bytes[i++] = (byte)(ac % 256); |
230 | //} | 225 | bytes[i++] = (byte)((ac >> 8) % 256); |
231 | /*else | 226 | bytes[i++] = (byte)(ac % 256); |
232 | { | 227 | bytes[i++] = (byte)((ac >> 8) % 256); |
233 | bytes[i++] = (byte)(ac % 256); | 228 | bytes[i++] = (byte)(ac % 256); |
234 | bytes[i++] = (byte)((ac >> 8) % 256); | 229 | bytes[i++] = (byte)((ac >> 8) % 256); |
235 | bytes[i++] = (byte)(ac % 256); | 230 | |
236 | bytes[i++] = (byte)((ac >> 8) % 256); | 231 | dat.Data=bytes; |
237 | bytes[i++] = (byte)(ac % 256); | 232 | |
238 | bytes[i++] = (byte)((ac >> 8) % 256); | 233 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) |
239 | bytes[i++] = (byte)(ac % 256); | 234 | { |
240 | bytes[i++] = (byte)((ac >> 8) % 256); | 235 | if(kp.Value.NetInfo.AgentID!=User.AgentID) |
241 | }*/ | 236 | { |
242 | //rotation vel | 237 | server.SendPacket(im,true,kp.Value.NetInfo); |
243 | bytes[i++] = (byte)(ac % 256); | 238 | } |
244 | bytes[i++] = (byte)((ac >> 8) % 256); | 239 | } |
245 | bytes[i++] = (byte)(ac % 256); | ||
246 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
247 | bytes[i++] = (byte)(ac % 256); | ||
248 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
249 | |||
250 | dat.Data=bytes; | ||
251 | //server.SendPacket(im,true,user); | ||
252 | //should send to all users. | ||
253 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) | ||
254 | { | ||
255 | if(kp.Value.NetInfo.AgentID!=User.AgentID) | ||
256 | { | ||
257 | server.SendPacket(im,true,kp.Value.NetInfo); | ||
258 | } | ||
259 | } | ||
260 | } | 240 | } |
261 | 241 | ||
262 | /// <summary> | 242 | /// <summary> |
@@ -310,49 +290,50 @@ namespace OpenSim | |||
310 | public void ReadPrimDatabase(string name,User_Agent_info user) | 290 | public void ReadPrimDatabase(string name,User_Agent_info user) |
311 | { | 291 | { |
312 | StreamReader SR; | 292 | StreamReader SR; |
313 | string line; | 293 | string line; |
314 | SR=File.OpenText(name); | 294 | SR=File.OpenText(name); |
315 | string [] comp= new string[10]; | 295 | string [] comp= new string[10]; |
316 | string delimStr = " , "; | 296 | string delimStr = " , "; |
317 | char [] delimiter = delimStr.ToCharArray(); | 297 | char [] delimiter = delimStr.ToCharArray(); |
318 | |||
319 | line=SR.ReadLine(); | ||
320 | while(line!="end") | ||
321 | { | ||
322 | comp=line.Split(delimiter); | ||
323 | if(comp[0]=="ObjPack"){ | ||
324 | int num=Convert.ToInt32(comp[2]); | ||
325 | int start=Convert.ToInt32(comp[1]); | ||
326 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | ||
327 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; | ||
328 | objupdate.RegionData.TimeDilation=64096; | ||
329 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; | ||
330 | |||
331 | // int count=0; | ||
332 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\data\"; | ||
333 | for(int cc=0; cc<num; cc++) | ||
334 | { | ||
335 | string filenam=data_path+@"prim_updates"+start+".dat"; | ||
336 | int i=0; | ||
337 | //FileInfo fInfo = new FileInfo("objectupate"+start+".dat"); | ||
338 | FileInfo fInfo = new FileInfo(filenam); | ||
339 | long numBytes = fInfo.Length; | ||
340 | //FileStream fStream = new FileStream("objectupate"+start+".dat", FileMode.Open, FileAccess.Read); | ||
341 | FileStream fStream = new FileStream(filenam, FileMode.Open, FileAccess.Read); | ||
342 | BinaryReader br = new BinaryReader(fStream); | ||
343 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
344 | br.Close(); | ||
345 | fStream.Close(); | ||
346 | 298 | ||
347 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); | ||
348 | objupdate.ObjectData[cc]=objdata; | ||
349 | start++; | ||
350 | } | ||
351 | server.SendPacket(objupdate,true,user); | ||
352 | line=SR.ReadLine(); | 299 | line=SR.ReadLine(); |
353 | } | 300 | while(line!="end") |
354 | } | 301 | { |
355 | SR.Close(); | 302 | comp=line.Split(delimiter); |
303 | if(comp[0]=="ObjPack") | ||
304 | { | ||
305 | int num=Convert.ToInt32(comp[2]); | ||
306 | int start=Convert.ToInt32(comp[1]); | ||
307 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | ||
308 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; | ||
309 | objupdate.RegionData.TimeDilation=64096; | ||
310 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; | ||
311 | |||
312 | // int count=0; | ||
313 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\data\"; | ||
314 | for(int cc=0; cc<num; cc++) | ||
315 | { | ||
316 | string filenam=data_path+@"prim_updates"+start+".dat"; | ||
317 | int i=0; | ||
318 | //FileInfo fInfo = new FileInfo("objectupate"+start+".dat"); | ||
319 | FileInfo fInfo = new FileInfo(filenam); | ||
320 | long numBytes = fInfo.Length; | ||
321 | //FileStream fStream = new FileStream("objectupate"+start+".dat", FileMode.Open, FileAccess.Read); | ||
322 | FileStream fStream = new FileStream(filenam, FileMode.Open, FileAccess.Read); | ||
323 | BinaryReader br = new BinaryReader(fStream); | ||
324 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
325 | br.Close(); | ||
326 | fStream.Close(); | ||
327 | |||
328 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); | ||
329 | objupdate.ObjectData[cc]=objdata; | ||
330 | start++; | ||
331 | } | ||
332 | server.SendPacket(objupdate,true,user); | ||
333 | line=SR.ReadLine(); | ||
334 | } | ||
335 | } | ||
336 | SR.Close(); | ||
356 | } | 337 | } |
357 | } | 338 | } |
358 | 339 | ||