diff options
author | MW | 2007-02-02 17:23:56 +0000 |
---|---|---|
committer | MW | 2007-02-02 17:23:56 +0000 |
commit | e75e6f426bfc069e9185c8c72e8707399edfe299 (patch) | |
tree | 0700369d4d568eed609709abe0c4442637538218 /Agent_Manager.cs | |
parent | Clean up (diff) | |
download | opensim-SC-e75e6f426bfc069e9185c8c72e8707399edfe299.zip opensim-SC-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.gz opensim-SC-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.bz2 opensim-SC-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.xz |
Clean up. Added GridManager and teleport between regions/sims.
Diffstat (limited to '')
-rw-r--r-- | Agent_Manager.cs | 457 |
1 files changed, 249 insertions, 208 deletions
diff --git a/Agent_Manager.cs b/Agent_Manager.cs index 3b05480..9aa8d7f 100644 --- a/Agent_Manager.cs +++ b/Agent_Manager.cs | |||
@@ -32,122 +32,173 @@ using libsecondlife.AssetSystem; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using Axiom.MathLib; | 33 | using Axiom.MathLib; |
34 | 34 | ||
35 | namespace Second_server | 35 | namespace OpenSim |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Description of Agent_Manager. | 38 | /// Description of Agent_Manager. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class Agent_Manager | 40 | public class AgentManager |
41 | { | 41 | { |
42 | public Dictionary<libsecondlife.LLUUID,Avatar_data> Agent_list; | 42 | public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList; |
43 | //public uint number_agents=0; | 43 | |
44 | private uint local_numer=0; | 44 | private uint local_numer=0; |
45 | private Server server; | 45 | private Server server; |
46 | public Prim_manager prim_man; | 46 | public PrimManager Prim_Manager; |
47 | private byte [] data1; | ||
48 | 47 | ||
49 | private libsecondlife.Packets.RegionHandshakePacket reg; | 48 | private libsecondlife.Packets.RegionHandshakePacket RegionPacket; |
50 | private System.Text.Encoding enc = System.Text.Encoding.ASCII; | 49 | private System.Text.Encoding enc = System.Text.Encoding.ASCII; |
51 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock avatar_template; | 50 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; |
52 | //private int appc=0; | 51 | |
53 | 52 | /// <summary> | |
54 | public Agent_Manager(Server serve) | 53 | /// |
54 | /// </summary> | ||
55 | /// <param name="serve"></param> | ||
56 | public AgentManager(Server serve) | ||
55 | { | 57 | { |
56 | Agent_list=new Dictionary<libsecondlife.LLUUID,Avatar_data>(); | 58 | AgentList=new Dictionary<libsecondlife.LLUUID,AvatarData>(); |
57 | server=serve; | 59 | server=serve; |
58 | this.initialise(); | 60 | this.initialise(); |
59 | } | 61 | } |
60 | //*************************************************** | 62 | |
61 | public Avatar_data Get_Agent(LLUUID id) | 63 | /// <summary> |
64 | /// | ||
65 | /// </summary> | ||
66 | /// <param name="id"></param> | ||
67 | /// <returns></returns> | ||
68 | public AvatarData GetAgent(LLUUID id) | ||
62 | { | 69 | { |
63 | 70 | if(!this.AgentList.ContainsKey(id)) | |
64 | |||
65 | if(!this.Agent_list.ContainsKey(id)) | ||
66 | { | 71 | { |
67 | return null; | 72 | return null; |
68 | } | 73 | } |
69 | else | 74 | else |
70 | { | 75 | { |
71 | Avatar_data ad=this.Agent_list[id]; | 76 | AvatarData ad=this.AgentList[id]; |
72 | return ad; | 77 | return ad; |
73 | } | 78 | } |
74 | } | 79 | } |
75 | 80 | /// <summary> | |
76 | public void Add_Agent(Avatar_data agent) | 81 | /// |
82 | /// </summary> | ||
83 | /// <param name="agent"></param> | ||
84 | public void AddAgent(AvatarData agent) | ||
77 | { | 85 | { |
78 | this.Agent_list.Add(agent.Full_ID,agent); | 86 | this.AgentList.Add(agent.FullID,agent); |
79 | } | 87 | } |
88 | /// <summary> | ||
89 | /// | ||
90 | /// </summary> | ||
91 | /// <param name="User_info"></param> | ||
92 | /// <param name="first"></param> | ||
93 | /// <param name="last"></param> | ||
94 | /// <returns></returns> | ||
95 | /// | ||
80 | 96 | ||
81 | public bool New_Agent(User_Agent_info User_info) | 97 | /// <summary> |
98 | /// | ||
99 | /// </summary> | ||
100 | /// <param name="User_info"></param> | ||
101 | /// <param name="first"></param> | ||
102 | /// <param name="last"></param> | ||
103 | /// <returns></returns> | ||
104 | public bool NewAgent(User_Agent_info User_info, string first, string last) | ||
82 | { | 105 | { |
83 | Avatar_data ad=new Avatar_data(); | 106 | AvatarData agent=new AvatarData(); |
84 | ad.Full_ID=User_info.AgentID; | 107 | agent.FullID=User_info.AgentID; |
85 | ad.Net_info=User_info; | 108 | agent.NetInfo=User_info; |
86 | ad.pos=new LLVector3(100,100,22); | 109 | agent.NetInfo.first_name=first; |
87 | this.Agent_list.Add(ad.Full_ID,ad); | 110 | agent.NetInfo.last_name=last; |
111 | agent.Position=new LLVector3(100,100,22); | ||
112 | this.AgentList.Add(agent.FullID,agent); | ||
88 | return(true); | 113 | return(true); |
89 | } | 114 | } |
90 | 115 | ||
91 | public void Agent_join(User_Agent_info User_info) | 116 | /// <summary> |
117 | /// | ||
118 | /// </summary> | ||
119 | /// <param name="UserInfo"></param> | ||
120 | public void RemoveAgent(User_Agent_info UserInfo) | ||
121 | { | ||
122 | this.AgentList.Remove(UserInfo.AgentID); | ||
123 | |||
124 | //tell other clients to delete this avatar | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// | ||
129 | /// </summary> | ||
130 | /// <param name="User_info"></param> | ||
131 | public void AgentJoin(User_Agent_info User_info) | ||
92 | { | 132 | { |
93 | //send region data | 133 | //send region data |
94 | server.SendPacket(reg,true,User_info); | 134 | server.SendPacket(RegionPacket,true,User_info); |
95 | 135 | ||
96 | //inform client of join comlete | 136 | //inform client of join comlete |
97 | libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); | 137 | libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); |
98 | mov.AgentData.SessionID=User_info.SessionID; | 138 | mov.AgentData.SessionID=User_info.SessionID; |
99 | mov.AgentData.AgentID=User_info.AgentID; | 139 | mov.AgentData.AgentID=User_info.AgentID; |
100 | mov.Data.RegionHandle=1096213093147648; | 140 | mov.Data.RegionHandle=Globals.Instance.RegionHandle; |
101 | mov.Data.Timestamp=1169838966; | 141 | mov.Data.Timestamp=1169838966; |
102 | mov.Data.Position=new LLVector3(100f,100f,22f); | 142 | mov.Data.Position=new LLVector3(100f,100f,22f); |
103 | mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); | 143 | mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); |
104 | server.SendPacket(mov,true,User_info); | 144 | server.SendPacket(mov,true,User_info); |
105 | } | 145 | } |
106 | public void tick() | 146 | |
147 | /// <summary> | ||
148 | /// | ||
149 | /// </summary> | ||
150 | public void UpdatePositions() | ||
107 | { | 151 | { |
108 | //update positions | 152 | //update positions |
109 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 153 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
110 | { | 154 | { |
111 | 155 | ||
112 | kp.Value.pos.X+=(kp.Value.vel.X*0.2f); | 156 | kp.Value.Position.X+=(kp.Value.Velocity.X*0.2f); |
113 | kp.Value.pos.Y+=(kp.Value.vel.Y*0.2f); | 157 | kp.Value.Position.Y+=(kp.Value.Velocity.Y*0.2f); |
114 | kp.Value.pos.Z+=(kp.Value.vel.Z*0.2f); | 158 | kp.Value.Position.Z+=(kp.Value.Velocity.Z*0.2f); |
115 | } | 159 | } |
116 | } | 160 | } |
117 | //************************************************************** | 161 | |
162 | /// <summary> | ||
163 | /// | ||
164 | /// </summary> | ||
118 | private void initialise() | 165 | private void initialise() |
119 | { | 166 | { |
120 | //Region data | 167 | //Region data |
121 | reg=new RegionHandshakePacket(); | 168 | RegionPacket=new RegionHandshakePacket(); |
122 | reg.RegionInfo.BillableFactor=0; | 169 | RegionPacket.RegionInfo.BillableFactor=0; |
123 | reg.RegionInfo.IsEstateManager=false; | 170 | RegionPacket.RegionInfo.IsEstateManager=false; |
124 | reg.RegionInfo.TerrainHeightRange00=60; | 171 | RegionPacket.RegionInfo.TerrainHeightRange00=60; |
125 | reg.RegionInfo.TerrainHeightRange01=60; | 172 | RegionPacket.RegionInfo.TerrainHeightRange01=60; |
126 | reg.RegionInfo.TerrainHeightRange10=60; | 173 | RegionPacket.RegionInfo.TerrainHeightRange10=60; |
127 | reg.RegionInfo.TerrainHeightRange11=60; | 174 | RegionPacket.RegionInfo.TerrainHeightRange11=60; |
128 | reg.RegionInfo.TerrainStartHeight00=20; | 175 | RegionPacket.RegionInfo.TerrainStartHeight00=20; |
129 | reg.RegionInfo.TerrainStartHeight01=20; | 176 | RegionPacket.RegionInfo.TerrainStartHeight01=20; |
130 | reg.RegionInfo.TerrainStartHeight10=20; | 177 | RegionPacket.RegionInfo.TerrainStartHeight10=20; |
131 | reg.RegionInfo.TerrainStartHeight11=20; | 178 | RegionPacket.RegionInfo.TerrainStartHeight11=20; |
132 | reg.RegionInfo.SimAccess=13; | 179 | RegionPacket.RegionInfo.SimAccess=13; |
133 | reg.RegionInfo.WaterHeight=5; | 180 | RegionPacket.RegionInfo.WaterHeight=5; |
134 | reg.RegionInfo.RegionFlags=72458694; | 181 | RegionPacket.RegionInfo.RegionFlags=72458694; |
135 | reg.RegionInfo.SimName=enc.GetBytes( "Test Sandbox\0"); | 182 | RegionPacket.RegionInfo.SimName=enc.GetBytes( Globals.Instance.RegionName); |
136 | reg.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); | 183 | RegionPacket.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); |
137 | reg.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | 184 | RegionPacket.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); |
138 | reg.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | 185 | RegionPacket.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); |
139 | reg.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | 186 | RegionPacket.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); |
140 | reg.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | 187 | RegionPacket.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); |
141 | reg.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); | 188 | RegionPacket.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); |
142 | reg.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); | 189 | RegionPacket.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); |
143 | reg.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); | 190 | RegionPacket.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); |
144 | reg.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); | 191 | RegionPacket.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); |
145 | reg.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab33"); | 192 | RegionPacket.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); |
146 | 193 | ||
147 | this.setuptemplate("objectupate168.dat"); | 194 | this.SetupTemplate("objectupate168.dat"); |
148 | } | 195 | } |
149 | 196 | ||
150 | public void setuptemplate(string name) | 197 | /// <summary> |
198 | /// | ||
199 | /// </summary> | ||
200 | /// <param name="name"></param> | ||
201 | private void SetupTemplate(string name) | ||
151 | { | 202 | { |
152 | /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 203 | /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
153 | objupdate.RegionData.RegionHandle=1096213093147648; | 204 | objupdate.RegionData.RegionHandle=1096213093147648; |
@@ -184,95 +235,87 @@ namespace Second_server | |||
184 | 235 | ||
185 | Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); | 236 | Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); |
186 | 237 | ||
187 | avatar_template=objdata; | 238 | AvatarTemplate=objdata; |
188 | 239 | ||
189 | } | 240 | } |
190 | //********************************************************** | 241 | |
191 | public void send_intial_data(User_Agent_info User_info) | 242 | /// <summary> |
243 | /// | ||
244 | /// </summary> | ||
245 | /// <param name="User_info"></param> | ||
246 | public void SendInitialData(User_Agent_info User_info) | ||
192 | { | 247 | { |
193 | 248 | ||
194 | //shouldn't really have to read all this in from disk for every new client? | 249 | //shouldn't have to read all this in from disk for every new client |
195 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; | 250 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; |
196 | 251 | ||
197 | //send layerdata | 252 | //send layerdata |
198 | LayerDataPacket layerpack=new LayerDataPacket(); | 253 | LayerDataPacket layerpack=new LayerDataPacket(); |
199 | layerpack.LayerID.Type=76; | 254 | layerpack.LayerID.Type=76; |
200 | //layerpack.LayerData.ReadfromFile(data_path+@"layerdata0.dat"); | 255 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat"); |
201 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata0.dat"); | 256 | |
202 | |||
203 | //server.SendPacket(layerpack,true,User_info); | ||
204 | |||
205 | LayerDataPacket layerpack1=new LayerDataPacket(); | 257 | LayerDataPacket layerpack1=new LayerDataPacket(); |
206 | layerpack1.LayerID.Type=76; | 258 | layerpack1.LayerID.Type=76; |
207 | //layerpack1.LayerData.ReadfromFile(data_path+@"layerdata1.dat"); | 259 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat"); |
208 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata1.dat"); | ||
209 | //server.SendPacket(layerpack1,true,User_info); | ||
210 | 260 | ||
211 | LayerDataPacket layerpack2=new LayerDataPacket(); | 261 | LayerDataPacket layerpack2=new LayerDataPacket(); |
212 | layerpack2.LayerID.Type=56; | 262 | layerpack2.LayerID.Type=56; |
213 | //layerpack2.LayerData.ReadfromFile(data_path+@"layerdata2.dat"); | 263 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat"); |
214 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata2.dat"); | ||
215 | //server.SendPacket(layerpack2,true,User_info); | ||
216 | 264 | ||
217 | LayerDataPacket layerpack3=new LayerDataPacket(); | 265 | LayerDataPacket layerpack3=new LayerDataPacket(); |
218 | layerpack3.LayerID.Type=55; | 266 | layerpack3.LayerID.Type=55; |
219 | //layerpack3.LayerData.ReadfromFile(data_path+@"layerdata3.dat"); | 267 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat"); |
220 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata3.dat"); | ||
221 | //server.SendPacket(layerpack3,true,User_info); | ||
222 | 268 | ||
223 | LayerDataPacket layerpack4=new LayerDataPacket(); | 269 | LayerDataPacket layerpack4=new LayerDataPacket(); |
224 | layerpack4.LayerID.Type=56; | 270 | layerpack4.LayerID.Type=56; |
225 | //layerpack4.LayerData.ReadfromFile(data_path+@"layerdata4.dat"); | 271 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat"); |
226 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata4.dat"); | ||
227 | //server.SendPacket(layerpack4,true,User_info); | ||
228 | 272 | ||
229 | LayerDataPacket layerpack5=new LayerDataPacket(); | 273 | LayerDataPacket layerpack5=new LayerDataPacket(); |
230 | layerpack5.LayerID.Type=55; | 274 | layerpack5.LayerID.Type=55; |
231 | //layerpack5.LayerData.ReadfromFile(data_path+@"layerdata5.dat"); | 275 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat"); |
232 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata5.dat"); | ||
233 | //server.SendPacket(layerpack5,true,User_info); | ||
234 | |||
235 | 276 | ||
236 | //send intial set of captured prims data? | 277 | //send intial set of captured prims data? |
237 | this.prim_man.Read_Prim_database( "objectdatabase.ini",User_info); | 278 | this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info); |
238 | 279 | ||
239 | //send prims that have been created by users | 280 | //send prims that have been created by users |
240 | //prim_man.send_existing_prims(User_info); | 281 | //prim_man.send_existing_prims(User_info); |
241 | 282 | ||
242 | //send update about clients avatar | 283 | //send update about clients avatar |
243 | this.send_intial_avatar_position(User_info); | 284 | this.SendInitialAvatarPosition(User_info); |
244 | 285 | ||
245 | //send updates about all other users | 286 | //send updates about all other users |
246 | //this.send_test_avatar_position(User_info); | 287 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
247 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | ||
248 | { | 288 | { |
249 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 289 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
250 | { | 290 | { |
251 | this.send_other_avatar_position(User_info,kp.Value); | 291 | this.SendOtherAvatarPosition(User_info,kp.Value); |
252 | } | 292 | } |
253 | } | 293 | } |
254 | |||
255 | |||
256 | } | 294 | } |
257 | public void send_intial_avatar_position(User_Agent_info User_info) | 295 | |
296 | /// <summary> | ||
297 | /// | ||
298 | /// </summary> | ||
299 | /// <param name="User_info"></param> | ||
300 | public void SendInitialAvatarPosition(User_Agent_info User_info) | ||
258 | { | 301 | { |
259 | //send a objectupdate packet with information about the clients avatar | 302 | //send a objectupdate packet with information about the clients avatar |
260 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 303 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
261 | objupdate.RegionData.RegionHandle=1096213093147648; | 304 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
262 | objupdate.RegionData.TimeDilation=64096; | 305 | objupdate.RegionData.TimeDilation=64096; |
263 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 306 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
264 | 307 | ||
265 | objupdate.ObjectData[0]=avatar_template; | 308 | objupdate.ObjectData[0]=AvatarTemplate; |
266 | //give this avatar object a local id and assign the user a name | 309 | //give this avatar object a local id and assign the user a name |
267 | objupdate.ObjectData[0].ID=8880000+this.local_numer; | 310 | objupdate.ObjectData[0].ID=8880000+this.local_numer; |
268 | User_info.localID=objupdate.ObjectData[0].ID; | 311 | User_info.localID=objupdate.ObjectData[0].ID; |
269 | //User_info.name="Test"+this.local_numer+" User"; | 312 | //User_info.name="Test"+this.local_numer+" User"; |
270 | this.Get_Agent(User_info.AgentID).started=true; | 313 | this.GetAgent(User_info.AgentID).Started=true; |
271 | objupdate.ObjectData[0].FullID=User_info.AgentID; | 314 | objupdate.ObjectData[0].FullID=User_info.AgentID; |
272 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | 315 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"); |
273 | User_info.name="FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"; | 316 | User_info.name="FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"; |
274 | User_info.last_name="User"; | 317 | //User_info.last_name="User"; |
275 | User_info.first_name="Test"+this.local_numer; | 318 | //User_info.first_name="Test"+this.local_numer; |
276 | libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); | 319 | libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); |
277 | 320 | ||
278 | byte[] pb=pos2.GetBytes(); | 321 | byte[] pb=pos2.GetBytes(); |
@@ -283,36 +326,23 @@ namespace Second_server | |||
283 | server.SendPacket(objupdate,true,User_info); | 326 | server.SendPacket(objupdate,true,User_info); |
284 | 327 | ||
285 | //send this info to other existing clients | 328 | //send this info to other existing clients |
286 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 329 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
287 | { | 330 | { |
288 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 331 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
289 | { | 332 | { |
290 | server.SendPacket(objupdate,true,kp.Value.Net_info); | 333 | server.SendPacket(objupdate,true,kp.Value.NetInfo); |
291 | this.send_other_apper(kp.Value.Net_info,objupdate.ObjectData[0].FullID); | 334 | this.SendOtherAppearance(kp.Value.NetInfo,objupdate.ObjectData[0].FullID); |
292 | } | 335 | } |
293 | } | 336 | } |
294 | 337 | ||
295 | } | 338 | } |
296 | public void send_intial_avatar_apper(User_Agent_info user) | 339 | |
340 | /// <summary> | ||
341 | /// | ||
342 | /// </summary> | ||
343 | /// <param name="user"></param> | ||
344 | public void SendIntialAvatarAppearance(User_Agent_info user) | ||
297 | { | 345 | { |
298 | |||
299 | //seems that we don't send a avatarapperance for ourself. | ||
300 | /*AvatarAppearancePacket avp=new AvatarAppearancePacket(); | ||
301 | |||
302 | avp.VisualParam=new AvatarAppearancePacket.VisualParamBlock[218]; | ||
303 | avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); | ||
304 | |||
305 | AvatarAppearancePacket.VisualParamBlock avblock=null; | ||
306 | for(int i=0; i<218; i++) | ||
307 | { | ||
308 | avblock=new AvatarAppearancePacket.VisualParamBlock(); | ||
309 | avblock.ParamValue=(byte)100; | ||
310 | avp.VisualParam[i]=avblock; | ||
311 | } | ||
312 | |||
313 | avp.Sender.IsTrial=false; | ||
314 | avp.Sender.ID=user.AgentID; | ||
315 | */ | ||
316 | 346 | ||
317 | AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); | 347 | AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); |
318 | aw.AgentData.AgentID=user.AgentID; | 348 | aw.AgentData.AgentID=user.AgentID; |
@@ -323,22 +353,18 @@ namespace Second_server | |||
323 | aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; | 353 | aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; |
324 | AgentWearablesUpdatePacket.WearableDataBlock awb=null; | 354 | AgentWearablesUpdatePacket.WearableDataBlock awb=null; |
325 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 355 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
326 | awb.WearableType=(byte)0; | 356 | awb.WearableType=(byte)0; |
327 | awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | 357 | awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); |
328 | //awb.ItemID=new LLUUID("b7878000-0000-0000-0000-000000000000"); | 358 | awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); |
329 | awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); | 359 | aw.WearableData[0]=awb; |
330 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); | 360 | |
331 | aw.WearableData[0]=awb; | 361 | /*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
332 | 362 | awb.WearableType=(byte)1; | |
333 | 363 | awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | |
334 | /*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 364 | awb.ItemID=new LLUUID("193f0876fc11d143797454352f9c9c26"); |
335 | awb.WearableType=(byte)1; | 365 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); |
336 | awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | 366 | aw.WearableData[1]=awb;*/ |
337 | awb.ItemID=new LLUUID("193f0876fc11d143797454352f9c9c26"); | 367 | |
338 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
339 | aw.WearableData[1]=awb;*/ | ||
340 | |||
341 | |||
342 | for(int i=1; i<13; i++) | 368 | for(int i=1; i<13; i++) |
343 | { | 369 | { |
344 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 370 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
@@ -348,13 +374,15 @@ namespace Second_server | |||
348 | aw.WearableData[i]=awb; | 374 | aw.WearableData[i]=awb; |
349 | } | 375 | } |
350 | 376 | ||
351 | //server.SendPacket(avp,true,user); | ||
352 | server.SendPacket(aw,true,user); | 377 | server.SendPacket(aw,true,user); |
353 | //System.Console.WriteLine(avp); | ||
354 | |||
355 | |||
356 | } | 378 | } |
357 | public void send_other_apper(User_Agent_info user,LLUUID id) | 379 | |
380 | /// <summary> | ||
381 | /// | ||
382 | /// </summary> | ||
383 | /// <param name="user"></param> | ||
384 | /// <param name="id"></param> | ||
385 | public void SendOtherAppearance(User_Agent_info user,LLUUID id) | ||
358 | { | 386 | { |
359 | AvatarAppearancePacket avp=new AvatarAppearancePacket(); | 387 | AvatarAppearancePacket avp=new AvatarAppearancePacket(); |
360 | 388 | ||
@@ -384,47 +412,25 @@ namespace Second_server | |||
384 | server.SendPacket(avp,true,user); | 412 | server.SendPacket(avp,true,user); |
385 | 413 | ||
386 | } | 414 | } |
387 | 415 | /// <summary> | |
388 | public void send_test_avatar_position(User_Agent_info User_info) | 416 | /// |
389 | { | 417 | /// </summary> |
390 | //send a objectupdate packet with information about the clients avatar | 418 | /// <param name="User_info"></param> |
391 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 419 | /// <param name="avd"></param> |
392 | objupdate.RegionData.RegionHandle=1096213093147648; | 420 | public void SendOtherAvatarPosition(User_Agent_info User_info, AvatarData avd) |
393 | objupdate.RegionData.TimeDilation=64500; | ||
394 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
395 | |||
396 | objupdate.ObjectData[0]=avatar_template; | ||
397 | //give this avatar object a local id and assign the user a name | ||
398 | objupdate.ObjectData[0].ID=8880000+this.local_numer; | ||
399 | objupdate.ObjectData[0].FullID=new LLUUID("00000000-0000-0000-5665-000000000034"); | ||
400 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | ||
401 | libsecondlife.LLVector3 pos2=new LLVector3(120f,120.0f,22.0f); | ||
402 | |||
403 | byte[] pb=pos2.GetBytes(); | ||
404 | |||
405 | Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); | ||
406 | this.local_numer++; | ||
407 | |||
408 | server.SendPacket(objupdate,true,User_info); | ||
409 | |||
410 | this.send_other_apper(User_info,new LLUUID("00000000-0000-0000-5665-000000000034")); | ||
411 | |||
412 | } | ||
413 | |||
414 | public void send_other_avatar_position(User_Agent_info User_info, Avatar_data avd) | ||
415 | { | 421 | { |
416 | //send a objectupdate packet with information about the clients avatar | 422 | //send a objectupdate packet with information about the clients avatar |
417 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 423 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
418 | objupdate.RegionData.RegionHandle=1096213093147648; | 424 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
419 | objupdate.RegionData.TimeDilation=64500; | 425 | objupdate.RegionData.TimeDilation=64500; |
420 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 426 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
421 | 427 | ||
422 | objupdate.ObjectData[0]=avatar_template; | 428 | objupdate.ObjectData[0]=AvatarTemplate; |
423 | //give this avatar object a local id and assign the user a name | 429 | //give this avatar object a local id and assign the user a name |
424 | objupdate.ObjectData[0].ID=avd.Net_info.localID; | 430 | objupdate.ObjectData[0].ID=avd.NetInfo.localID; |
425 | objupdate.ObjectData[0].FullID=avd.Net_info.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); | 431 | objupdate.ObjectData[0].FullID=avd.NetInfo.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); |
426 | objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.Net_info.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | 432 | 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"); |
427 | libsecondlife.LLVector3 pos2=new LLVector3(avd.pos.X,avd.pos.Y,avd.pos.Z); | 433 | libsecondlife.LLVector3 pos2=new LLVector3(avd.Position.X,avd.Position.Y,avd.Position.Z); |
428 | 434 | ||
429 | byte[] pb=pos2.GetBytes(); | 435 | byte[] pb=pos2.GetBytes(); |
430 | 436 | ||
@@ -433,11 +439,16 @@ namespace Second_server | |||
433 | 439 | ||
434 | server.SendPacket(objupdate,true,User_info); | 440 | server.SendPacket(objupdate,true,User_info); |
435 | 441 | ||
436 | this.send_other_apper(User_info,avd.Net_info.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); | 442 | this.SendOtherAppearance(User_info,avd.NetInfo.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); |
437 | 443 | ||
438 | } | 444 | } |
439 | //************************************************************* | 445 | |
440 | public void send_chat_message(User_Agent_info User_info, string line) | 446 | /// <summary> |
447 | /// | ||
448 | /// </summary> | ||
449 | /// <param name="User_info"></param> | ||
450 | /// <param name="line"></param> | ||
451 | public void SendChatMessage(User_Agent_info User_info, string line) | ||
441 | { | 452 | { |
442 | libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); | 453 | libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); |
443 | reply.ChatData.Audible=1; | 454 | reply.ChatData.Audible=1; |
@@ -452,23 +463,33 @@ namespace Second_server | |||
452 | server.SendPacket(reply,true,User_info); | 463 | server.SendPacket(reply,true,User_info); |
453 | 464 | ||
454 | //send to all users | 465 | //send to all users |
455 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 466 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
456 | { | 467 | { |
457 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 468 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
458 | { | 469 | { |
459 | server.SendPacket(reply,true,kp.Value.Net_info); | 470 | server.SendPacket(reply,true,kp.Value.NetInfo); |
460 | } | 471 | } |
461 | } | 472 | } |
462 | } | 473 | } |
463 | //************************************************************* | 474 | |
464 | public void send_move_command(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) | 475 | /// <summary> |
476 | /// | ||
477 | /// </summary> | ||
478 | /// <param name="user"></param> | ||
479 | /// <param name="stop"></param> | ||
480 | /// <param name="x"></param> | ||
481 | /// <param name="y"></param> | ||
482 | /// <param name="z"></param> | ||
483 | /// <param name="av_id"></param> | ||
484 | /// <param name="body"></param> | ||
485 | public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) | ||
465 | { | 486 | { |
466 | uint ID=user.localID; | 487 | uint ID=user.localID; |
467 | //ID=av_id; | 488 | //ID=av_id; |
468 | byte[] bytes=new byte[60]; | 489 | byte[] bytes=new byte[60]; |
469 | 490 | ||
470 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); | 491 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); |
471 | im.RegionData.RegionHandle=1096213093147648; | 492 | im.RegionData.RegionHandle=Globals.Instance.RegionHandle;; |
472 | im.RegionData.TimeDilation=64096; | 493 | im.RegionData.TimeDilation=64096; |
473 | 494 | ||
474 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 495 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
@@ -477,7 +498,7 @@ namespace Second_server | |||
477 | 498 | ||
478 | im.ObjectData[0]=dat; | 499 | im.ObjectData[0]=dat; |
479 | 500 | ||
480 | dat.TextureEntry=avatar_template.TextureEntry; | 501 | dat.TextureEntry=AvatarTemplate.TextureEntry; |
481 | libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); | 502 | libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); |
482 | 503 | ||
483 | bytes[i++] = (byte)(ID % 256); | 504 | bytes[i++] = (byte)(ID % 256); |
@@ -571,16 +592,22 @@ namespace Second_server | |||
571 | server.SendPacket(im,true,user); | 592 | server.SendPacket(im,true,user); |
572 | 593 | ||
573 | //should send to all users. | 594 | //should send to all users. |
574 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 595 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
575 | { | 596 | { |
576 | if(kp.Value.Net_info.AgentID!=user.AgentID) | 597 | if(kp.Value.NetInfo.AgentID!=user.AgentID) |
577 | { | 598 | { |
578 | server.SendPacket(im,true,kp.Value.Net_info); | 599 | server.SendPacket(im,true,kp.Value.NetInfo); |
579 | } | 600 | } |
580 | } | 601 | } |
581 | } | 602 | } |
582 | //************************************************************* | 603 | |
583 | public void read_layerdata(User_Agent_info User_info,ref LayerDataPacket lay,string name) | 604 | /// <summary> |
605 | /// | ||
606 | /// </summary> | ||
607 | /// <param name="User_info"></param> | ||
608 | /// <param name="lay"></param> | ||
609 | /// <param name="name"></param> | ||
610 | public void SendLayerData(User_Agent_info User_info,ref LayerDataPacket lay,string name) | ||
584 | { | 611 | { |
585 | FileInfo fInfo = new FileInfo(name); | 612 | FileInfo fInfo = new FileInfo(name); |
586 | 613 | ||
@@ -590,7 +617,7 @@ namespace Second_server | |||
590 | 617 | ||
591 | BinaryReader br = new BinaryReader(fStream); | 618 | BinaryReader br = new BinaryReader(fStream); |
592 | 619 | ||
593 | data1 = br.ReadBytes((int)numBytes); | 620 | byte [] data1 = br.ReadBytes((int)numBytes); |
594 | 621 | ||
595 | br.Close(); | 622 | br.Close(); |
596 | 623 | ||
@@ -601,18 +628,32 @@ namespace Second_server | |||
601 | } | 628 | } |
602 | } | 629 | } |
603 | 630 | ||
604 | public class Avatar_data | 631 | public class AvatarData |
605 | { | 632 | { |
606 | public User_Agent_info Net_info; | 633 | public User_Agent_info NetInfo; |
607 | public LLUUID Full_ID; | 634 | public LLUUID FullID; |
608 | public LLVector3 pos; | 635 | public LLVector3 Position; |
609 | public LLVector3 vel=new LLVector3(0,0,0); | 636 | public LLVector3 Velocity=new LLVector3(0,0,0); |
610 | public bool walk=false; | 637 | //public LLQuaternion Rotation; |
611 | public bool started=false; | 638 | public bool Walk=false; |
639 | public bool Started=false; | ||
640 | //public TextureEntry TextureEntry; | ||
612 | 641 | ||
613 | public Avatar_data() | 642 | public AvatarData() |
614 | { | 643 | { |
615 | 644 | ||
616 | } | 645 | } |
617 | } | 646 | } |
647 | /* | ||
648 | public class AvatarParams | ||
649 | { | ||
650 | public byte[] Params; | ||
651 | |||
652 | public AvatarParams() | ||
653 | { | ||
654 | |||
655 | } | ||
656 | |||
657 | } | ||
658 | */ | ||
618 | } | 659 | } |